id
stringlengths
14
16
text
stringlengths
29
2.73k
source
stringlengths
49
117
5641e0c3fcb0-4
text_embedding_pairs = list(zip(texts, text_embeddings)) db = Annoy.from_embeddings(text_embedding_pairs, embeddings) classmethod from_texts(texts: List[str], embedding: langchain.embeddings.base.Embeddings, metadatas: Optional[List[dict]] = None, metric: str = 'angular', trees: int = 100, n_jobs: int = - 1, **kwargs: ...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-5
embeddings – Embeddings to use when generating queries. max_marginal_relevance_search(query: str, k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, **kwargs: Any) β†’ List[langchain.schema.Document][source]# Return docs selected using the maximal marginal relevance. Maximal marginal relevance optimizes for similar...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-6
Defaults to 0.5. Returns List of Documents selected by maximal marginal relevance. process_index_results(idxs: List[int], dists: List[float]) β†’ List[Tuple[langchain.schema.Document, float]][source]# Turns annoy results into a list of documents and scores. Parameters idxs – List of indices of the documents in the index....
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-7
to n_trees * n if not provided Returns List of Documents most similar to the embedding. similarity_search_by_vector(embedding: List[float], k: int = 4, search_k: int = - 1, **kwargs: Any) β†’ List[langchain.schema.Document][source]# Return docs most similar to embedding vector. Parameters embedding – Embedding to look up...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-8
Returns List of Documents most similar to the query and score for each similarity_search_with_score_by_vector(embedding: List[float], k: int = 4, search_k: int = - 1) β†’ List[Tuple[langchain.schema.Document, float]][source]# Return docs most similar to query. Parameters query – Text to look up documents similar to. k – ...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-9
ids (Optional[List[str]]) – An optional list of ids. refresh (bool) – Whether or not to refresh indices with the updated data. Default True. Returns List of IDs of the added texts. Return type List[str] create_index(**kwargs: Any) β†’ Any[source]# Creates an index in your project. See https://docs.nomic.ai/atlas_api.html...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-10
index_kwargs (Optional[dict]) – Dict of kwargs for index creation. See https://docs.nomic.ai/atlas_api.html Returns Nomic’s neural database and finest rhizomatic instrument Return type AtlasDB classmethod from_texts(texts: List[str], embedding: Optional[langchain.embeddings.base.Embeddings] = None, metadatas: Optional[...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-11
Returns Nomic’s neural database and finest rhizomatic instrument Return type AtlasDB similarity_search(query: str, k: int = 4, **kwargs: Any) β†’ List[langchain.schema.Document][source]# Run similarity search with AtlasDB Parameters query (str) – Query text to search for. k (int) – Number of results to return. Defaults t...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-12
List[str] delete_collection() β†’ None[source]# Delete the collection. classmethod from_documents(documents: List[Document], embedding: Optional[Embeddings] = None, ids: Optional[List[str]] = None, collection_name: str = 'langchain', persist_directory: Optional[str] = None, client_settings: Optional[chromadb.config.Setti...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-13
Otherwise, the data will be ephemeral in-memory. Parameters texts (List[str]) – List of texts to add to the collection. collection_name (str) – Name of the collection to create. persist_directory (Optional[str]) – Directory to persist the collection. embedding (Optional[Embeddings]) – Embedding function. Defaults to No...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-14
Returns List of Documents selected by maximal marginal relevance. max_marginal_relevance_search_by_vector(embedding: List[float], k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, filter: Optional[Dict[str, str]] = None, **kwargs: Any) β†’ List[langchain.schema.Document][source]# Return docs selected using the max...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-15
List of documents most similar to the query text. Return type List[Document] similarity_search_by_vector(embedding: List[float], k: int = 4, filter: Optional[Dict[str, str]] = None, **kwargs: Any) β†’ List[langchain.schema.Document][source]# Return docs most similar to embedding vector. :param embedding: Embedding to loo...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-16
document (Document) – Document to update. class langchain.vectorstores.DeepLake(dataset_path: str = './deeplake/', token: Optional[str] = None, embedding_function: Optional[langchain.embeddings.base.Embeddings] = None, read_only: Optional[bool] = False, ingestion_batch_size: int = 1024, num_workers: int = 0, verbose: b...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-17
Returns List of IDs of the added texts. Return type List[str] delete(ids: Any[List[str], None] = None, filter: Any[Dict[str, str], None] = None, delete_all: Any[bool, None] = None) β†’ bool[source]# Delete the entities in the dataset Parameters ids (Optional[List[str]], optional) – The document_ids to delete. Defaults to...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-18
Google Cloud Storage path of the formgcs://bucketname/path/to/dataset Credentials are required in either the environment Local file system path of the form ./path/to/dataset or~/path/to/dataset or path/to/dataset. In-memory path of the form mem://path/to/dataset which doesn’tsave the dataset, but keeps it in memory ins...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-19
Defaults to 0.5. Returns List of Documents selected by maximal marginal relevance. max_marginal_relevance_search_by_vector(embedding: List[float], k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, **kwargs: Any) β†’ List[langchain.schema.Document][source]# Return docs selected using the maximal marginal relevance....
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-20
Defaults to None. maximal_marginal_relevance – Whether to use maximal marginal relevance. Defaults to False. fetch_k – Number of Documents to fetch to pass to MMR algorithm. Defaults to 20. return_score – Whether to return the score. Defaults to False. Returns List of Documents most similar to the query vector. similar...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-21
Wrapper around HnswLib storage. To use it, you should have the docarray package with version >=0.32.0 installed. You can install it with pip install β€œlangchain[docarray]”. classmethod from_params(embedding: langchain.embeddings.base.Embeddings, work_dir: str, n_dim: int, dist_metric: Literal['cosine', 'ip', 'l2'] = 'co...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-22
with new added ones. Defaults to True. num_threads (int) – Sets the number of cpu threads to use. Defaults to 1. **kwargs – Other keyword arguments to be passed to the get_doc_cls method. classmethod from_texts(texts: List[str], embedding: langchain.embeddings.base.Embeddings, metadatas: Optional[List[dict]] = None, wo...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-23
Initialize DocArrayInMemorySearch store. Parameters embedding (Embeddings) – Embedding function. metric (str) – metric for exact nearest-neighbor search. Can be one of: β€œcosine_sim”, β€œeuclidean_dist” and β€œsqeuclidean_dist”. Defaults to β€œcosine_sim”. **kwargs – Other keyword arguments to be passed to the get_doc_cls met...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-24
embedding = OpenAIEmbeddings() elastic_vector_search = ElasticVectorSearch( elasticsearch_url="http://localhost:9200", index_name="test_index", embedding=embedding ) To connect to an Elasticsearch instance that requires login credentials, including Elastic Cloud, use the Elasticsearch URL format https://use...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-25
index_name (str) – The name of the Elasticsearch index for the embeddings. embedding (Embeddings) – An object that provides the ability to embed text. It should be an instance of a class that subclasses the Embeddings abstract base class, such as OpenAIEmbeddings() Raises ValueError – If the elasticsearch python packag...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-26
from langchain import ElasticVectorSearch from langchain.embeddings import OpenAIEmbeddings embeddings = OpenAIEmbeddings() elastic_vector_search = ElasticVectorSearch.from_texts( texts, embeddings, elasticsearch_url="http://localhost:9200" ) similarity_search(query: str, k: int = 4, filter: Optional[dict] ...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-27
add_embeddings(text_embeddings: Iterable[Tuple[str, List[float]]], metadatas: Optional[List[dict]] = None, ids: Optional[List[str]] = None, **kwargs: Any) β†’ List[str][source]# Run more texts through the embeddings and add to the vectorstore. Parameters text_embeddings – Iterable pairs of string and embedding to add to ...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-28
text_embedding_pairs = list(zip(texts, text_embeddings)) faiss = FAISS.from_embeddings(text_embedding_pairs, embeddings) classmethod from_texts(texts: List[str], embedding: langchain.embeddings.base.Embeddings, metadatas: Optional[List[dict]] = None, ids: Optional[List[str]] = None, **kwargs: Any) β†’ langchain.vectorsto...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-29
k – Number of Documents to return. Defaults to 4. fetch_k – Number of Documents to fetch to pass to MMR algorithm. lambda_mult – 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. Returns List of Documen...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-30
and index_to_docstore_id to. index_name – for saving with a specific index file name similarity_search(query: str, k: int = 4, **kwargs: Any) β†’ List[langchain.schema.Document][source]# Return docs most similar to query. Parameters query – Text to look up documents similar to. k – Number of Documents to return. Defaults...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-31
Returns List of Documents most similar to the query and score for each class langchain.vectorstores.LanceDB(connection: Any, embedding: langchain.embeddings.base.Embeddings, vector_key: Optional[str] = 'vector', id_key: Optional[str] = 'id', text_key: Optional[str] = 'text')[source]# Wrapper around LanceDB vector datab...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-32
Return documents most similar to the query Parameters query – String to query the vectorstore with. k – Number of documents to return. Returns List of documents most similar to the query. class langchain.vectorstores.Milvus(embedding_function: langchain.embeddings.base.Embeddings, collection_name: str = 'LangChainColle...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-33
Returns The resulting keys for each inserted element. Return type List[str] classmethod from_texts(texts: List[str], embedding: langchain.embeddings.base.Embeddings, metadatas: Optional[List[dict]] = None, collection_name: str = 'LangChainCollection', connection_args: dict[str, Any] = {'host': 'localhost', 'password': ...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-34
Returns Milvus Vector Store Return type Milvus max_marginal_relevance_search(query: str, k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, param: Optional[dict] = None, expr: Optional[str] = None, timeout: Optional[int] = None, **kwargs: Any) β†’ List[langchain.schema.Document][source]# Perform a search and return...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-35
Parameters embedding (str) – The embedding vector being searched. k (int, optional) – How many results to give. Defaults to 4. fetch_k (int, optional) – Total results to select k from. Defaults to 20. lambda_mult – Number between 0 and 1 that determines the degree of diversity among the results with 0 corresponding to ...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-36
Returns Document results for search. Return type List[Document] similarity_search_by_vector(embedding: List[float], k: int = 4, param: Optional[dict] = None, expr: Optional[str] = None, timeout: Optional[int] = None, **kwargs: Any) β†’ List[langchain.schema.Document][source]# Perform a similarity search against the query...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-37
Defaults to None. expr (str, optional) – Filtering expression. Defaults to None. timeout (int, optional) – How long to wait before timeout error. Defaults to None. kwargs – Collection.search() keyword arguments. Return type List[float], List[Tuple[Document, any, any]] similarity_search_with_score_by_vector(embedding: L...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-38
To use, you should have both: - the pymongo python package installed - a connection string associated with a MongoDB Atlas Cluster having deployed an Atlas Search index Example from langchain.vectorstores import MongoDBAtlasVectorSearch from langchain.embeddings.openai import OpenAIEmbeddings from pymongo import MongoC...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-39
This is intended to be a quick way to get started. Example similarity_search(query: str, k: int = 4, pre_filter: Optional[dict] = None, post_filter_pipeline: Optional[List[Dict]] = None, **kwargs: Any) β†’ List[langchain.schema.Document][source]# Return MongoDB documents most similar to query. Use the knnBeta Operator av...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-40
Parameters query – Text to look up documents similar to. k – Optional Number of Documents to return. Defaults to 4. pre_filter – Optional Dictionary of argument(s) to prefilter on document fields. post_filter_pipeline – Optional Pipeline of MongoDB aggregation stages following the knnBeta search. Returns List of Docume...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-41
Helper function: Drop data escape_str(value: str) β†’ str[source]# classmethod from_texts(texts: List[str], embedding: langchain.embeddings.base.Embeddings, metadatas: Optional[List[Dict[Any, Any]]] = None, config: Optional[langchain.vectorstores.myscale.MyScaleSettings] = None, text_ids: Optional[Iterable[str]] = None, ...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-42
of SQL injection. When dealing with metadatas, remember to use {self.metadata_column}.attribute instead of attribute alone. The default name for it is metadata. Returns List of Documents Return type List[Document] similarity_search_by_vector(embedding: List[float], k: int = 4, where_str: Optional[str] = None, **kwargs:...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-43
Returns List of documents Return type List[Document] pydantic settings langchain.vectorstores.MyScaleSettings[source]# MyScale Client Configuration Attribute: myscale_host (str)An URL to connect to MyScale backend.Defaults to β€˜localhost’. myscale_port (int) : URL port to connect with HTTP. Defaults to 8443. username (s...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-44
Show JSON schema{ "title": "MyScaleSettings", "description": "MyScale Client Configuration\n\nAttribute:\n myscale_host (str) : An URL to connect to MyScale backend.\n Defaults to 'localhost'.\n myscale_port (int) : URL port to connect with HTTP. Defaults to 8443.\n username (str)...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-45
}, "port": { "title": "Port", "default": 8443, "env_names": "{'myscale_port'}", "type": "integer" }, "username": { "title": "Username", "env_names": "{'myscale_username'}", "type": "string" }, "password": { "title": "P...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-46
}, "table": { "title": "Table", "default": "langchain", "env_names": "{'myscale_table'}", "type": "string" }, "metric": { "title": "Metric", "default": "cosine", "env_names": "{'myscale_metric'}", "type": "string" } }, ...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-47
Example from langchain import OpenSearchVectorSearch opensearch_vector_search = OpenSearchVectorSearch( "http://localhost:9200", "embeddings", embedding_function ) add_texts(texts: Iterable[str], metadatas: Optional[List[dict]] = None, bulk_size: int = 500, **kwargs: Any) β†’ List[str][source]# Run more texts...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-48
search through Script Scoring and Painless Scripting. Optional Args:vector_field: Document field embeddings are stored in. Defaults to β€œvector_field”. text_field: Document field the text of the document is stored in. Defaults to β€œtext”. Optional Keyword Args for Approximate Search:engine: β€œnmslib”, β€œfaiss”, β€œlucene”; d...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-49
metadata_field: Document field that metadata is stored in. Defaults to β€œmetadata”. Can be set to a special value β€œ*” to include the entire document. Optional Args for Approximate Search:search_type: β€œapproximate_search”; default: β€œapproximate_search” boolean_filter: A Boolean filter consists of a Boolean query that con...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-50
k – Number of Documents to return. Defaults to 4. Returns List of Documents along with its scores most similar to the query. Optional Args:same as similarity_search class langchain.vectorstores.Pinecone(index: Any, embedding_function: Callable, text_key: str, namespace: Optional[str] = None)[source]# Wrapper around Pin...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-51
Load pinecone vectorstore from index name. classmethod from_texts(texts: List[str], embedding: langchain.embeddings.base.Embeddings, metadatas: Optional[List[dict]] = None, ids: Optional[List[str]] = None, batch_size: int = 32, text_key: str = 'text', index_name: Optional[str] = None, namespace: Optional[str] = None, *...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-52
Returns List of Documents most similar to the query and score for each similarity_search_with_score(query: str, k: int = 4, filter: Optional[dict] = None, namespace: Optional[str] = None) β†’ List[Tuple[langchain.schema.Document, float]][source]# Return pinecone documents most similar to query, along with scores. Paramet...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-53
metadatas – Optional list of metadatas associated with the texts. Returns List of ids from adding the texts into the vectorstore. classmethod from_texts(texts: List[str], embedding: langchain.embeddings.base.Embeddings, metadatas: Optional[List[dict]] = None, location: Optional[str] = None, url: Optional[str] = None, p...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-54
grpc_port – Port of the gRPC interface. Default: 6334 prefer_grpc – If true - use gPRC interface whenever possible in custom methods. Default: False https – If true - use HTTPS(SSL) protocol. Default: None api_key – API key for authentication in Qdrant Cloud. Default: None prefix – If not None - add prefix to the REST ...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-55
Example from langchain import Qdrant from langchain.embeddings import OpenAIEmbeddings embeddings = OpenAIEmbeddings() qdrant = Qdrant.from_texts(texts, embeddings, "localhost") max_marginal_relevance_search(query: str, k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, **kwargs: Any) β†’ List[langchain.schema.Docu...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-56
Parameters query – Text to look up documents similar to. k – Number of Documents to return. Defaults to 4. filter – Filter by metadata. Defaults to None. Returns List of Documents most similar to the query and score for each. class langchain.vectorstores.Redis(redis_url: str, index_name: str, embedding_function: typing...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-57
Defaults to None. batch_size (int, optional) – Batch size to use for writes. Defaults to 1000. Returns List of ids added to the vectorstore Return type List[str] as_retriever(**kwargs: Any) β†’ langchain.vectorstores.redis.RedisVectorStoreRetriever[source]# static drop_index(index_name: str, delete_documents: bool, **kwa...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-58
This is intended to be a quick way to get started. .. rubric:: Example classmethod from_texts_return_keys(texts: List[str], embedding: langchain.embeddings.base.Embeddings, metadatas: Optional[List[dict]] = None, index_name: Optional[str] = None, content_key: str = 'content', metadata_key: str = 'metadata', vector_key:...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-59
k (int) – The number of documents to return. Default is 4. score_threshold (float) – The minimum matching score required for a document 0.2. (to be considered a match. Defaults to) – similarity (Because the similarity calculation algorithm is based on cosine) – :param : :param the smaller the angle: :param the higher...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-60
kwargs – vectorstore specific parameters Returns List of ids from adding the texts into the vectorstore. classmethod from_texts(texts: List[str], embedding: langchain.embeddings.base.Embeddings, metadatas: Optional[List[dict]] = None, ids: Optional[List[str]] = None, persist_path: Optional[str] = None, **kwargs: Any) β†’...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-61
:param k: Number of Documents to return. Defaults to 4. :param fetch_k: Number of Documents to fetch to pass to MMR algorithm. :param lambda_mult: 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. Retur...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-62
Run more texts through the embeddings and add to the vectorstore. Parameters texts – Iterable of strings to add to the vectorstore. metadatas – Optional list of metadatas associated with the texts. kwargs – vectorstore specific parameters Returns List of ids from adding the texts into the vectorstore. add_vectors(vecto...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-63
demonstrates how to do this: ```sql CREATE FUNCTION match_documents_embeddings(query_embedding vector(1536), match_count int) RETURNS TABLE(id bigint, content text, metadata jsonb, embedding vector(1536), similarity float) LANGUAGE plpgsql AS $$ # variable_conflict use_column BEGINRETURN query SELECT id, content, metad...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-64
Return docs most similar to embedding vector. Parameters embedding – Embedding to look up documents similar to. k – Number of Documents to return. Defaults to 4. Returns List of Documents most similar to the query vector. similarity_search_by_vector_returning_embeddings(query: List[float], k: int) β†’ List[Tuple[langchai...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-65
Add texts data to an existing index. create_index_if_not_exist(dim: int, distance_type: str, index_type: str, data_type: str, **kwargs: Any) β†’ bool[source]# static drop_index(index_name: str = 'langchain', **kwargs: Any) β†’ bool[source]# Drop an existing index. Parameters index_name (str) – Name of the index to drop. Re...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-66
Returns the most similar indexed documents to the query text. Parameters query (str) – The query text for which to find similar documents. k (int) – The number of documents to return. Default is 4. Returns A list of documents that are most similar to the query text. Return type List[Document] class langchain.vectorstor...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-67
Parameters texts – Iterable of strings to add to the vectorstore. metadatas – Optional list of metadatas associated with the texts. ids – Optional list of ids to associate with the texts. Returns List of ids from adding the texts into the vectorstore. classmethod from_client_params(embedding: langchain.embeddings.base....
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-68
Parameters query – Text to look up documents similar to. k – Number of Documents to return. Defaults to 4. filter – typesense filter_by expression to filter documents on Returns List of Documents most similar to the query and score for each similarity_search_with_score(query: str, k: int = 4, filter: Optional[str] = ''...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-69
Returns List of ids from adding the texts into the vectorstore. as_retriever(**kwargs: Any) β†’ langchain.vectorstores.vectara.VectaraRetriever[source]# classmethod from_texts(texts: List[str], embedding: Optional[langchain.embeddings.base.Embeddings] = None, metadatas: Optional[List[dict]] = None, **kwargs: Any) β†’ langc...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-70
Return Vectara documents most similar to query, along with scores. Parameters query – Text to look up documents similar to. k – Number of Documents to return. Defaults to 5. alpha – parameter for hybrid search (called β€œlambda” in Vectara documentation). filter – Dictionary of argument(s) to filter on metadata. For exam...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-71
Run more texts through the embeddings and add to the vectorstore. Parameters texts – Iterable of strings to add to the vectorstore. metadatas – Optional list of metadatas associated with the texts. kwargs – vectorstore specific parameters Returns List of ids from adding the texts into the vectorstore. async classmethod...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-72
Return docs most similar to query using specified search type. async asimilarity_search(query: str, k: int = 4, **kwargs: Any) β†’ List[langchain.schema.Document][source]# Return docs most similar to query. async asimilarity_search_by_vector(embedding: List[float], k: int = 4, **kwargs: Any) β†’ List[langchain.schema.Docum...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-73
lambda_mult – 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. Returns List of Documents selected by maximal marginal relevance. max_marginal_relevance_search_by_vector(embedding: List[float], k: int =...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-74
k – Number of Documents to return. Defaults to 4. Returns List of Documents most similar to the query vector. similarity_search_with_relevance_scores(query: str, k: int = 4, **kwargs: Any) β†’ List[Tuple[langchain.schema.Document, float]][source]# Return docs and relevance scores in the range [0, 1]. 0 is dissimilar, 1 i...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-75
Upload texts with metadata (properties) to Weaviate. classmethod from_texts(texts: List[str], embedding: langchain.embeddings.base.Embeddings, metadatas: Optional[List[dict]] = None, **kwargs: Any) β†’ langchain.vectorstores.weaviate.Weaviate[source]# Construct Weaviate wrapper from raw documents. This is a user-friendly...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-76
Defaults to 0.5. Returns List of Documents selected by maximal marginal relevance. max_marginal_relevance_search_by_vector(embedding: List[float], k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, **kwargs: Any) β†’ List[langchain.schema.Document][source]# Return docs selected using the maximal marginal relevance....
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-77
Look up similar documents by embedding vector in Weaviate. similarity_search_with_score(query: str, k: int = 4, **kwargs: Any) β†’ List[Tuple[langchain.schema.Document, float]][source]# class langchain.vectorstores.Zilliz(embedding_function: langchain.embeddings.base.Embeddings, collection_name: str = 'LangChainCollectio...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
5641e0c3fcb0-78
Defaults to None. search_params (Optional[dict], optional) – Which search params to use. Defaults to None. drop_old (Optional[bool], optional) – Whether to drop the collection with that name if it exists. Defaults to False. Returns Zilliz Vector Store Return type Zilliz previous Document Loaders next Retrievers By Harr...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
91755aa8b5b4-0
.rst .pdf SearxNG Search Contents Quick Start Searching Engine Parameters Search Tips SearxNG Search# Utility for using SearxNG meta search API. SearxNG is a privacy-friendly free metasearch engine that aggregates results from multiple search engines and databases and supports the OpenSearch specification. More detai...
https://python.langchain.com/en/latest/reference/modules/searx_search.html
91755aa8b5b4-1
# assuming the searx host is set as above or exported as an env variable s = SearxSearchWrapper(engines=['google', 'bing'], language='es') Search Tips# Searx offers a special search syntax that can also be used instead of passing engine parameters. For example the following query: s = SearxSearchWra...
https://python.langchain.com/en/latest/reference/modules/searx_search.html
91755aa8b5b4-2
use a self hosted instance and disable the rate limiter. If you are self-hosting an instance you can customize the rate limiter for your own network as described here. For a list of public SearxNG instances see https://searx.space/ class langchain.utilities.searx_search.SearxResults(data: str)[source]# Dict like wrappe...
https://python.langchain.com/en/latest/reference/modules/searx_search.html
91755aa8b5b4-3
field params: dict [Optional]# field query_suffix: Optional[str] = ''# field searx_host: str = ''# field unsecure: bool = False# async aresults(query: str, num_results: int, engines: Optional[List[str]] = None, query_suffix: Optional[str] = '', **kwargs: Any) β†’ List[Dict][source]# Asynchronously query with json results...
https://python.langchain.com/en/latest/reference/modules/searx_search.html
91755aa8b5b4-4
Run query through Searx API and parse results. You can pass any other params to the searx query API. Parameters query – The query to search for. query_suffix – Extra suffix appended to the query. engines – List of engines to use for the query. categories – List of categories to use for the query. **kwargs – extra param...
https://python.langchain.com/en/latest/reference/modules/searx_search.html
1c9bc9e0ad7d-0
.rst .pdf SerpAPI SerpAPI# For backwards compatiblity. pydantic model langchain.serpapi.SerpAPIWrapper[source]# 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 param...
https://python.langchain.com/en/latest/reference/modules/serpapi.html
58b3cb6ae83d-0
.rst .pdf Agents Agents# Interface for agents. pydantic model langchain.agents.Agent[source]# Class responsible for calling the language model and deciding the action. This is driven by an LLMChain. The prompt in the LLMChain MUST include a variable called β€œagent_scratchpad” where the agent can put its intermediary wor...
https://python.langchain.com/en/latest/reference/modules/agents.html
58b3cb6ae83d-1
Construct an agent from an LLM and tools. get_allowed_tools() β†’ Optional[List[str]][source]# get_full_inputs(intermediate_steps: List[Tuple[langchain.schema.AgentAction, str]], **kwargs: Any) β†’ Dict[str, Any][source]# Create the full inputs for the LLMChain from intermediate steps. plan(intermediate_steps: List[Tuple[l...
https://python.langchain.com/en/latest/reference/modules/agents.html
58b3cb6ae83d-2
field early_stopping_method: str = 'force'# field handle_parsing_errors: Union[bool, str, Callable[[OutputParserException], str]] = False# field max_execution_time: Optional[float] = None# field max_iterations: Optional[int] = 15# field return_intermediate_steps: bool = False# field tools: Sequence[BaseTool] [Required]...
https://python.langchain.com/en/latest/reference/modules/agents.html
58b3cb6ae83d-3
SELF_ASK_WITH_SEARCH = 'self-ask-with-search'# STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION = 'structured-chat-zero-shot-react-description'# ZERO_SHOT_REACT_DESCRIPTION = 'zero-shot-react-description'# pydantic model langchain.agents.BaseMultiActionAgent[source]# Base Agent class. abstract async aplan(intermediate_steps...
https://python.langchain.com/en/latest/reference/modules/agents.html
58b3cb6ae83d-4
Return response when agent has been stopped due to max iterations. save(file_path: Union[pathlib.Path, str]) β†’ None[source]# Save the agent. Parameters file_path – Path to file to save the agent to. Example: .. code-block:: python # If working with agent executor agent.agent.save(file_path=”path/agent.yaml”) tool_run_l...
https://python.langchain.com/en/latest/reference/modules/agents.html
58b3cb6ae83d-5
get_allowed_tools() β†’ Optional[List[str]][source]# abstract plan(intermediate_steps: List[Tuple[langchain.schema.AgentAction, str]], callbacks: Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]] = None, **kwargs: Any) β†’ Union[langchain.schema.AgentAction, l...
https://python.langchain.com/en/latest/reference/modules/agents.html
58b3cb6ae83d-6
classmethod create_prompt(tools: Sequence[langchain.tools.base.BaseTool], prefix: str = 'Assistant is a large language model trained by OpenAI.\n\nAssistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of ...
https://python.langchain.com/en/latest/reference/modules/agents.html
58b3cb6ae83d-7
say to the Human, or if you do not need to use a tool, you MUST use the format:\n\n```\nThought: Do I need to use a tool? No\n{ai_prefix}: [your response here]\n```', ai_prefix: str = 'AI', human_prefix: str = 'Human', input_variables: Optional[List[str]] = None) β†’ langchain.prompts.prompt.PromptTemplate[source]#
https://python.langchain.com/en/latest/reference/modules/agents.html
58b3cb6ae83d-8
Create prompt in the style of the zero shot agent. Parameters tools – List of tools the agent will have access to, used to format the prompt. prefix – String to put before the list of tools. suffix – String to put after the list of tools. ai_prefix – String to use before AI output. human_prefix – String to use before h...
https://python.langchain.com/en/latest/reference/modules/agents.html
58b3cb6ae83d-9
classmethod from_llm_and_tools(llm: langchain.base_language.BaseLanguageModel, tools: Sequence[langchain.tools.base.BaseTool], callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, output_parser: Optional[langchain.agents.agent.AgentOutputParser] = None, prefix: str = 'Assistant is a large la...
https://python.langchain.com/en/latest/reference/modules/agents.html
58b3cb6ae83d-10
the action to take, should be one of [{tool_names}]\nAction Input: the input to the action\nObservation: the result of the action\n```\n\nWhen you have a response to say to the Human, or if you do not need to use a tool, you MUST use the format:\n\n```\nThought: Do I need to use a tool? No\n{ai_prefix}: [your response ...
https://python.langchain.com/en/latest/reference/modules/agents.html
58b3cb6ae83d-11
Construct an agent from an LLM and tools. property llm_prefix: str# Prefix to append the llm call with. property observation_prefix: str# Prefix to append the observation with. pydantic model langchain.agents.ConversationalChatAgent[source]# An agent designed to hold a conversation in addition to using tools. field out...
https://python.langchain.com/en/latest/reference/modules/agents.html
58b3cb6ae83d-12
classmethod create_prompt(tools: Sequence[langchain.tools.base.BaseTool], system_message: str = 'Assistant is a large language model trained by OpenAI.\n\nAssistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide r...
https://python.langchain.com/en/latest/reference/modules/agents.html
58b3cb6ae83d-13
classmethod from_llm_and_tools(llm: langchain.base_language.BaseLanguageModel, tools: Sequence[langchain.tools.base.BaseTool], callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, output_parser: Optional[langchain.agents.agent.AgentOutputParser] = None, system_message: str = 'Assistant is a ...
https://python.langchain.com/en/latest/reference/modules/agents.html
58b3cb6ae83d-14
with a single action, and NOTHING else):\n\n{{{{input}}}}", input_variables: Optional[List[str]] = None, **kwargs: Any) β†’ langchain.agents.agent.Agent[source]#
https://python.langchain.com/en/latest/reference/modules/agents.html
58b3cb6ae83d-15
Construct an agent from an LLM and tools. property llm_prefix: str# Prefix to append the llm call with. property observation_prefix: str# Prefix to append the observation with. pydantic model langchain.agents.LLMSingleActionAgent[source]# field llm_chain: langchain.chains.llm.LLMChain [Required]# field output_parser: l...
https://python.langchain.com/en/latest/reference/modules/agents.html
58b3cb6ae83d-16
pydantic model langchain.agents.MRKLChain[source]# Chain that implements the MRKL system. Example from langchain import OpenAI, MRKLChain from langchain.chains.mrkl.base import ChainConfig llm = OpenAI(temperature=0) prompt = PromptTemplate(...) chains = [...] mrkl = MRKLChain.from_chains(llm=llm, prompt=prompt) Valida...
https://python.langchain.com/en/latest/reference/modules/agents.html
58b3cb6ae83d-17
action_description="useful for doing math" ) ] mrkl = MRKLChain.from_chains(llm, chains) pydantic model langchain.agents.ReActChain[source]# Chain that implements the ReAct paper. Example from langchain import ReActChain, OpenAI react = ReAct(llm=OpenAI()) Validators raise_deprecation Β» all fields set_verbose Β» ver...
https://python.langchain.com/en/latest/reference/modules/agents.html
58b3cb6ae83d-18
field output_parser: langchain.agents.agent.AgentOutputParser [Optional]# classmethod create_prompt(tools: Sequence[langchain.tools.base.BaseTool], prefix: str = 'Respond to the human as helpfully and accurately as possible. You have access to the following tools:', suffix: str = 'Begin! Reminder to ALWAYS respond with...
https://python.langchain.com/en/latest/reference/modules/agents.html