Tony20100/langchain_full huggingface dataset:
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
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 ManticoreSearchSettings¶
ManticoreSearch VectorStore
langchain_community.vectorstores.azuresearch.AzureSearchVectorStoreRetriever¶
class langchain_community.vectorstores.azuresearch.AzureSearchVectorStoreRetriever[source]¶
Bases: BaseRetriever
Retriever that uses Azure Cognitive Search.
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 k: int = 4¶
Number of documents to return.
param metadata: Optional[Dict[str, Any]] = None¶
Optional metadata associated with the retriever. Defaults to None
This metadata will be associated with each call to this retriever,
and passed as arguments to the handlers defined in callbacks.
You can use these to eg identify a specific instance of a retriever with its
use case.
param search_kwargs: dict = {}¶
Search params.
score_threshold: Minimum relevance threshold
for similarity_score_threshold
fetch_k: Amount of documents to pass to MMR algorithm (Default: 20)
lambda_mult: Diversity of results returned by MMR;
1 for minimum diversity and 0 for maximum. (Default: 0.5)
filter: Filter by document metadata
param search_type: str = 'hybrid'¶
Type of search to perform. Options are “similarity”, “hybrid”,
“semantic_hybrid”, “similarity_score_threshold”, “hybrid_score_threshold”,
or “semantic_hybrid_score_threshold”.
param tags: Optional[List[str]] = None¶
Optional list of tags associated with the retriever. Defaults to None
These tags will be associated with each call to this retriever,
and passed as arguments to the handlers defined in callbacks.
You can use these to eg identify a specific instance of a retriever with its
use case.
param vectorstore: AzureSearch [Required]¶
use case.
param vectorstore: AzureSearch [Required]¶
Azure Search instance used to find similar documents.
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 aget_relevant_documents(query: str, *, callbacks: Callbacks = None, tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None, run_name: Optional[str] = None, **kwargs: Any) → List[Document]¶
[Deprecated] Asynchronously get documents relevant to a query.
[Deprecated] Asynchronously get documents relevant to a query.
Users should favor using .ainvoke or .abatch rather than
aget_relevant_documents directly.
Parameters
query (str) – string to find relevant documents for
callbacks (Callbacks) – Callback manager or list of callbacks
tags (Optional[List[str]]) – Optional list of tags associated with the retriever. Defaults to None
These tags will be associated with each call to this retriever,
and passed as arguments to the handlers defined in callbacks.
metadata (Optional[Dict[str, Any]]) – Optional metadata associated with the retriever. Defaults to None
This metadata will be associated with each call to this retriever,
and passed as arguments to the handlers defined in callbacks.
run_name (Optional[str]) – Optional name for the run.
kwargs (Any) – 
Returns
List of relevant documents
Return type
List[Document]
Notes
Deprecated since version langchain-core==0.1.46: Use ainvoke instead.
async ainvoke(input: str, config: Optional[RunnableConfig] = None, **kwargs: Any) → List[Document]¶
Asynchronously invoke the retriever to get relevant documents.
Main entry point for asynchronous retriever invocations.
Parameters
input (str) – The query string
config (Optional[RunnableConfig]) – Configuration for the retriever
**kwargs (Any) – Additional arguments to pass to the retriever
Returns
List of relevant documents
Return type
List[Document]
Examples:
await retriever.ainvoke("query")
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]¶
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.
allowed_search_types: ClassVar[Collection[str]] = ('similarity', 'similarity_score_threshold', 'hybrid', 'hybrid_score_threshold', 'semantic_hybrid', 'semantic_hybrid_score_threshold')¶
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: Optional[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.
langchain_community.vectorstores.redis.schema.FlatVectorField¶
class langchain_community.vectorstores.redis.schema.FlatVectorField[source]¶
Bases: RedisVectorField
Schema for flat vector fields in Redis.
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 algorithm: Literal['FLAT'] = 'FLAT'¶
param block_size: Optional[int] = None¶
param datatype: str = 'FLOAT32'¶
param dims: int [Required]¶
param distance_metric: RedisDistanceMetric = 'COSINE'¶
param initial_cap: Optional[int] = None¶
param name: str [Required]¶
as_field() → VectorField[source]¶
Return type
VectorField
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
asimilarity_search(query[, k])
Return docs most similar to query.
asimilarity_search_by_vector(embedding[, k])
Return docs most similar to embedding vector.
asimilarity_search_with_relevance_scores(query)
Return docs and relevance scores in the range [0, 1].
asimilarity_search_with_score(*args, **kwargs)
Run similarity search with distance.
create_inverse_metadata(fields)
Create metadata from fields.
create_results(json_result)
Assemble documents.
create_results_with_score(json_result)
Parsing the returned results with scores.
delete([ids])
Delete by vector ID or other criteria.
delete_documents_with_document_id(id_list)
Delete documents based on their IDs.
delete_documents_with_texts(texts)
Delete documents based on their page content.
from_documents(documents, embedding[, config])
Create alibaba cloud opensearch vector store instance.
from_texts(texts, embedding[, metadatas, config])
Create alibaba cloud opensearch vector store instance.
inner_embedding_query(embedding[, ...])
max_marginal_relevance_search(query[, k, ...])
Return docs selected using the maximal marginal relevance.
max_marginal_relevance_search_by_vector(...)
Return docs selected using the maximal marginal relevance.
search(query, search_type, **kwargs)
Return docs most similar to query using specified search type.
similarity_search(query[, k, search_filter])
Perform similarity retrieval based on text.
similarity_search_by_vector(embedding[, k, ...])
Perform retrieval directly using vectors.
similarity_search_with_relevance_scores(query)
Perform similarity retrieval based on text with scores.
similarity_search_with_score(*args, **kwargs)
Run similarity search with distance.
Parameters
Run similarity search with distance.
Parameters
embedding (Embeddings) – 
config (AlibabaCloudOpenSearchSettings) – 
kwargs (Any) – 
__init__(embedding: Embeddings, config: AlibabaCloudOpenSearchSettings, **kwargs: Any) → None[source]¶
Parameters
embedding (Embeddings) – 
config (AlibabaCloudOpenSearchSettings) – 
kwargs (Any) – 
Return type
None
async aadd_documents(documents: List[Document], **kwargs: Any) → List[str]¶
Run more documents through the embeddings and add to the vectorstore.
Parameters
documents (List[Document]) – Documents to add to the vectorstore.
kwargs (Any) – 
Returns
List of IDs of the added texts.
Return type
List[str]
async aadd_texts(texts: Iterable[str], metadatas: Optional[List[dict]] = None, **kwargs: Any) → List[str]¶
Run more texts through the embeddings and add to the vectorstore.
Parameters
texts (Iterable[str]) – Iterable of strings to add to the vectorstore.
metadatas (Optional[List[dict]]) – Optional list of metadatas associated with the texts.
**kwargs (Any) – vectorstore specific parameters.
Returns
List of ids from adding the texts into the vectorstore.
Return type
List[str]
add_documents(documents: List[Document], **kwargs: Any) → List[str]¶
Run more documents through the embeddings and add to the vectorstore.
Parameters
documents (List[Document]) – Documents to add to the vectorstore.
kwargs (Any) – 
Returns
List of IDs of the added texts.
Return type
List[str]
Returns
List of IDs of the added texts.
Return type
List[str]
add_texts(texts: Iterable[str], metadatas: Optional[List[dict]] = None, **kwargs: Any) → List[str][source]¶
Insert documents into the instance..
:param texts: The text segments to be inserted into the vector storage,
should not be empty.
Parameters
metadatas (Optional[List[dict]]) – Metadata information.
texts (Iterable[str]) – 
kwargs (Any) – 
Returns
List of document IDs.
Return type
id_list
async adelete(ids: Optional[List[str]] = None, **kwargs: Any) → Optional[bool]¶
Delete by vector ID or other criteria.
Parameters
ids (Optional[List[str]]) – List of ids to delete.
**kwargs (Any) – Other keyword arguments that subclasses might use.
Returns
True if deletion is successful,
False otherwise, None if not implemented.
Return type
Optional[bool]
async classmethod afrom_documents(documents: List[Document], embedding: Embeddings, **kwargs: Any) → VST¶
Return VectorStore initialized from documents and embeddings.
Parameters
documents (List[Document]) – List of Documents to add to the vectorstore.
embedding (Embeddings) – Embedding function to use.
kwargs (Any) – 
Return type
VST
async classmethod afrom_texts(texts: List[str], embedding: Embeddings, metadatas: Optional[List[dict]] = None, **kwargs: Any) → VST¶
Return VectorStore initialized from texts and embeddings.
Parameters
texts (List[str]) – Texts to add to the vectorstore.
metadatas (Optional[List[dict]]) – Optional list of metadatas associated with the texts.
embedding (Embeddings) – Embedding function to use.
kwargs (Any) – 
Returns
List of Documents most similar to the query vector.
Return type
List[Document]
async asimilarity_search_with_relevance_scores(query: str, k: int = 4, **kwargs: Any) → List[Tuple[Document, float]]¶
Return docs and relevance scores in the range [0, 1].
0 is dissimilar, 1 is most similar.
Parameters
query (str) – Input text.
k (int) – Number of Documents to return. Defaults to 4.
**kwargs (Any) – kwargs to be passed to similarity search. Should include:
score_threshold: Optional, a floating point value between 0 to 1 to
filter the resulting set of retrieved docs
Returns
List of Tuples of (doc, similarity_score)
Return type
List[Tuple[Document, float]]
async asimilarity_search_with_score(*args: Any, **kwargs: Any) → List[Tuple[Document, float]]¶
Run similarity search with distance.
Returns
List of Tuples of (doc, similarity_score)
Parameters
args (Any) – 
kwargs (Any) – 
Return type
List[Tuple[Document, float]]
create_inverse_metadata(fields: Dict[str, Any]) → Dict[str, Any][source]¶
Create metadata from fields.
Parameters
fields (Dict[str, Any]) – The fields of the document. The fields must be a dict.
Returns
The metadata of the document. The metadata must be a dict.
Return type
metadata
create_results(json_result: Dict[str, Any]) → List[Document][source]¶
Assemble documents.
Parameters
json_result (Dict[str, Any]) – 
Return type
List[Document]
json_result (Dict[str, Any]) – 
Return type
List[Document]
create_results_with_score(json_result: Dict[str, Any]) → List[Tuple[Document, float]][source]¶
Parsing the returned results with scores.
:param json_result: Results from OpenSearch query.
Returns
Results with scores.
Return type
query_result_list
Parameters
json_result (Dict[str, Any]) – 
delete(ids: Optional[List[str]] = None, **kwargs: Any) → Optional[bool]¶
Delete by vector ID or other criteria.
Parameters
ids (Optional[List[str]]) – List of ids to delete.
**kwargs (Any) – Other keyword arguments that subclasses might use.
Returns
True if deletion is successful,
False otherwise, None if not implemented.
Return type
Optional[bool]
delete_documents_with_document_id(id_list: List[str]) → bool[source]¶
Delete documents based on their IDs.
Parameters
id_list (List[str]) – List of document IDs.
Returns
Whether the deletion was successful or not.
Return type
bool
delete_documents_with_texts(texts: List[str]) → bool[source]¶
Delete documents based on their page content.
Parameters
texts (List[str]) – List of document page content.
Returns
Whether the deletion was successful or not.
Return type
bool
classmethod from_documents(documents: List[Document], embedding: Embeddings, config: Optional[AlibabaCloudOpenSearchSettings] = None, **kwargs: Any) → AlibabaCloudOpenSearch[source]¶
Create alibaba cloud opensearch vector store instance.
Parameters
documents (List[Document]) – Documents to be inserted into the vector storage,
should not be empty.
embedding (Embeddings) – Embedding function, Embedding function.
embedding (Embeddings) – Embedding function, Embedding function.
config (Optional[AlibabaCloudOpenSearchSettings]) – Alibaba OpenSearch instance configuration.
ids – Specify the ID for the inserted document. If left empty, the ID will be
automatically generated based on the text content.
kwargs (Any) – 
Returns
Alibaba cloud opensearch vector store instance.
Return type
AlibabaCloudOpenSearch
classmethod from_texts(texts: List[str], embedding: Embeddings, metadatas: Optional[List[dict]] = None, config: Optional[AlibabaCloudOpenSearchSettings] = None, **kwargs: Any) → AlibabaCloudOpenSearch[source]¶
Create alibaba cloud opensearch vector store instance.
Parameters
texts (List[str]) – The text segments to be inserted into the vector storage,
should not be empty.
embedding (Embeddings) – Embedding function, Embedding function.
config (Optional[AlibabaCloudOpenSearchSettings]) – Alibaba OpenSearch instance configuration.
metadatas (Optional[List[dict]]) – Metadata information.
kwargs (Any) – 
Returns
Alibaba cloud opensearch vector store instance.
Return type
AlibabaCloudOpenSearch
inner_embedding_query(embedding: List[float], search_filter: Optional[Dict[str, Any]] = None, k: int = 4) → Dict[str, Any][source]¶
Parameters
embedding (List[float]) – 
search_filter (Optional[Dict[str, Any]]) – 
k (int) – 
Return type
Dict[str, Any]
max_marginal_relevance_search(query: str, k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, **kwargs: Any) → List[Document]¶
Return docs selected using the maximal marginal relevance.
Return docs selected using the maximal marginal relevance.
Maximal marginal relevance optimizes for similarity to query AND diversity
among selected documents.
Parameters
query (str) – Text to look up documents similar to.
k (int) – Number of Documents to return. Defaults to 4.
fetch_k (int) – Number of Documents to fetch to pass to MMR algorithm.
lambda_mult (float) – Number between 0 and 1 that determines the degree
of diversity among the results with 0 corresponding
to maximum diversity and 1 to minimum diversity.
Defaults to 0.5.
kwargs (Any) – 
Returns
List of Documents selected by maximal marginal relevance.
Return type
List[Document]
max_marginal_relevance_search_by_vector(embedding: List[float], k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, **kwargs: Any) → List[Document]¶
Return docs selected using the maximal marginal relevance.
Maximal marginal relevance optimizes for similarity to query AND diversity
among selected documents.
Parameters
embedding (List[float]) – Embedding to look up documents similar to.
k (int) – Number of Documents to return. Defaults to 4.
fetch_k (int) – Number of Documents to fetch to pass to MMR algorithm.
lambda_mult (float) – Number between 0 and 1 that determines the degree
of diversity among the results with 0 corresponding
to maximum diversity and 1 to minimum diversity.
Defaults to 0.5.
kwargs (Any) – 
Returns
List of Documents selected by maximal marginal relevance.
Return type
List[Document]
search(query: str, search_type: str, **kwargs: Any) → List[Document]¶
Return docs most similar to query using specified search type.
Parameters
Return docs most similar to query using specified search type.
Parameters
query (str) – Input text
search_type (str) – Type of search to perform. Can be “similarity”,
“mmr”, or “similarity_score_threshold”.
**kwargs (Any) – Arguments to pass to the search method.
Return type
List[Document]
similarity_search(query: str, k: int = 4, search_filter: Optional[Dict[str, Any]] = None, **kwargs: Any) → List[Document][source]¶
Perform similarity retrieval based on text.
:param query: Vectorize text for retrieval.，should not be empty.
:param k: top n.
:param search_filter: Additional filtering conditions.
Returns
List of documents.
Return type
document_list
Parameters
query (str) – 
k (int) – 
search_filter (Optional[Dict[str, Any]]) – 
kwargs (Any) – 
similarity_search_by_vector(embedding: List[float], k: int = 4, search_filter: Optional[dict] = None, **kwargs: Any) → List[Document][source]¶
Perform retrieval directly using vectors.
:param embedding: vectors.
:param k: top n.
:param search_filter: Additional filtering conditions.
Returns
List of documents.
Return type
document_list
Parameters
embedding (List[float]) – 
k (int) – 
search_filter (Optional[dict]) – 
kwargs (Any) – 
similarity_search_with_relevance_scores(query: str, k: int = 4, search_filter: Optional[dict] = None, **kwargs: Any) → List[Tuple[Document, float]][source]¶
Perform similarity retrieval based on text with scores.
:param query: Vectorize text for retrieval.，should not be empty.
:param query: Vectorize text for retrieval.，should not be empty.
:param k: top n.
:param search_filter: Additional filtering conditions.
Returns
List of documents.
Return type
document_list
Parameters
query (str) – 
k (int) – 
search_filter (Optional[dict]) – 
kwargs (Any) – 
similarity_search_with_score(*args: Any, **kwargs: Any) → List[Tuple[Document, float]]¶
Run similarity search with distance.
Returns
List of Tuples of (doc, similarity_score)
Parameters
args (Any) – 
kwargs (Any) – 
Return type
List[Tuple[Document, float]]
Examples using AlibabaCloudOpenSearch¶
Alibaba Cloud
Alibaba Cloud OpenSearch
langchain_community.vectorstores.redis.filters.RedisFilterOperator¶
class langchain_community.vectorstores.redis.filters.RedisFilterOperator(value)[source]¶
RedisFilterOperator enumerator is used to create RedisFilterExpressions.
EQ = 1¶
NE = 2¶
LT = 3¶
GT = 4¶
LE = 5¶
GE = 6¶
OR = 7¶
AND = 8¶
LIKE = 9¶
IN = 10¶
langchain_community.vectorstores.vdms.VDMS¶
class langchain_community.vectorstores.vdms.VDMS(client: vdms.vdms, *, embedding: Optional[Embeddings] = None, collection_name: str = 'langchain', distance_strategy: DISTANCE_METRICS = 'L2', engine: ENGINES = 'FaissFlat', relevance_score_fn: Optional[Callable[[float], float]] = None)[source]¶
Intel Lab’s VDMS for vector-store workloads.
To use, you should have both:
- the vdms python package installed
- a host (str) and port (int) associated with a deployed VDMS Server
Visit https://github.com/IntelLabs/vdms/wiki more information.
IT IS HIGHLY SUGGESTED TO NORMALIZE YOUR DATA.
Parameters
client (vdms.vdms) – VDMS Client used to connect to VDMS server
collection_name (str) – Name of data collection [Default: langchain]
distance_strategy (DISTANCE_METRICS) – Method used to calculate distances. VDMS supports
“L2” (euclidean distance) or “IP” (inner product) [Default: L2]
engine (ENGINES) – Underlying implementation for indexing and computing distances.
VDMS supports TileDBDense, TileDBSparse, FaissFlat, FaissIVFFlat,
and Flinng [Default: FaissFlat]
embedding (Optional[Embeddings]) – Any embedding function implementing
langchain_core.embeddings.Embeddings interface.
relevance_score_fn (Optional[Callable[[float], float]]) – Function for obtaining relevance score
Example
from langchain_community.embeddings import HuggingFaceEmbeddings
from langchain_community.vectorstores.vdms import VDMS, VDMS_Client
vectorstore = VDMS(