Tony20100/langchain_full huggingface dataset:
exclude_tables (Optional[List[str]]) – 
include_tables (Optional[List[str]]) – 
cassio_init_kwargs (Optional[Dict[str, Any]]) – 
fetch_all(query: str, **kwargs: Any) → list[source]¶
Parameters
query (str) – 
kwargs (Any) – 
Return type
list
fetch_one(query: str, **kwargs: Any) → Dict[str, Any][source]¶
Parameters
query (str) – 
kwargs (Any) – 
Return type
Dict[str, Any]
format_keyspace_to_markdown(keyspace: str, tables: Optional[List[Table]] = None) → str[source]¶
Generates a markdown representation of the schema for a specific keyspace
by iterating over all tables within that keyspace and calling their
as_markdown method.
Parameters
keyspace (str) – The name of the keyspace to generate markdown documentation for.
tables (Optional[List[Table]]) – list of tables in the keyspace; it will be resolved if not provided.
Returns
A string containing the markdown representation of the specified
keyspace schema.
Return type
str
format_schema_to_markdown() → str[source]¶
Generates a markdown representation of the schema for all keyspaces and tables
within the CassandraDatabase instance. This method utilizes the
format_keyspace_to_markdown method to create markdown sections for each
keyspace, assembling them into a comprehensive schema document.
Iterates through each keyspace in the database, utilizing
format_keyspace_to_markdown to generate markdown for each keyspace’s schema,
including details of its tables. These sections are concatenated to form a
single markdown document that represents the schema of the entire database or
the subset of keyspaces that have been resolved in this instance.
Returns
A markdown string that documents the schema of all resolved keyspaces and
Returns
A markdown string that documents the schema of all resolved keyspaces and
their tables within this CassandraDatabase instance. This includes keyspace
names, table names, comments, columns, partition keys, clustering keys,
and indexes for each table.
Return type
str
get_context() → Dict[str, Any][source]¶
Return db context that you may want in agent prompt.
Return type
Dict[str, Any]
get_keyspace_tables(keyspace: str) → List[Table][source]¶
Get the Table objects for the specified keyspace.
Parameters
keyspace (str) – 
Return type
List[Table]
get_table_data(keyspace: str, table: str, predicate: str, limit: int) → str[source]¶
Get data from the specified table in the specified keyspace.
Parameters
keyspace (str) – 
table (str) – 
predicate (str) – 
limit (int) – 
Return type
str
run(query: str, fetch: str = 'all', **kwargs: Any) → Union[list, Dict[str, Any], ResultSet][source]¶
Execute a CQL query and return the results.
Parameters
query (str) – 
fetch (str) – 
kwargs (Any) – 
Return type
Union[list, Dict[str, Any], ResultSet]
Examples using CassandraDatabase¶
Cassandra Database
langchain_community.utilities.searx_search.SearxResults¶
class langchain_community.utilities.searx_search.SearxResults(data: str)[source]¶
Dict like wrapper around search api results.
Take a raw result from Searx and make it into a dict like object.
Attributes
answers
Helper accessor on the json result.
results
Silence mypy for accessing this field.
Methods
__init__(data)
Take a raw result from Searx and make it into a dict like object.
clear()
copy()
fromkeys([value])
Create a new dictionary with keys from iterable and values set to value.
get(key[, default])
Return the value for key if key is in the dictionary, else default.
items()
keys()
pop(k[,d])
If the key is not found, return the default if given; otherwise, raise a KeyError.
popitem()
Remove and return a (key, value) pair as a 2-tuple.
setdefault(key[, default])
Insert key with a value of default if key is not in the dictionary.
update([E, ]**F)
If E is present and has a .keys() method, then does:  for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does:  for k, v in E: D[k] = v In either case, this is followed by: for k in F:  D[k] = F[k]
values()
Parameters
data (str) – 
__init__(data: str)[source]¶
Take a raw result from Searx and make it into a dict like object.
Parameters
data (str) – 
clear() → None.  Remove all items from D.¶
clear() → None.  Remove all items from D.¶
copy() → a shallow copy of D¶
fromkeys(value=None, /)¶
Create a new dictionary with keys from iterable and values set to value.
get(key, default=None, /)¶
Return the value for key if key is in the dictionary, else default.
items() → a set-like object providing a view on D's items¶
keys() → a set-like object providing a view on D's keys¶
pop(k[, d]) → v, remove specified key and return the corresponding value.¶
If the key is not found, return the default if given; otherwise,
raise a KeyError.
popitem()¶
Remove and return a (key, value) pair as a 2-tuple.
Pairs are returned in LIFO (last-in, first-out) order.
Raises KeyError if the dict is empty.
setdefault(key, default=None, /)¶
Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.
update([E, ]**F) → None.  Update D from dict/iterable E and F.¶
If E is present and has a .keys() method, then does:  for k in E: D[k] = E[k]
If E is present and lacks a .keys() method, then does:  for k, v in E: D[k] = v
In either case, this is followed by: for k in F:  D[k] = F[k]
values() → an object providing a view on D's values¶
langchain_community.utilities.clickup.Team¶
class langchain_community.utilities.clickup.Team(id: int, name: str, members: List[Member])[source]¶
Component class for a team.
Attributes
id
name
members
Methods
__init__(id, name, members)
from_data(data)
Parameters
id (int) – 
name (str) – 
members (List[Member]) – 
__init__(id: int, name: str, members: List[Member]) → None¶
Parameters
id (int) – 
name (str) – 
members (List[Member]) – 
Return type
None
classmethod from_data(data: Dict) → Team[source]¶
Parameters
data (Dict) – 
Return type
Team
cell phone number. If you are using messaging_service_sid, this parameter
must be empty.
classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) → Model¶
Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
Behaves as if Config.extra = ‘allow’ was set since it adds all passed values
Parameters
_fields_set (Optional[SetStr]) – 
values (Any) – 
Return type
Model
copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) → Model¶
Duplicate a model, optionally choose which fields to include, exclude and change.
Parameters
include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to include in new model
exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to exclude from new model, as with values this takes precedence over include
update (Optional[DictStrAny]) – values to change/add in the new model. Note: the data is not validated before creating
the new model: you should trust this data
deep (bool) – set to True to make a deep copy of the model
self (Model) – 
Returns
new model instance
Return type
Model
Parameters
include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – 
exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – 
by_alias (bool) – 
skip_defaults (Optional[bool]) – 
exclude_unset (bool) – 
exclude_defaults (bool) – 
exclude_none (bool) – 
encoder (Optional[Callable[[Any], Any]]) – 
models_as_dict (bool) – 
dumps_kwargs (Any) – 
Return type
unicode
classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶
Parameters
path (Union[str, Path]) – 
content_type (unicode) – 
encoding (unicode) – 
proto (Protocol) – 
allow_pickle (bool) – 
Return type
Model
classmethod parse_obj(obj: Any) → Model¶
Parameters
obj (Any) – 
Return type
Model
classmethod parse_raw(b: Union[str, bytes], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶
Parameters
b (Union[str, bytes]) – 
content_type (unicode) – 
encoding (unicode) – 
proto (Protocol) – 
allow_pickle (bool) – 
Return type
Model
run(body: str, to: str) → str[source]¶
Run body through Twilio and respond with message sid.
Parameters
body (str) – The text of the message you want to send. Can be up to 1,600
characters in length.
to (str) – The destination phone number in
characters in length.
to (str) – The destination phone number in
[E.164](https://www.twilio.com/docs/glossary/what-e164) format for
SMS/MMS or
[Channel user address](https://www.twilio.com/docs/sms/channels#channel-addresses)
for other 3rd-party channels.
Return type
str
classmethod schema(by_alias: bool = True, ref_template: unicode = '#/definitions/{model}') → DictStrAny¶
Parameters
by_alias (bool) – 
ref_template (unicode) – 
Return type
DictStrAny
classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) → unicode¶
Parameters
by_alias (bool) – 
ref_template (unicode) – 
dumps_kwargs (Any) – 
Return type
unicode
classmethod update_forward_refs(**localns: Any) → None¶
Try to update ForwardRefs on fields based on this Model, globalns and localns.
Parameters
localns (Any) – 
Return type
None
classmethod validate(value: Any) → Model¶
Parameters
value (Any) – 
Return type
Model
Examples using TwilioAPIWrapper¶
Twilio
langchain_community.utilities.arcee.ArceeWrapper¶
class langchain_community.utilities.arcee.ArceeWrapper(arcee_api_key: Union[str, SecretStr], arcee_api_url: str, arcee_api_version: str, model_kwargs: Optional[Dict[str, Any]], model_name: str)[source]¶
Wrapper for Arcee API.
For more details, see: https://www.arcee.ai/
Initialize ArceeWrapper.
Parameters
arcee_api_key (Union[str, SecretStr]) – API key for Arcee API.
arcee_api_url (str) – URL for Arcee API.
arcee_api_version (str) – Version of Arcee API.
model_kwargs (Optional[Dict[str, Any]]) – Keyword arguments for Arcee API.
model_name (str) – Name of an Arcee model.
Methods
__init__(arcee_api_key, arcee_api_url, ...)
Initialize ArceeWrapper.
generate(prompt, **kwargs)
Generate text from Arcee DALM.
retrieve(query, **kwargs)
Retrieve {size} contexts with your retriever for a given query
validate_model_training_status()
__init__(arcee_api_key: Union[str, SecretStr], arcee_api_url: str, arcee_api_version: str, model_kwargs: Optional[Dict[str, Any]], model_name: str)[source]¶
Initialize ArceeWrapper.
Parameters
arcee_api_key (Union[str, SecretStr]) – API key for Arcee API.
arcee_api_url (str) – URL for Arcee API.
arcee_api_version (str) – Version of Arcee API.
model_kwargs (Optional[Dict[str, Any]]) – Keyword arguments for Arcee API.
model_name (str) – Name of an Arcee model.
generate(prompt: str, **kwargs: Any) → str[source]¶
generate(prompt: str, **kwargs: Any) → str[source]¶
Generate text from Arcee DALM.
Parameters
prompt (str) – Prompt to generate text from.
size – The max number of context results to retrieve. Defaults to 3.
(Can be less if filters are provided).
filters – Filters to apply to the context dataset.
kwargs (Any) – 
Return type
str
retrieve(query: str, **kwargs: Any) → List[Document][source]¶
Retrieve {size} contexts with your retriever for a given query
Parameters
query (str) – Query to submit to the model
size – The max number of context results to retrieve. Defaults to 3.
(Can be less if filters are provided).
filters – Filters to apply to the context dataset.
kwargs (Any) – 
Return type
List[Document]
validate_model_training_status() → None[source]¶
Return type
None
langchain_community.utilities.serpapi.SerpAPIWrapper¶
class langchain_community.utilities.serpapi.SerpAPIWrapper[source]¶
Bases: BaseModel
Wrapper around SerpAPI.
To use, you should have the google-search-results python package installed,
and the environment variable SERPAPI_API_KEY set with your API key, or pass
serpapi_api_key as a named parameter to the constructor.
Example
from langchain_community.utilities import SerpAPIWrapper
serpapi = SerpAPIWrapper()
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
param aiosession: Optional[ClientSession] = None¶
param params: dict = {'engine': 'google', 'gl': 'us', 'google_domain': 'google.com', 'hl': 'en'}¶
param serpapi_api_key: Optional[str] = None¶
async aresults(query: str) → dict[source]¶
Use aiohttp to run query through SerpAPI and return the results async.
Parameters
query (str) – 
Return type
dict
async arun(query: str, **kwargs: Any) → str[source]¶
Run query through SerpAPI and parse result async.
Parameters
query (str) – 
kwargs (Any) – 
Return type
str
classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) → Model¶
Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
Behaves as if Config.extra = ‘allow’ was set since it adds all passed values
Parameters
_fields_set (Optional[SetStr]) – 
values (Any) – 
Return type
Model
exclude_unset (bool) – 
exclude_defaults (bool) – 
exclude_none (bool) – 
Return type
DictStrAny
classmethod from_orm(obj: Any) → Model¶
Parameters
obj (Any) – 
Return type
Model
get_params(query: str) → Dict[str, str][source]¶
Get parameters for SerpAPI.
Parameters
query (str) – 
Return type
Dict[str, str]
json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) → unicode¶
Generate a JSON representation of the model, include and exclude arguments as per dict().
encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().
Parameters
include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – 
exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – 
by_alias (bool) – 
skip_defaults (Optional[bool]) – 
exclude_unset (bool) – 
exclude_defaults (bool) – 
exclude_none (bool) – 
encoder (Optional[Callable[[Any], Any]]) – 
models_as_dict (bool) – 
dumps_kwargs (Any) – 
Return type
unicode
dumps_kwargs (Any) – 
Return type
unicode
classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶
Parameters
path (Union[str, Path]) – 
content_type (unicode) – 
encoding (unicode) – 
proto (Protocol) – 
allow_pickle (bool) – 
Return type
Model
classmethod parse_obj(obj: Any) → Model¶
Parameters
obj (Any) – 
Return type
Model
classmethod parse_raw(b: Union[str, bytes], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶
Parameters
b (Union[str, bytes]) – 
content_type (unicode) – 
encoding (unicode) – 
proto (Protocol) – 
allow_pickle (bool) – 
Return type
Model
results(query: str) → dict[source]¶
Run query through SerpAPI and return the raw result.
Parameters
query (str) – 
Return type
dict
run(query: str, **kwargs: Any) → str[source]¶
Run query through SerpAPI and parse result.
Parameters
query (str) – 
kwargs (Any) – 
Return type
str
classmethod schema(by_alias: bool = True, ref_template: unicode = '#/definitions/{model}') → DictStrAny¶
Parameters
by_alias (bool) – 
ref_template (unicode) – 
Return type
DictStrAny
classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) → unicode¶
Parameters
by_alias (bool) –
Parameters
by_alias (bool) – 
ref_template (unicode) – 
dumps_kwargs (Any) – 
Return type
unicode
classmethod update_forward_refs(**localns: Any) → None¶
Try to update ForwardRefs on fields based on this Model, globalns and localns.
Parameters
localns (Any) – 
Return type
None
classmethod validate(value: Any) → Model¶
Parameters
value (Any) – 
Return type
Model
Examples using SerpAPIWrapper¶
Google
Hugging Face
MLX
SerpAPI
langchain_community.utilities.nvidia_riva.RivaASR¶
class langchain_community.utilities.nvidia_riva.RivaASR[source]¶
Bases: RivaAuthMixin, RivaCommonConfigMixin, RunnableSerializable[AudioStream, str]
A runnable that performs Automatic Speech Recognition (ASR) using NVIDIA Riva.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
param audio_channel_count: int = 1¶
The number of audio channels in the input audio stream.
param description: str = 'A Runnable for converting audio bytes to a string.This is useful for feeding an audio stream into a chain andpreprocessing that audio to create an LLM prompt.'¶
param enable_automatic_punctuation: bool = True¶
Controls whether Riva should attempt to correct senetence puncuation in the transcribed text.
param encoding: RivaAudioEncoding = RivaAudioEncoding.LINEAR_PCM¶
The encoding on the audio stream.
param language_code: str = 'en-US'¶
The [BCP-47 language code](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) for the target language.
param profanity_filter: bool = True¶
Controls whether or not Riva should attempt to filter profanity out of the transcribed text.
param sample_rate_hertz: int = 8000¶
The sample rate frequency of audio stream.
param ssl_cert: Optional[str] = None¶
A full path to the file where Riva’s public ssl key can be read.
param url: Union[AnyHttpUrl, str] = AnyHttpUrl('http://localhost:50051', )¶
The full URL where the Riva service can be found.
The full URL where the Riva service can be found.
async abatch(inputs: List[Input], config: Optional[Union[RunnableConfig, List[RunnableConfig]]] = None, *, return_exceptions: bool = False, **kwargs: Optional[Any]) → List[Output]¶
Default implementation runs ainvoke in parallel using asyncio.gather.
The default implementation of batch works well for IO bound runnables.
Subclasses should override this method if they can batch more efficiently;
e.g., if the underlying runnable uses an API which supports a batch mode.
Parameters
inputs (List[Input]) – 
config (Optional[Union[RunnableConfig, List[RunnableConfig]]]) – 
return_exceptions (bool) – 
kwargs (Optional[Any]) – 
Return type
List[Output]
async abatch_as_completed(inputs: Sequence[Input], config: Optional[Union[RunnableConfig, Sequence[RunnableConfig]]] = None, *, return_exceptions: bool = False, **kwargs: Optional[Any]) → AsyncIterator[Tuple[int, Union[Output, Exception]]]¶
Run ainvoke in parallel on a list of inputs,
yielding results as they complete.
Parameters
inputs (Sequence[Input]) – 
config (Optional[Union[RunnableConfig, Sequence[RunnableConfig]]]) – 
return_exceptions (bool) – 
kwargs (Optional[Any]) – 
Return type
AsyncIterator[Tuple[int, Union[Output, Exception]]]
async ainvoke(input: Input, config: Optional[RunnableConfig] = None, **kwargs: Any) → Output¶
Default implementation of ainvoke, calls invoke from a thread.
The default implementation allows usage of async code even if
the runnable did not implement a native async version of invoke.
Subclasses should override this method if they can run asynchronously.
Parameters
input (Input) –
Parameters
input (Input) – 
config (Optional[RunnableConfig]) – 
kwargs (Any) – 
Return type
Output
assign(**kwargs: Union[Runnable[Dict[str, Any], Any], Callable[[Dict[str, Any]], Any], Mapping[str, Union[Runnable[Dict[str, Any], Any], Callable[[Dict[str, Any]], Any]]]]) → RunnableSerializable[Any, Any]¶
Assigns new fields to the dict output of this runnable.
Returns a new runnable.
from langchain_community.llms.fake import FakeStreamingListLLM
from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import SystemMessagePromptTemplate
from langchain_core.runnables import Runnable
from operator import itemgetter
prompt = (
    SystemMessagePromptTemplate.from_template("You are a nice assistant.")
    + "{question}"
)
llm = FakeStreamingListLLM(responses=["foo-lish"])
chain: Runnable = prompt | llm | {"str": StrOutputParser()}
chain_with_assign = chain.assign(hello=itemgetter("str") | llm)
print(chain_with_assign.input_schema.schema())
# {'title': 'PromptInput', 'type': 'object', 'properties':
{'question': {'title': 'Question', 'type': 'string'}}}
print(chain_with_assign.output_schema.schema()) #
{'title': 'RunnableSequenceOutput', 'type': 'object', 'properties':
{'str': {'title': 'Str',
'type': 'string'}, 'hello': {'title': 'Hello', 'type': 'string'}}}
Parameters
kwargs (Union[Runnable[Dict[str, Any], Any], Callable[[Dict[str, Any]], Any], Mapping[str, Union[Runnable[Dict[str, Any], Any], Callable[[Dict[str, Any]], Any]]]]) – 
Return type
methods will have a dynamic input schema that depends on which
configuration the runnable is invoked with.
This method allows to get an input schema for a specific configuration.
Parameters
config (Optional[RunnableConfig]) – A config to use when generating the schema.
Returns
A pydantic model that can be used to validate input.
Return type
Type[BaseModel]
classmethod get_lc_namespace() → List[str]¶
Get the namespace of the langchain object.
For example, if the class is langchain.llms.openai.OpenAI, then the
namespace is [“langchain”, “llms”, “openai”]
Return type
List[str]
get_name(suffix: Optional[str] = None, *, name: Optional[str] = None) → str¶
Get the name of the runnable.
Parameters
suffix (Optional[str]) – 
name (Optional[str]) – 
Return type
str
get_output_schema(config: Optional[RunnableConfig] = None) → Type[BaseModel]¶
Get a pydantic model that can be used to validate output to the runnable.
Runnables that leverage the configurable_fields and configurable_alternatives
methods will have a dynamic output schema that depends on which
configuration the runnable is invoked with.
This method allows to get an output schema for a specific configuration.
Parameters
config (Optional[RunnableConfig]) – A config to use when generating the schema.
Returns
A pydantic model that can be used to validate output.
Return type
Type[BaseModel]
get_prompts(config: Optional[RunnableConfig] = None) → List[BasePromptTemplate]¶
Parameters
config (Optional[RunnableConfig]) – 
Return type
List[BasePromptTemplate]
invoke(input: AudioStream, _: Optional[RunnableConfig] = None) → str[source]¶
Transcribe the audio bytes into a string with Riva.
Parameters
input (AudioStream) – 
_ (Optional[RunnableConfig]) – 
Return type
str
classmethod is_lc_serializable() → bool¶
Is this class serializable?
Return type
bool
json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) → unicode¶
Generate a JSON representation of the model, include and exclude arguments as per dict().
encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().
Parameters
include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – 
exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – 
by_alias (bool) – 
skip_defaults (Optional[bool]) – 
exclude_unset (bool) – 
exclude_defaults (bool) – 
exclude_none (bool) – 
encoder (Optional[Callable[[Any], Any]]) – 
models_as_dict (bool) – 
dumps_kwargs (Any) – 
Return type
unicode
classmethod lc_id() → List[str]¶
A unique identifier for this class for serialization purposes.
The unique identifier is a list of strings that describes the path
to the object.
Return type
List[str]
map() → Runnable[List[Input], List[Output]]¶