Tony20100/langchain_full huggingface dataset:
stop_after_attempt (int) – The maximum number of attempts to make before giving up
Returns
A new Runnable that retries the original runnable on exceptions.
Return type
Runnable[Input, Output]
with_types(*, input_type: Optional[Type[Input]] = None, output_type: Optional[Type[Output]] = None) → Runnable[Input, Output]¶
Bind input and output types to a Runnable, returning a new Runnable.
Parameters
input_type (Optional[Type[Input]]) – 
output_type (Optional[Type[Output]]) – 
Return type
Runnable[Input, Output]
property InputType: Type[Input]¶
The type of input this runnable accepts specified as a type annotation.
property OutputType: Type[Output]¶
The type of output this runnable produces specified as a type annotation.
property auth: riva.client.Auth¶
Return a riva client auth object.
property config: riva.client.StreamingRecognitionConfig¶
Create and return the riva config object.
property config_specs: List[ConfigurableFieldSpec]¶
List configurable fields for this runnable.
property input_schema: Type[BaseModel]¶
The type of input this runnable accepts specified as a pydantic model.
property lc_attributes: Dict¶
List of attribute names that should be included in the serialized kwargs.
These attributes must be accepted by the constructor.
property lc_secrets: Dict[str, str]¶
A map of constructor argument names to secret ids.
For example,{“openai_api_key”: “OPENAI_API_KEY”}
name: str = None¶
The name of the runnable. Used for debugging and tracing.
property output_schema: Type[BaseModel]¶
The type of output this runnable produces specified as a pydantic model.
Examples using RivaASR¶
langchain_community.utilities.dria_index.DriaAPIWrapper¶
class langchain_community.utilities.dria_index.DriaAPIWrapper(api_key: str, contract_id: Optional[str] = None, top_n: int = 10)[source]¶
Wrapper around Dria API.
This wrapper facilitates interactions with Dria’s vector search
and retrieval services, including creating knowledge bases, inserting data,
and fetching search results.
Parameters
api_key (str) – 
contract_id (Optional[str]) – 
top_n (int) – 
api_key¶
Your API key for accessing Dria.
contract_id¶
The contract ID of the knowledge base to interact with.
top_n¶
Number of top results to fetch for a search.
Methods
__init__(api_key[, contract_id, top_n])
create_knowledge_base(name, description, ...)
Create a new knowledge base.
insert_data(data)
Insert data into the knowledge base.
query_with_vector(vector)
Perform a vector-based query.
run(query)
Method to handle both text-based searches and vector-based queries.
search(query)
Perform a text-based search.
__init__(api_key: str, contract_id: Optional[str] = None, top_n: int = 10)[source]¶
Parameters
api_key (str) – 
contract_id (Optional[str]) – 
top_n (int) – 
create_knowledge_base(name: str, description: str, category: str, embedding: str) → str[source]¶
Create a new knowledge base.
Parameters
name (str) – 
description (str) – 
category (str) – 
embedding (str) – 
Return type
str
insert_data(data: List[Dict[str, Any]]) → str[source]¶
Insert data into the knowledge base.
Parameters
Insert data into the knowledge base.
Parameters
data (List[Dict[str, Any]]) – 
Return type
str
query_with_vector(vector: List[float]) → List[Dict[str, Any]][source]¶
Perform a vector-based query.
Parameters
vector (List[float]) – 
Return type
List[Dict[str, Any]]
run(query: Union[str, List[float]]) → Optional[List[Dict[str, Any]]][source]¶
Method to handle both text-based searches and vector-based queries.
Parameters
query (Union[str, List[float]]) – A string for text-based search or a list of floats for
query. (vector-based) – 
Returns
The search or query results from Dria.
Return type
Optional[List[Dict[str, Any]]]
search(query: str) → List[Dict[str, Any]][source]¶
Perform a text-based search.
Parameters
query (str) – 
Return type
List[Dict[str, Any]]
langchain_community.utilities.redis.get_client¶
langchain_community.utilities.redis.get_client(redis_url: str, **kwargs: Any) → RedisType[source]¶
Get a redis client from the connection url given. This helper accepts
urls for Redis server (TCP with/without TLS or UnixSocket) as well as
Redis Sentinel connections.
Redis Cluster is not supported.
Before creating a connection the existence of the database driver is checked
an and ValueError raised otherwise
To use, you should have the redis python package installed.
Example
from langchain_community.utilities.redis import get_client
redis_client = get_client(
    redis_url="redis://username:password@localhost:6379"
    index_name="my-index",
    embedding_function=embeddings.embed_query,
)
To use a redis replication setup with multiple redis server and redis sentinels
set “redis_url” to “redis+sentinel://” scheme. With this url format a path is
needed holding the name of the redis service within the sentinels to get the
correct redis server connection. The default service name is “mymaster”. The
optional second part of the path is the redis db number to connect to.
An optional username or password is used for booth connections to the rediserver
and the sentinel, different passwords for server and sentinel are not supported.
And as another constraint only one sentinel instance can be given:
Example
from langchain_community.utilities.redis import get_client
redis_client = get_client(
    redis_url="redis+sentinel://username:password@sentinelhost:26379/mymaster/0"
    index_name="my-index",
    embedding_function=embeddings.embed_query,
)
Parameters
redis_url (str) – 
kwargs (Any) – 
Return type
RedisType
langchain_community.utilities.scenexplain.SceneXplainAPIWrapper¶
class langchain_community.utilities.scenexplain.SceneXplainAPIWrapper[source]¶
Bases: BaseSettings, BaseModel
Wrapper for SceneXplain API.
In order to set this up, you need API key for the SceneXplain API.
You can obtain a key by following the steps below.
- Sign up for a free account at https://scenex.jina.ai/.
- Navigate to the API Access page (https://scenex.jina.ai/api)
and create a new API key.
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 scenex_api_key: str [Required]¶
param scenex_api_url: str = 'https://api.scenex.jina.ai/v1/describe'¶
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
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(image: str) → str[source]¶
Run SceneXplain image explainer.
Parameters
image (str) – 
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
langchain_community.utilities.pebblo.Runtime¶
class langchain_community.utilities.pebblo.Runtime[source]¶
Bases: BaseModel
Pebblo Runtime.
Parameters
type (Optional[str]) – Runtime type. Defaults to “”
host (str) – Hostname of runtime.
path (str) – Current working directory path.
ip (Optional[str]) – Ip of current runtime. Defaults to “”
platform (str) – Platform details of current runtime.
os (str) – OS name.
os_version (str) – OS version.
language (str) – Runtime kernel.
language_version (str) – version of current runtime kernel.
runtime (Optional[str]) – 
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 host: str [Required]¶
param ip: Optional[str] = ''¶
param language: str [Required]¶
param language_version: str [Required]¶
param os: str [Required]¶
param os_version: str [Required]¶
param path: str [Required]¶
param platform: str [Required]¶
param runtime: str = 'local'¶
param type: str = 'local'¶
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
langchain_community.utilities.apify.ApifyWrapper¶
class langchain_community.utilities.apify.ApifyWrapper[source]¶
Bases: BaseModel
Wrapper around Apify.
To use, you should have the apify-client python package installed,
and the environment variable APIFY_API_TOKEN set with your API key, or pass
apify_api_token as a named parameter to the constructor.
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 apify_api_token: Optional[str] = None¶
param apify_client: Any = None¶
param apify_client_async: Any = None¶
async acall_actor(actor_id: str, run_input: Dict, dataset_mapping_function: Callable[[Dict], Document], *, build: Optional[str] = None, memory_mbytes: Optional[int] = None, timeout_secs: Optional[int] = None) → ApifyDatasetLoader[source]¶
Run an Actor on the Apify platform and wait for results to be ready.
:param actor_id: The ID or name of the Actor on the Apify platform.
:type actor_id: str
:param run_input: The input object of the Actor that you’re trying to run.
:type run_input: Dict
:param dataset_mapping_function: A function that takes a single
dictionary (an Apify dataset item) and converts it to
an instance of the Document class.
Parameters
build (str, optional) – Optionally specifies the actor build to run.
It can be either a build tag or build number.
memory_mbytes (int, optional) – Optional memory limit for the run,
in megabytes.
timeout_secs (int, optional) – Optional timeout for the run, in seconds.
actor_id (str) – 
run_input (Dict) – 
dataset_mapping_function (Callable) –
run_input (Dict) – 
dataset_mapping_function (Callable) – 
Returns
A loader that will fetch the records from theActor run’s default dataset.
Return type
ApifyDatasetLoader
async acall_actor_task(task_id: str, task_input: Dict, dataset_mapping_function: Callable[[Dict], Document], *, build: Optional[str] = None, memory_mbytes: Optional[int] = None, timeout_secs: Optional[int] = None) → ApifyDatasetLoader[source]¶
Run a saved Actor task on Apify and wait for results to be ready.
:param task_id: The ID or name of the task on the Apify platform.
:type task_id: str
:param task_input: The input object of the task that you’re trying to run.
Overrides the task’s saved input.
Parameters
dataset_mapping_function (Callable) – A function that takes a single
dictionary (an Apify dataset item) and converts it to an
instance of the Document class.
build (str, optional) – Optionally specifies the actor build to run.
It can be either a build tag or build number.
memory_mbytes (int, optional) – Optional memory limit for the run,
in megabytes.
timeout_secs (int, optional) – Optional timeout for the run, in seconds.
task_id (str) – 
task_input (Dict) – 
Returns
A loader that will fetch the records from thetask run’s default dataset.
Return type
ApifyDatasetLoader
call_actor(actor_id: str, run_input: Dict, dataset_mapping_function: Callable[[Dict], Document], *, build: Optional[str] = None, memory_mbytes: Optional[int] = None, timeout_secs: Optional[int] = None) → ApifyDatasetLoader[source]¶
Run an Actor on the Apify platform and wait for results to be ready.
Run an Actor on the Apify platform and wait for results to be ready.
:param actor_id: The ID or name of the Actor on the Apify platform.
:type actor_id: str
:param run_input: The input object of the Actor that you’re trying to run.
:type run_input: Dict
:param dataset_mapping_function: A function that takes a single
dictionary (an Apify dataset item) and converts it to an
instance of the Document class.
Parameters
build (str, optional) – Optionally specifies the actor build to run.
It can be either a build tag or build number.
memory_mbytes (int, optional) – Optional memory limit for the run,
in megabytes.
timeout_secs (int, optional) – Optional timeout for the run, in seconds.
actor_id (str) – 
run_input (Dict) – 
dataset_mapping_function (Callable) – 
Returns
A loader that will fetch the records from theActor run’s default dataset.
Return type
ApifyDatasetLoader
call_actor_task(task_id: str, task_input: Dict, dataset_mapping_function: Callable[[Dict], Document], *, build: Optional[str] = None, memory_mbytes: Optional[int] = None, timeout_secs: Optional[int] = None) → ApifyDatasetLoader[source]¶
Run a saved Actor task on Apify and wait for results to be ready.
:param task_id: The ID or name of the task on the Apify platform.
:type task_id: str
:param task_input: The input object of the task that you’re trying to run.
Overrides the task’s saved input.
Parameters
dataset_mapping_function (Callable) – A function that takes a single
dictionary (an Apify dataset item) and converts it to an
instance of the Document class.
build (str, optional) – Optionally specifies the actor build to run.
build (str, optional) – Optionally specifies the actor build to run.
It can be either a build tag or build number.
memory_mbytes (int, optional) – Optional memory limit for the run,
in megabytes.
timeout_secs (int, optional) – Optional timeout for the run, in seconds.
task_id (str) – 
task_input (Dict) – 
Returns
A loader that will fetch the records from thetask run’s default dataset.
Return type
ApifyDatasetLoader
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
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 ApifyWrapper¶
Apify
langchain_community.utilities.pebblo.Doc¶
class langchain_community.utilities.pebblo.Doc[source]¶
Bases: BaseModel
Pebblo document.
Parameters
name (str) – Name of app originating this document.
owner (str) – Owner of app.
docs (list) – List of documents with its metadata.
plugin_version (str) – Pebblo plugin Version
load_id (str) – Unique load_id of the app instance.
loader_details (dict) – Loader details with its metadata.
loading_end (bool) – Boolean, specifying end of loading of source.
source_owner (str) – Owner of the source of the loader.
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 docs: list [Required]¶
param load_id: str [Required]¶
param loader_details: dict [Required]¶
param loading_end: bool [Required]¶
param name: str [Required]¶
param owner: str [Required]¶
param plugin_version: str [Required]¶
param source_owner: str [Required]¶
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
langchain_community.utilities.bibtex.BibtexparserWrapper¶
class langchain_community.utilities.bibtex.BibtexparserWrapper[source]¶
Bases: BaseModel
Wrapper around bibtexparser.
To use, you should have the bibtexparser python package installed.
https://bibtexparser.readthedocs.io/en/master/
This wrapper will use bibtexparser to load a collection of references from
a bibtex file and fetch document summaries.
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.
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
dict(*, 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) → DictStrAny¶
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
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) – 
Return type
DictStrAny
classmethod from_orm(obj: Any) → Model¶
Parameters
obj (Any) – 
Return type
Model
get_metadata(entry: Mapping[str, Any], load_extra: bool = False) → Dict[str, Any][source]¶
Get metadata for the given entry.
Parameters
entry (Mapping[str, Any]) – 
load_extra (bool) – 
Return type
Dict[str, Any]
load_extra (bool) – 
Return type
Dict[str, Any]
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
load_bibtex_entries(path: str) → List[Dict[str, Any]][source]¶
Load bibtex entries from the bibtex file at the given path.
Parameters
path (str) – 
Return type
List[Dict[str, Any]]
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]) –
langchain_community.utilities.brave_search.BraveSearchWrapper¶
class langchain_community.utilities.brave_search.BraveSearchWrapper[source]¶
Bases: BaseModel
Wrapper around the Brave search engine.
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 api_key: str [Required]¶
The API key to use for the Brave search engine.
param base_url: str = 'https://api.search.brave.com/res/v1/web/search'¶
The base URL for the Brave search engine.
param search_kwargs: dict [Optional]¶
Additional keyword arguments to pass to the search request.
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