id
stringlengths
14
15
text
stringlengths
35
2.51k
source
stringlengths
61
154
76cf626360dc-3
Return docs selected using the maximal marginal relevance. as_retriever(**kwargs: Any) → VectorStoreRetriever¶ async asearch(query: str, search_type: str, **kwargs: Any) → List[Document]¶ Return docs most similar to query using specified search type. async asimilarity_search(query: str, k: int = 4, **kwargs: Any) → List[Document]¶ Return docs most similar to query. async asimilarity_search_by_vector(embedding: List[float], k: int = 4, **kwargs: Any) → List[Document]¶ Return docs most similar to embedding vector. async asimilarity_search_with_relevance_scores(query: str, k: int = 4, **kwargs: Any) → List[Tuple[Document, float]]¶ Return docs most similar to query. delete(ids: List[str]) → Optional[bool]¶ Delete by vector ID. Parameters ids – List of ids to delete. Returns True if deletion is successful, False otherwise, None if not implemented. Return type Optional[bool] classmethod from_documents(documents: List[Document], embedding: Embeddings, **kwargs: Any) → VST¶ Return VectorStore initialized from documents and embeddings. classmethod from_texts(texts: List[str], embedding: Embeddings, metadatas: Optional[List[dict]] = None, connection: Any = None, vector_key: Optional[str] = 'vector', id_key: Optional[str] = 'id', text_key: Optional[str] = 'text', **kwargs: Any) → LanceDB[source]¶ Return VectorStore initialized from texts and embeddings.
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.lancedb.LanceDB.html
76cf626360dc-4
Return VectorStore initialized from texts and embeddings. 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. Maximal marginal relevance optimizes for similarity to query AND diversity among selected documents. Parameters query – Text to look up documents similar to. 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 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[Document]¶ Return docs selected using the maximal marginal relevance. Maximal marginal relevance optimizes for similarity to query AND diversity among selected documents. Parameters embedding – Embedding to look up documents similar to. 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 Documents selected by maximal marginal relevance. search(query: str, search_type: str, **kwargs: Any) → List[Document]¶ Return docs most similar to query using specified search type.
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.lancedb.LanceDB.html
76cf626360dc-5
Return docs most similar to query using specified search type. similarity_search(query: str, k: int = 4, **kwargs: Any) → List[Document][source]¶ 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. similarity_search_by_vector(embedding: List[float], k: int = 4, **kwargs: Any) → List[Document]¶ 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_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 – input text k – Number of Documents to return. Defaults to 4. **kwargs – 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)
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.lancedb.LanceDB.html
c449461461ff-0
langchain.vectorstores.qdrant.Qdrant¶ class langchain.vectorstores.qdrant.Qdrant(client: Any, collection_name: str, embeddings: Optional[Embeddings] = None, content_payload_key: str = 'page_content', metadata_payload_key: str = 'metadata', vector_name: Optional[str] = None, embedding_function: Optional[Callable] = None)[source]¶ Bases: VectorStore Wrapper around Qdrant vector database. To use you should have the qdrant-client package installed. Example from qdrant_client import QdrantClient from langchain import Qdrant client = QdrantClient() collection_name = "MyCollection" qdrant = Qdrant(client, collection_name, embedding_function) Initialize with necessary components. Methods __init__(client, collection_name[, ...]) Initialize with necessary components. aadd_documents(documents, **kwargs) Run more documents through the embeddings and add to the vectorstore. aadd_texts(texts[, metadatas]) Run more texts through the embeddings and add to the vectorstore. add_documents(documents, **kwargs) Run more documents through the embeddings and add to the vectorstore. add_texts(texts[, metadatas, ids, batch_size]) Run more texts through the embeddings and add to the vectorstore. afrom_documents(documents, embedding, **kwargs) Return VectorStore initialized from documents and embeddings. afrom_texts(texts, embedding[, metadatas]) Return VectorStore initialized from texts and embeddings. amax_marginal_relevance_search(query[, k, ...]) Return docs selected using the maximal marginal relevance. amax_marginal_relevance_search_by_vector(...) Return docs selected using the maximal marginal relevance.
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.qdrant.Qdrant.html
c449461461ff-1
Return docs selected using the maximal marginal relevance. as_retriever(**kwargs) asearch(query, search_type, **kwargs) Return docs most similar to query using specified search type. 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 most similar to query. delete(ids) Delete by vector ID. from_documents(documents, embedding, **kwargs) Return VectorStore initialized from documents and embeddings. from_texts(texts, embedding[, metadatas, ...]) Construct Qdrant wrapper from a list of texts. 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, filter, ...]) Return docs most similar to query. similarity_search_by_vector(embedding[, k, ...]) Return docs most similar to embedding vector. similarity_search_with_relevance_scores(query) Return docs and relevance scores in the range [0, 1]. similarity_search_with_score(query[, k, ...]) Return docs most similar to query. similarity_search_with_score_by_vector(embedding) Return docs most similar to embedding vector. Attributes CONTENT_KEY METADATA_KEY VECTOR_NAME async aadd_documents(documents: List[Document], **kwargs: Any) → List[str]¶ Run more documents through the embeddings and add to the vectorstore. Parameters
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.qdrant.Qdrant.html
c449461461ff-2
Run more documents through the embeddings and add to the vectorstore. Parameters (List[Document] (documents) – Documents to add to the vectorstore. 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. add_documents(documents: List[Document], **kwargs: Any) → List[str]¶ Run more documents through the embeddings and add to the vectorstore. Parameters (List[Document] (documents) – Documents to add to the vectorstore. Returns List of IDs of the added texts. Return type List[str] add_texts(texts: Iterable[str], metadatas: Optional[List[dict]] = None, ids: Optional[Sequence[str]] = None, batch_size: int = 64, **kwargs: Any) → List[str][source]¶ 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. ids – Optional list of ids to associate with the texts. Ids have to be uuid-like strings. batch_size – How many vectors upload per-request. Default: 64 Returns List of ids from adding the texts into the vectorstore. async classmethod afrom_documents(documents: List[Document], embedding: Embeddings, **kwargs: Any) → VST¶ Return VectorStore initialized from documents and embeddings. async classmethod afrom_texts(texts: List[str], embedding: Embeddings, metadatas: Optional[List[dict]] = None, **kwargs: Any) → VST¶
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.qdrant.Qdrant.html
c449461461ff-3
Return VectorStore initialized from texts and embeddings. async amax_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. async amax_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. as_retriever(**kwargs: Any) → VectorStoreRetriever¶ async asearch(query: str, search_type: str, **kwargs: Any) → List[Document]¶ Return docs most similar to query using specified search type. async asimilarity_search(query: str, k: int = 4, **kwargs: Any) → List[Document]¶ Return docs most similar to query. async asimilarity_search_by_vector(embedding: List[float], k: int = 4, **kwargs: Any) → List[Document]¶ Return docs most similar to embedding vector. async asimilarity_search_with_relevance_scores(query: str, k: int = 4, **kwargs: Any) → List[Tuple[Document, float]]¶ Return docs most similar to query. delete(ids: List[str]) → Optional[bool]¶ Delete by vector ID. Parameters ids – List of ids to delete. Returns True if deletion is successful, False otherwise, None if not implemented. Return type Optional[bool] classmethod from_documents(documents: List[Document], embedding: Embeddings, **kwargs: Any) → VST¶ Return VectorStore initialized from documents and embeddings.
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.qdrant.Qdrant.html
c449461461ff-4
Return VectorStore initialized from documents and embeddings. classmethod from_texts(texts: List[str], embedding: Embeddings, metadatas: Optional[List[dict]] = None, ids: Optional[Sequence[str]] = None, location: Optional[str] = None, url: Optional[str] = None, port: Optional[int] = 6333, grpc_port: int = 6334, prefer_grpc: bool = False, https: Optional[bool] = None, api_key: Optional[str] = None, prefix: Optional[str] = None, timeout: Optional[float] = None, host: Optional[str] = None, path: Optional[str] = None, collection_name: Optional[str] = None, distance_func: str = 'Cosine', content_payload_key: str = 'page_content', metadata_payload_key: str = 'metadata', vector_name: Optional[str] = None, batch_size: int = 64, shard_number: Optional[int] = None, replication_factor: Optional[int] = None, write_consistency_factor: Optional[int] = None, on_disk_payload: Optional[bool] = None, hnsw_config: Optional[common_types.HnswConfigDiff] = None, optimizers_config: Optional[common_types.OptimizersConfigDiff] = None, wal_config: Optional[common_types.WalConfigDiff] = None, quantization_config: Optional[common_types.QuantizationConfig] = None, init_from: Optional[common_types.InitFrom] = None, **kwargs: Any) → Qdrant[source]¶ Construct Qdrant wrapper from a list of texts. Parameters texts – A list of texts to be indexed in Qdrant. embedding – A subclass of Embeddings, responsible for text vectorization. metadatas – An optional list of metadata. If provided it has to be of the same length as a list of texts.
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.qdrant.Qdrant.html
c449461461ff-5
length as a list of texts. ids – Optional list of ids to associate with the texts. Ids have to be uuid-like strings. location – If :memory: - use in-memory Qdrant instance. If str - use it as a url parameter. If None - fallback to relying on host and port parameters. url – either host or str of “Optional[scheme], host, Optional[port], Optional[prefix]”. Default: None port – Port of the REST API interface. Default: 6333 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 URL path. Example: service/v1 will result in http://localhost:6333/service/v1/{qdrant-endpoint} for REST API. Default: None timeout – Timeout for REST and gRPC API requests. Default: 5.0 seconds for REST and unlimited for gRPC host – Host name of Qdrant service. If url and host are None, set to ‘localhost’. Default: None path – Path in which the vectors will be stored while using local mode. Default: None collection_name – Name of the Qdrant collection to be used. If not provided, it will be created randomly. Default: None distance_func – Distance function. One of: “Cosine” / “Euclid” / “Dot”. Default: “Cosine” content_payload_key – A payload key used to store the content of the document. Default: “page_content”
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.qdrant.Qdrant.html
c449461461ff-6
Default: “page_content” metadata_payload_key – A payload key used to store the metadata of the document. Default: “metadata” vector_name – Name of the vector to be used internally in Qdrant. Default: None batch_size – How many vectors upload per-request. Default: 64 shard_number – Number of shards in collection. Default is 1, minimum is 1. replication_factor – Replication factor for collection. Default is 1, minimum is 1. Defines how many copies of each shard will be created. Have effect only in distributed mode. write_consistency_factor – Write consistency factor for collection. Default is 1, minimum is 1. Defines how many replicas should apply the operation for us to consider it successful. Increasing this number will make the collection more resilient to inconsistencies, but will also make it fail if not enough replicas are available. Does not have any performance impact. Have effect only in distributed mode. on_disk_payload – If true - point`s payload will not be stored in memory. It will be read from the disk every time it is requested. This setting saves RAM by (slightly) increasing the response time. Note: those payload values that are involved in filtering and are indexed - remain in RAM. hnsw_config – Params for HNSW index optimizers_config – Params for optimizer wal_config – Params for Write-Ahead-Log quantization_config – Params for quantization, if None - quantization will be disabled init_from – Use data stored in another collection to initialize this collection **kwargs – Additional arguments passed directly into REST client initialization This is a user-friendly interface that: 1. Creates embeddings, one for each text 2. Initializes the Qdrant database as an in-memory docstore by default
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.qdrant.Qdrant.html
c449461461ff-7
2. Initializes the Qdrant database as an in-memory docstore by default (and overridable to a remote docstore) Adds the text embeddings to the Qdrant database This is intended to be a quick way to get started. 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[Document][source]¶ Return docs selected using the maximal marginal relevance. Maximal marginal relevance optimizes for similarity to query AND diversity among selected documents. Parameters query – Text to look up documents similar to. k – Number of Documents to return. Defaults to 4. fetch_k – Number of Documents to fetch to pass to MMR algorithm. Defaults to 20. 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 = 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 – Embedding to look up documents similar to. k – Number of Documents to return. Defaults to 4.
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.qdrant.Qdrant.html
c449461461ff-8
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 Documents selected by maximal marginal relevance. search(query: str, search_type: str, **kwargs: Any) → List[Document]¶ Return docs most similar to query using specified search type. similarity_search(query: str, k: int = 4, filter: Optional[MetadataFilter] = None, search_params: Optional[common_types.SearchParams] = None, offset: int = 0, score_threshold: Optional[float] = None, consistency: Optional[common_types.ReadConsistency] = None, **kwargs: Any) → List[Document][source]¶ Return docs most similar to query. 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. search_params – Additional search params offset – Offset of the first result to return. May be used to paginate results. Note: large offset values may cause performance issues. score_threshold – Define a minimal score threshold for the result. If defined, less similar results will not be returned. Score of the returned result might be higher or smaller than the threshold depending on the Distance function used. E.g. for cosine similarity only higher scores will be returned. consistency – Read consistency of the search. Defines how many replicas should be queried before returning the result. Values: - int - number of replicas to query, values should present in all queried replicas
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.qdrant.Qdrant.html
c449461461ff-9
- int - number of replicas to query, values should present in all queried replicas ’majority’ - query all replicas, but return values present in themajority of replicas ’quorum’ - query the majority of replicas, return values present inall of them ’all’ - query all replicas, and return values present in all replicas Returns List of Documents most similar to the query. similarity_search_by_vector(embedding: List[float], k: int = 4, filter: Optional[MetadataFilter] = None, search_params: Optional[common_types.SearchParams] = None, offset: int = 0, score_threshold: Optional[float] = None, consistency: Optional[common_types.ReadConsistency] = None, **kwargs: Any) → List[Document][source]¶ Return docs most similar to embedding vector. Parameters embedding – Embedding vector to look up documents similar to. k – Number of Documents to return. Defaults to 4. filter – Filter by metadata. Defaults to None. search_params – Additional search params offset – Offset of the first result to return. May be used to paginate results. Note: large offset values may cause performance issues. score_threshold – Define a minimal score threshold for the result. If defined, less similar results will not be returned. Score of the returned result might be higher or smaller than the threshold depending on the Distance function used. E.g. for cosine similarity only higher scores will be returned. consistency – Read consistency of the search. Defines how many replicas should be queried before returning the result. Values: - int - number of replicas to query, values should present in all queried replicas ’majority’ - query all replicas, but return values present in themajority of replicas
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.qdrant.Qdrant.html
c449461461ff-10
’majority’ - query all replicas, but return values present in themajority of replicas ’quorum’ - query the majority of replicas, return values present inall of them ’all’ - query all replicas, and return values present in all replicas Returns List of Documents most similar to the query. similarity_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 – input text k – Number of Documents to return. Defaults to 4. **kwargs – 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) similarity_search_with_score(query: str, k: int = 4, filter: Optional[MetadataFilter] = None, search_params: Optional[common_types.SearchParams] = None, offset: int = 0, score_threshold: Optional[float] = None, consistency: Optional[common_types.ReadConsistency] = None, **kwargs: Any) → List[Tuple[Document, float]][source]¶ Return docs most similar to query. 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. search_params – Additional search params offset – Offset of the first result to return. May be used to paginate results. Note: large offset values may cause performance issues. score_threshold – Define a minimal score threshold for the result. If defined, less similar results will not be returned.
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.qdrant.Qdrant.html
c449461461ff-11
If defined, less similar results will not be returned. Score of the returned result might be higher or smaller than the threshold depending on the Distance function used. E.g. for cosine similarity only higher scores will be returned. consistency – Read consistency of the search. Defines how many replicas should be queried before returning the result. Values: - int - number of replicas to query, values should present in all queried replicas ’majority’ - query all replicas, but return values present in themajority of replicas ’quorum’ - query the majority of replicas, return values present inall of them ’all’ - query all replicas, and return values present in all replicas Returns List of documents most similar to the query text and cosine distance in float for each. Lower score represents more similarity. similarity_search_with_score_by_vector(embedding: List[float], k: int = 4, filter: Optional[MetadataFilter] = None, search_params: Optional[common_types.SearchParams] = None, offset: int = 0, score_threshold: Optional[float] = None, consistency: Optional[common_types.ReadConsistency] = None, **kwargs: Any) → List[Tuple[Document, float]][source]¶ Return docs most similar to embedding vector. Parameters embedding – Embedding vector to look up documents similar to. k – Number of Documents to return. Defaults to 4. filter – Filter by metadata. Defaults to None. search_params – Additional search params offset – Offset of the first result to return. May be used to paginate results. Note: large offset values may cause performance issues. score_threshold – Define a minimal score threshold for the result. If defined, less similar results will not be returned. Score of the returned result might be higher or smaller than the threshold depending on the Distance function used.
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.qdrant.Qdrant.html
c449461461ff-12
threshold depending on the Distance function used. E.g. for cosine similarity only higher scores will be returned. consistency – Read consistency of the search. Defines how many replicas should be queried before returning the result. Values: - int - number of replicas to query, values should present in all queried replicas ’majority’ - query all replicas, but return values present in themajority of replicas ’quorum’ - query the majority of replicas, return values present inall of them ’all’ - query all replicas, and return values present in all replicas Returns List of documents most similar to the query text and cosine distance in float for each. Lower score represents more similarity. CONTENT_KEY = 'page_content'¶ METADATA_KEY = 'metadata'¶ VECTOR_NAME = None¶
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.qdrant.Qdrant.html
e732c6e32cef-0
langchain.vectorstores.supabase.SupabaseVectorStore¶ class langchain.vectorstores.supabase.SupabaseVectorStore(client: supabase.client.Client, embedding: Embeddings, table_name: str, query_name: Union[str, None] = None)[source]¶ Bases: VectorStore VectorStore for a Supabase postgres database. Assumes you have the pgvector extension installed and a match_documents (or similar) function. For more details: https://js.langchain.com/docs/modules/indexes/vector_stores/integrations/supabase You can implement your own match_documents function in order to limit the search space to a subset of documents based on your own authorization or business logic. Note that the Supabase Python client does not yet support async operations. If you’d like to use max_marginal_relevance_search, please review the instructions below on modifying the match_documents function to return matched embeddings. Initialize with supabase client. Methods __init__(client, embedding, table_name[, ...]) Initialize with supabase client. aadd_documents(documents, **kwargs) Run more documents through the embeddings and add to the vectorstore. aadd_texts(texts[, metadatas]) Run more texts through the embeddings and add to the vectorstore. add_documents(documents, **kwargs) Run more documents through the embeddings and add to the vectorstore. add_texts(texts[, metadatas, ids]) Run more texts through the embeddings and add to the vectorstore. add_vectors(vectors, documents, ids) afrom_documents(documents, embedding, **kwargs) Return VectorStore initialized from documents and embeddings. afrom_texts(texts, embedding[, metadatas]) Return VectorStore initialized from texts and embeddings.
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.supabase.SupabaseVectorStore.html
e732c6e32cef-1
Return VectorStore initialized from texts and embeddings. amax_marginal_relevance_search(query[, k, ...]) Return docs selected using the maximal marginal relevance. amax_marginal_relevance_search_by_vector(...) Return docs selected using the maximal marginal relevance. as_retriever(**kwargs) asearch(query, search_type, **kwargs) Return docs most similar to query using specified search type. 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 most similar to query. delete(ids) Delete by vector IDs. from_documents(documents, embedding, **kwargs) Return VectorStore initialized from documents and embeddings. from_texts(texts, embedding[, metadatas, ...]) Return VectorStore initialized from texts and embeddings. 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]) Return docs most similar to query. similarity_search_by_vector(embedding[, k]) Return docs most similar to embedding vector. similarity_search_by_vector_returning_embeddings(...) similarity_search_by_vector_with_relevance_scores(...) similarity_search_with_relevance_scores(query) Return docs and relevance scores in the range [0, 1]. Attributes table_name query_name async aadd_documents(documents: List[Document], **kwargs: Any) → List[str]¶
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.supabase.SupabaseVectorStore.html
e732c6e32cef-2
Run more documents through the embeddings and add to the vectorstore. Parameters (List[Document] (documents) – Documents to add to the vectorstore. 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. add_documents(documents: List[Document], **kwargs: Any) → List[str]¶ Run more documents through the embeddings and add to the vectorstore. Parameters (List[Document] (documents) – Documents to add to the vectorstore. Returns List of IDs of the added texts. Return type List[str] add_texts(texts: Iterable[str], metadatas: Optional[List[dict[Any, Any]]] = None, ids: Optional[List[str]] = None, **kwargs: Any) → List[str][source]¶ 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(vectors: List[List[float]], documents: List[Document], ids: List[str]) → List[str][source]¶ async classmethod afrom_documents(documents: List[Document], embedding: Embeddings, **kwargs: Any) → VST¶ Return VectorStore initialized from documents and embeddings. async classmethod afrom_texts(texts: List[str], embedding: Embeddings, metadatas: Optional[List[dict]] = None, **kwargs: Any) → VST¶ Return VectorStore initialized from texts and embeddings.
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.supabase.SupabaseVectorStore.html
e732c6e32cef-3
Return VectorStore initialized from texts and embeddings. async amax_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. async amax_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. as_retriever(**kwargs: Any) → VectorStoreRetriever¶ async asearch(query: str, search_type: str, **kwargs: Any) → List[Document]¶ Return docs most similar to query using specified search type. async asimilarity_search(query: str, k: int = 4, **kwargs: Any) → List[Document]¶ Return docs most similar to query. async asimilarity_search_by_vector(embedding: List[float], k: int = 4, **kwargs: Any) → List[Document]¶ Return docs most similar to embedding vector. async asimilarity_search_with_relevance_scores(query: str, k: int = 4, **kwargs: Any) → List[Tuple[Document, float]]¶ Return docs most similar to query. delete(ids: List[str]) → None[source]¶ Delete by vector IDs. Parameters ids – List of ids to delete. classmethod from_documents(documents: List[Document], embedding: Embeddings, **kwargs: Any) → VST¶ Return VectorStore initialized from documents and embeddings.
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.supabase.SupabaseVectorStore.html
e732c6e32cef-4
Return VectorStore initialized from documents and embeddings. classmethod from_texts(texts: List[str], embedding: Embeddings, metadatas: Optional[List[dict]] = None, client: Optional[supabase.client.Client] = None, table_name: Optional[str] = 'documents', query_name: Union[str, None] = 'match_documents', ids: Optional[List[str]] = None, **kwargs: Any) → SupabaseVectorStore[source]¶ Return VectorStore initialized from texts and embeddings. max_marginal_relevance_search(query: str, k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, **kwargs: Any) → List[Document][source]¶ Return docs selected using the maximal marginal relevance. Maximal marginal relevance optimizes for similarity to query AND diversity among selected documents. Parameters query – Text to look up documents similar to. 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 Documents selected by maximal marginal relevance. max_marginal_relevance_search requires that query_name returns matched embeddings alongside the match documents. The following function 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, metadata, embedding,
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.supabase.SupabaseVectorStore.html
e732c6e32cef-5
BEGINRETURN query SELECT id, content, metadata, embedding, 1 -(docstore.embedding <=> query_embedding) AS similarity FROMdocstore ORDER BYdocstore.embedding <=> query_embedding LIMIT match_count; END; $$; ``` 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][source]¶ Return docs selected using the maximal marginal relevance. Maximal marginal relevance optimizes for similarity to query AND diversity among selected documents. Parameters embedding – Embedding to look up documents similar to. 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 Documents selected by maximal marginal relevance. search(query: str, search_type: str, **kwargs: Any) → List[Document]¶ Return docs most similar to query using specified search type. similarity_search(query: str, k: int = 4, **kwargs: Any) → List[Document][source]¶ Return docs most similar to query. similarity_search_by_vector(embedding: List[float], k: int = 4, **kwargs: Any) → List[Document][source]¶ 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.
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.supabase.SupabaseVectorStore.html
e732c6e32cef-6
Returns List of Documents most similar to the query vector. similarity_search_by_vector_returning_embeddings(query: List[float], k: int) → List[Tuple[Document, float, ndarray[float32, Any]]][source]¶ similarity_search_by_vector_with_relevance_scores(query: List[float], k: int) → List[Tuple[Document, float]][source]¶ similarity_search_with_relevance_scores(query: str, k: int = 4, **kwargs: Any) → List[Tuple[Document, float]][source]¶ Return docs and relevance scores in the range [0, 1]. 0 is dissimilar, 1 is most similar. Parameters query – input text k – Number of Documents to return. Defaults to 4. **kwargs – 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) query_name: str¶ table_name: str¶
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.supabase.SupabaseVectorStore.html
7c7d12426ceb-0
langchain.vectorstores.starrocks.has_mul_sub_str¶ langchain.vectorstores.starrocks.has_mul_sub_str(s: str, *args: Any) → bool[source]¶ Check if a string has multiple substrings. :param s: The string to check :param *args: The substrings to check for in the string Returns True if all substrings are present in the string, False otherwise Return type bool
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.starrocks.has_mul_sub_str.html
feb23d94161c-0
langchain.vectorstores.myscale.MyScaleSettings¶ class langchain.vectorstores.myscale.MyScaleSettings(_env_file: Optional[Union[str, PathLike, List[Union[str, PathLike]], Tuple[Union[str, PathLike], ...]]] = '<object object>', _env_file_encoding: Optional[str] = None, _env_nested_delimiter: Optional[str] = None, _secrets_dir: Optional[Union[str, PathLike]] = None, *, host: str = 'localhost', port: int = 8443, username: Optional[str] = None, password: Optional[str] = None, index_type: str = 'IVFFLAT', index_param: Optional[Dict[str, str]] = None, column_map: Dict[str, str] = {'id': 'id', 'metadata': 'metadata', 'text': 'text', 'vector': 'vector'}, database: str = 'default', table: str = 'langchain', metric: str = 'cosine')[source]¶ Bases: BaseSettings 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 (str) : Username to login. Defaults to None. password (str) : Password to login. Defaults to None. index_type (str): index type string. index_param (dict): index build parameter. database (str) : Database name to find the table. Defaults to ‘default’. table (str) : Table name to operate on. Defaults to ‘vector_table’. metric (str)Metric to compute distance,supported are (‘l2’, ‘cosine’, ‘ip’). Defaults to ‘cosine’.
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.myscale.MyScaleSettings.html
feb23d94161c-1
column_map (Dict)Column type map to project column name onto langchainsemantics. Must have keys: text, id, vector, must be same size to number of columns. For example: .. code-block:: python {‘id’: ‘text_id’, ‘vector’: ‘text_embedding’, ‘text’: ‘text_plain’, ‘metadata’: ‘metadata_dictionary_in_json’, } Defaults to identity map. 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 column_map: Dict[str, str] = {'id': 'id', 'metadata': 'metadata', 'text': 'text', 'vector': 'vector'}¶ param database: str = 'default'¶ param host: str = 'localhost'¶ param index_param: Optional[Dict[str, str]] = None¶ param index_type: str = 'IVFFLAT'¶ param metric: str = 'cosine'¶ param password: Optional[str] = None¶ param port: int = 8443¶ param table: str = 'langchain'¶ param username: Optional[str] = None¶ model Config[source]¶ Bases: object env_file = '.env'¶ env_file_encoding = 'utf-8'¶ env_prefix = 'myscale_'¶
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.myscale.MyScaleSettings.html
0a1d8a26b94c-0
langchain.vectorstores.zilliz.Zilliz¶ class langchain.vectorstores.zilliz.Zilliz(embedding_function: Embeddings, collection_name: str = 'LangChainCollection', connection_args: Optional[dict[str, Any]] = None, consistency_level: str = 'Session', index_params: Optional[dict] = None, search_params: Optional[dict] = None, drop_old: Optional[bool] = False)[source]¶ Bases: Milvus Initialize wrapper around the milvus vector database. In order to use this you need to have pymilvus installed and a running Milvus/Zilliz Cloud instance. See the following documentation for how to run a Milvus instance: https://milvus.io/docs/install_standalone-docker.md If looking for a hosted Milvus, take a looka this documentation: https://zilliz.com/cloud IF USING L2/IP metric IT IS HIGHLY SUGGESTED TO NORMALIZE YOUR DATA. Parameters embedding_function (Embeddings) – Function used to embed the text. collection_name (str) – Which Milvus collection to use. Defaults to “LangChainCollection”. connection_args (Optional[dict[str, any]]) – The connection args used for this class comes in the form of a dict, here are a few of the options: address (str): The actual address of Milvus instance. Example address: “localhost:19530” uri (str): The uri of Milvus instance. Example uri:”http://randomwebsite:19530”, “tcp:foobarsite:19530”, “https://ok.s3.south.com:19530”. host (str): The host of Milvus instance. Default at “localhost”,PyMilvus will fill in the default host if only port is provided.
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.zilliz.Zilliz.html
0a1d8a26b94c-1
port (str/int): The port of Milvus instance. Default at 19530, PyMilvuswill fill in the default port if only host is provided. user (str): Use which user to connect to Milvus instance. If user andpassword are provided, we will add related header in every RPC call. password (str): Required when user is provided. The passwordcorresponding to the user. secure (bool): Default is false. If set to true, tls will be enabled. client_key_path (str): If use tls two-way authentication, need to write the client.key path. client_pem_path (str): If use tls two-way authentication, need towrite the client.pem path. ca_pem_path (str): If use tls two-way authentication, need to writethe ca.pem path. server_pem_path (str): If use tls one-way authentication, need towrite the server.pem path. server_name (str): If use tls, need to write the common name. consistency_level (str) – The consistency level to use for a collection. Defaults to “Session”. index_params (Optional[dict]) – Which index params to use. Defaults to HNSW/AUTOINDEX depending on service. search_params (Optional[dict]) – Which search params to use. Defaults to default of index. drop_old (Optional[bool]) – Whether to drop the current collection. Defaults to False. The connection args used for this class comes in the form of a dict, here are a few of the options: address (str): The actual address of Milvusinstance. Example address: “localhost:19530” uri (str): The uri of Milvus instance. Example uri:“http://randomwebsite:19530”, “tcp:foobarsite:19530”,
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.zilliz.Zilliz.html
0a1d8a26b94c-2
“tcp:foobarsite:19530”, “https://ok.s3.south.com:19530”. host (str): The host of Milvus instance. Default at “localhost”,PyMilvus will fill in the default host if only port is provided. port (str/int): The port of Milvus instance. Default at 19530, PyMilvuswill fill in the default port if only host is provided. user (str): Use which user to connect to Milvus instance. If user andpassword are provided, we will add related header in every RPC call. password (str): Required when user is provided. The passwordcorresponding to the user. secure (bool): Default is false. If set to true, tls will be enabled. client_key_path (str): If use tls two-way authentication, need to write the client.key path. client_pem_path (str): If use tls two-way authentication, need towrite the client.pem path. ca_pem_path (str): If use tls two-way authentication, need to writethe ca.pem path. server_pem_path (str): If use tls one-way authentication, need towrite the server.pem path. server_name (str): If use tls, need to write the common name. Methods __init__(embedding_function[, ...]) Initialize wrapper around the milvus vector database. aadd_documents(documents, **kwargs) Run more documents through the embeddings and add to the vectorstore. aadd_texts(texts[, metadatas]) Run more texts through the embeddings and add to the vectorstore. add_documents(documents, **kwargs) Run more documents through the embeddings and add to the vectorstore. add_texts(texts[, metadatas, timeout, ...])
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.zilliz.Zilliz.html
0a1d8a26b94c-3
add_texts(texts[, metadatas, timeout, ...]) Insert text data into Milvus. afrom_documents(documents, embedding, **kwargs) Return VectorStore initialized from documents and embeddings. afrom_texts(texts, embedding[, metadatas]) Return VectorStore initialized from texts and embeddings. amax_marginal_relevance_search(query[, k, ...]) Return docs selected using the maximal marginal relevance. amax_marginal_relevance_search_by_vector(...) Return docs selected using the maximal marginal relevance. as_retriever(**kwargs) asearch(query, search_type, **kwargs) Return docs most similar to query using specified search type. 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 most similar to query. delete(ids) Delete by vector ID. from_documents(documents, embedding, **kwargs) Return VectorStore initialized from documents and embeddings. from_texts(texts, embedding[, metadatas, ...]) Create a Zilliz collection, indexes it with HNSW, and insert data. max_marginal_relevance_search(query[, k, ...]) Perform a search and return results that are reordered by MMR. max_marginal_relevance_search_by_vector(...) Perform a search and return results that are reordered by MMR. search(query, search_type, **kwargs) Return docs most similar to query using specified search type. similarity_search(query[, k, param, expr, ...]) Perform a similarity search against the query string.
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.zilliz.Zilliz.html
0a1d8a26b94c-4
Perform a similarity search against the query string. similarity_search_by_vector(embedding[, k, ...]) Perform a similarity search against the query string. similarity_search_with_relevance_scores(query) Return docs and relevance scores in the range [0, 1]. similarity_search_with_score(query[, k, ...]) Perform a search on a query string and return results with score. similarity_search_with_score_by_vector(embedding) Perform a search on a query string and return results with score. async aadd_documents(documents: List[Document], **kwargs: Any) → List[str]¶ Run more documents through the embeddings and add to the vectorstore. Parameters (List[Document] (documents) – Documents to add to the vectorstore. 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. add_documents(documents: List[Document], **kwargs: Any) → List[str]¶ Run more documents through the embeddings and add to the vectorstore. Parameters (List[Document] (documents) – Documents to add to the vectorstore. Returns List of IDs of the added texts. Return type List[str] add_texts(texts: Iterable[str], metadatas: Optional[List[dict]] = None, timeout: Optional[int] = None, batch_size: int = 1000, **kwargs: Any) → List[str]¶ Insert text data into Milvus. Inserting data when the collection has not be made yet will result in creating a new Collection. The data of the first entity decides
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.zilliz.Zilliz.html
0a1d8a26b94c-5
in creating a new Collection. The data of the first entity decides the schema of the new collection, the dim is extracted from the first embedding and the columns are decided by the first metadata dict. Metada keys will need to be present for all inserted values. At the moment there is no None equivalent in Milvus. Parameters texts (Iterable[str]) – The texts to embed, it is assumed that they all fit in memory. metadatas (Optional[List[dict]]) – Metadata dicts attached to each of the texts. Defaults to None. timeout (Optional[int]) – Timeout for each batch insert. Defaults to None. batch_size (int, optional) – Batch size to use for insertion. Defaults to 1000. Raises MilvusException – Failure to add texts Returns The resulting keys for each inserted element. Return type List[str] async classmethod afrom_documents(documents: List[Document], embedding: Embeddings, **kwargs: Any) → VST¶ Return VectorStore initialized from documents and embeddings. async classmethod afrom_texts(texts: List[str], embedding: Embeddings, metadatas: Optional[List[dict]] = None, **kwargs: Any) → VST¶ Return VectorStore initialized from texts and embeddings. async amax_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. async amax_marginal_relevance_search_by_vector(embedding: List[float], k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, **kwargs: Any) → List[Document]¶
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.zilliz.Zilliz.html
0a1d8a26b94c-6
Return docs selected using the maximal marginal relevance. as_retriever(**kwargs: Any) → VectorStoreRetriever¶ async asearch(query: str, search_type: str, **kwargs: Any) → List[Document]¶ Return docs most similar to query using specified search type. async asimilarity_search(query: str, k: int = 4, **kwargs: Any) → List[Document]¶ Return docs most similar to query. async asimilarity_search_by_vector(embedding: List[float], k: int = 4, **kwargs: Any) → List[Document]¶ Return docs most similar to embedding vector. async asimilarity_search_with_relevance_scores(query: str, k: int = 4, **kwargs: Any) → List[Tuple[Document, float]]¶ Return docs most similar to query. delete(ids: List[str]) → Optional[bool]¶ Delete by vector ID. Parameters ids – List of ids to delete. Returns True if deletion is successful, False otherwise, None if not implemented. Return type Optional[bool] classmethod from_documents(documents: List[Document], embedding: Embeddings, **kwargs: Any) → VST¶ Return VectorStore initialized from documents and embeddings. classmethod from_texts(texts: List[str], embedding: Embeddings, metadatas: Optional[List[dict]] = None, collection_name: str = 'LangChainCollection', connection_args: dict[str, Any] = {}, consistency_level: str = 'Session', index_params: Optional[dict] = None, search_params: Optional[dict] = None, drop_old: bool = False, **kwargs: Any) → Zilliz[source]¶ Create a Zilliz collection, indexes it with HNSW, and insert data. Parameters texts (List[str]) – Text data.
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.zilliz.Zilliz.html
0a1d8a26b94c-7
Parameters texts (List[str]) – Text data. embedding (Embeddings) – Embedding function. metadatas (Optional[List[dict]]) – Metadata for each text if it exists. Defaults to None. collection_name (str, optional) – Collection name to use. Defaults to “LangChainCollection”. connection_args (dict[str, Any], optional) – Connection args to use. Defaults to DEFAULT_MILVUS_CONNECTION. consistency_level (str, optional) – Which consistency level to use. Defaults to “Session”. index_params (Optional[dict], optional) – Which index_params to use. 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 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[Document]¶ Perform a search and return results that are reordered by MMR. Parameters query (str) – The text 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 maximum diversity and 1 to minimum diversity. Defaults to 0.5
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.zilliz.Zilliz.html
0a1d8a26b94c-8
to maximum diversity and 1 to minimum diversity. Defaults to 0.5 param (dict, optional) – The search params for the specified index. 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. Returns Document results for search. 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, param: Optional[dict] = None, expr: Optional[str] = None, timeout: Optional[int] = None, **kwargs: Any) → List[Document]¶ Perform a search and return results that are reordered by MMR. 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 maximum diversity and 1 to minimum diversity. Defaults to 0.5 param (dict, optional) – The search params for the specified index. 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. Returns Document results for search. Return type List[Document] search(query: str, search_type: str, **kwargs: Any) → List[Document]¶
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.zilliz.Zilliz.html
0a1d8a26b94c-9
Return docs most similar to query using specified search type. similarity_search(query: str, k: int = 4, param: Optional[dict] = None, expr: Optional[str] = None, timeout: Optional[int] = None, **kwargs: Any) → List[Document]¶ Perform a similarity search against the query string. Parameters query (str) – The text to search. k (int, optional) – How many results to return. Defaults to 4. param (dict, optional) – The search params for the index type. 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. 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[Document]¶ Perform a similarity search against the query string. Parameters embedding (List[float]) – The embedding vector to search. k (int, optional) – How many results to return. Defaults to 4. param (dict, optional) – The search params for the index type. 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. Returns Document results for search. Return type List[Document]
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.zilliz.Zilliz.html
0a1d8a26b94c-10
Returns Document results for search. Return type List[Document] similarity_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 – input text k – Number of Documents to return. Defaults to 4. **kwargs – 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) similarity_search_with_score(query: str, k: int = 4, param: Optional[dict] = None, expr: Optional[str] = None, timeout: Optional[int] = None, **kwargs: Any) → List[Tuple[Document, float]]¶ Perform a search on a query string and return results with score. For more information about the search parameters, take a look at the pymilvus documentation found here: https://milvus.io/api-reference/pymilvus/v2.2.6/Collection/search().md Parameters query (str) – The text being searched. k (int, optional) – The amount of results ot return. Defaults to 4. param (dict) – The search params for the specified index. 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]]
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.zilliz.Zilliz.html
0a1d8a26b94c-11
Return type List[float], List[Tuple[Document, any, any]] similarity_search_with_score_by_vector(embedding: List[float], k: int = 4, param: Optional[dict] = None, expr: Optional[str] = None, timeout: Optional[int] = None, **kwargs: Any) → List[Tuple[Document, float]]¶ Perform a search on a query string and return results with score. For more information about the search parameters, take a look at the pymilvus documentation found here: https://milvus.io/api-reference/pymilvus/v2.2.6/Collection/search().md Parameters embedding (List[float]) – The embedding vector being searched. k (int, optional) – The amount of results ot return. Defaults to 4. param (dict) – The search params for the specified index. 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. Returns Result doc and score. Return type List[Tuple[Document, float]]
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.zilliz.Zilliz.html
477456661ba8-0
langchain.vectorstores.annoy.Annoy¶ class langchain.vectorstores.annoy.Annoy(embedding_function: Callable, index: Any, metric: str, docstore: Docstore, index_to_docstore_id: Dict[int, str])[source]¶ Bases: VectorStore Wrapper around Annoy vector database. To use, you should have the annoy python package installed. Example from langchain import Annoy db = Annoy(embedding_function, index, docstore, index_to_docstore_id) Initialize with necessary components. Methods __init__(embedding_function, index, metric, ...) Initialize with necessary components. aadd_documents(documents, **kwargs) Run more documents through the embeddings and add to the vectorstore. aadd_texts(texts[, metadatas]) Run more texts through the embeddings and add to the vectorstore. add_documents(documents, **kwargs) Run more documents through the embeddings and add to the vectorstore. add_texts(texts[, metadatas]) Run more texts through the embeddings and add to the vectorstore. afrom_documents(documents, embedding, **kwargs) Return VectorStore initialized from documents and embeddings. afrom_texts(texts, embedding[, metadatas]) Return VectorStore initialized from texts and embeddings. amax_marginal_relevance_search(query[, k, ...]) Return docs selected using the maximal marginal relevance. amax_marginal_relevance_search_by_vector(...) Return docs selected using the maximal marginal relevance. as_retriever(**kwargs) asearch(query, search_type, **kwargs) Return docs most similar to query using specified search type. asimilarity_search(query[, k]) Return docs most similar to query.
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.annoy.Annoy.html
477456661ba8-1
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 most similar to query. delete(ids) Delete by vector ID. from_documents(documents, embedding, **kwargs) Return VectorStore initialized from documents and embeddings. from_embeddings(text_embeddings, embedding) Construct Annoy wrapper from embeddings. from_texts(texts, embedding[, metadatas, ...]) Construct Annoy wrapper from raw documents. load_local(folder_path, embeddings) Load Annoy index, docstore, and index_to_docstore_id to disk. 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. process_index_results(idxs, dists) Turns annoy results into a list of documents and scores. save_local(folder_path[, prefault]) Save Annoy index, docstore, and index_to_docstore_id to disk. search(query, search_type, **kwargs) Return docs most similar to query using specified search type. similarity_search(query[, k, search_k]) Return docs most similar to query. similarity_search_by_index(docstore_index[, ...]) Return docs most similar to docstore_index. similarity_search_by_vector(embedding[, k, ...]) Return docs most similar to embedding vector. similarity_search_with_relevance_scores(query) Return docs and relevance scores in the range [0, 1]. similarity_search_with_score(query[, k, ...])
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.annoy.Annoy.html
477456661ba8-2
similarity_search_with_score(query[, k, ...]) Return docs most similar to query. similarity_search_with_score_by_index(...[, ...]) Return docs most similar to query. similarity_search_with_score_by_vector(embedding) Return docs most similar to query. async aadd_documents(documents: List[Document], **kwargs: Any) → List[str]¶ Run more documents through the embeddings and add to the vectorstore. Parameters (List[Document] (documents) – Documents to add to the vectorstore. 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. add_documents(documents: List[Document], **kwargs: Any) → List[str]¶ Run more documents through the embeddings and add to the vectorstore. Parameters (List[Document] (documents) – Documents to add to the vectorstore. 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]¶ 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 afrom_documents(documents: List[Document], embedding: Embeddings, **kwargs: Any) → VST¶ Return VectorStore initialized from documents and embeddings.
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.annoy.Annoy.html
477456661ba8-3
Return VectorStore initialized from documents and embeddings. async classmethod afrom_texts(texts: List[str], embedding: Embeddings, metadatas: Optional[List[dict]] = None, **kwargs: Any) → VST¶ Return VectorStore initialized from texts and embeddings. async amax_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. async amax_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. as_retriever(**kwargs: Any) → VectorStoreRetriever¶ async asearch(query: str, search_type: str, **kwargs: Any) → List[Document]¶ Return docs most similar to query using specified search type. async asimilarity_search(query: str, k: int = 4, **kwargs: Any) → List[Document]¶ Return docs most similar to query. async asimilarity_search_by_vector(embedding: List[float], k: int = 4, **kwargs: Any) → List[Document]¶ Return docs most similar to embedding vector. async asimilarity_search_with_relevance_scores(query: str, k: int = 4, **kwargs: Any) → List[Tuple[Document, float]]¶ Return docs most similar to query. delete(ids: List[str]) → Optional[bool]¶ Delete by vector ID. Parameters ids – List of ids to delete. Returns True if deletion is successful,
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.annoy.Annoy.html
477456661ba8-4
Parameters ids – List of ids to delete. Returns True if deletion is successful, False otherwise, None if not implemented. Return type Optional[bool] classmethod from_documents(documents: List[Document], embedding: Embeddings, **kwargs: Any) → VST¶ Return VectorStore initialized from documents and embeddings. classmethod from_embeddings(text_embeddings: List[Tuple[str, List[float]]], embedding: Embeddings, metadatas: Optional[List[dict]] = None, metric: str = 'angular', trees: int = 100, n_jobs: int = - 1, **kwargs: Any) → Annoy[source]¶ Construct Annoy wrapper from embeddings. Parameters text_embeddings – List of tuples of (text, embedding) embedding – Embedding function to use. metadatas – List of metadata dictionaries to associate with documents. metric – Metric to use for indexing. Defaults to “angular”. trees – Number of trees to use for indexing. Defaults to 100. n_jobs – Number of jobs to use for indexing. Defaults to -1 This is a user friendly interface that: Creates an in memory docstore with provided embeddings Initializes the Annoy database This is intended to be a quick way to get started. Example from langchain import Annoy from langchain.embeddings import OpenAIEmbeddings embeddings = OpenAIEmbeddings() text_embeddings = embeddings.embed_documents(texts) text_embedding_pairs = list(zip(texts, text_embeddings)) db = Annoy.from_embeddings(text_embedding_pairs, embeddings)
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.annoy.Annoy.html
477456661ba8-5
db = Annoy.from_embeddings(text_embedding_pairs, embeddings) classmethod from_texts(texts: List[str], embedding: Embeddings, metadatas: Optional[List[dict]] = None, metric: str = 'angular', trees: int = 100, n_jobs: int = - 1, **kwargs: Any) → Annoy[source]¶ Construct Annoy wrapper from raw documents. Parameters texts – List of documents to index. embedding – Embedding function to use. metadatas – List of metadata dictionaries to associate with documents. metric – Metric to use for indexing. Defaults to “angular”. trees – Number of trees to use for indexing. Defaults to 100. n_jobs – Number of jobs to use for indexing. Defaults to -1. This is a user friendly interface that: Embeds documents. Creates an in memory docstore Initializes the Annoy database This is intended to be a quick way to get started. Example from langchain import Annoy from langchain.embeddings import OpenAIEmbeddings embeddings = OpenAIEmbeddings() index = Annoy.from_texts(texts, embeddings) classmethod load_local(folder_path: str, embeddings: Embeddings) → Annoy[source]¶ Load Annoy index, docstore, and index_to_docstore_id to disk. Parameters folder_path – folder path to load index, docstore, and index_to_docstore_id from. 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[Document][source]¶ Return docs selected using the maximal marginal relevance.
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.annoy.Annoy.html
477456661ba8-6
Return docs selected using the maximal marginal relevance. Maximal marginal relevance optimizes for similarity to query AND diversity among selected documents. Parameters query – Text to look up documents similar to. 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 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[Document][source]¶ Return docs selected using the maximal marginal relevance. Maximal marginal relevance optimizes for similarity to query AND diversity among selected documents. Parameters embedding – Embedding to look up documents similar to. fetch_k – Number of Documents to fetch to pass to MMR algorithm. k – Number of Documents to return. Defaults to 4. 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. process_index_results(idxs: List[int], dists: List[float]) → List[Tuple[Document, float]][source]¶ Turns annoy results into a list of documents and scores. Parameters idxs – List of indices of the documents in the index. dists – List of distances of the documents in the index. Returns List of Documents and scores.
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.annoy.Annoy.html
477456661ba8-7
Returns List of Documents and scores. save_local(folder_path: str, prefault: bool = False) → None[source]¶ Save Annoy index, docstore, and index_to_docstore_id to disk. Parameters folder_path – folder path to save index, docstore, and index_to_docstore_id to. prefault – Whether to pre-load the index into memory. search(query: str, search_type: str, **kwargs: Any) → List[Document]¶ Return docs most similar to query using specified search type. similarity_search(query: str, k: int = 4, search_k: int = - 1, **kwargs: Any) → List[Document][source]¶ Return docs most similar to query. Parameters query – Text to look up documents similar to. k – Number of Documents to return. Defaults to 4. search_k – inspect up to search_k nodes which defaults to n_trees * n if not provided Returns List of Documents most similar to the query. similarity_search_by_index(docstore_index: int, k: int = 4, search_k: int = - 1, **kwargs: Any) → List[Document][source]¶ Return docs most similar to docstore_index. Parameters docstore_index – Index of document in docstore k – Number of Documents to return. Defaults to 4. search_k – inspect up to search_k nodes which defaults 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[Document][source]¶ Return docs most similar to embedding vector. Parameters embedding – Embedding to look up documents similar to.
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.annoy.Annoy.html
477456661ba8-8
Parameters embedding – Embedding to look up documents similar to. k – Number of Documents to return. Defaults to 4. search_k – inspect up to search_k nodes which defaults to n_trees * n if not provided Returns List of Documents most similar to the embedding. similarity_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 – input text k – Number of Documents to return. Defaults to 4. **kwargs – 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) similarity_search_with_score(query: str, k: int = 4, search_k: int = - 1) → List[Tuple[Document, float]][source]¶ Return docs most similar to query. Parameters query – Text to look up documents similar to. k – Number of Documents to return. Defaults to 4. search_k – inspect up to search_k nodes which defaults to n_trees * n if not provided Returns List of Documents most similar to the query and score for each similarity_search_with_score_by_index(docstore_index: int, k: int = 4, search_k: int = - 1) → List[Tuple[Document, float]][source]¶ Return docs most similar to query. Parameters query – Text to look up documents similar to. k – Number of Documents to return. Defaults to 4. search_k – inspect up to search_k nodes which defaults
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.annoy.Annoy.html
477456661ba8-9
search_k – inspect up to search_k nodes which defaults to n_trees * n if not provided 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[Document, float]][source]¶ Return docs most similar to query. Parameters query – Text to look up documents similar to. k – Number of Documents to return. Defaults to 4. search_k – inspect up to search_k nodes which defaults to n_trees * n if not provided Returns List of Documents most similar to the query and score for each
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.annoy.Annoy.html
23b16579c2b7-0
langchain.vectorstores.rocksetdb.Rockset¶ class langchain.vectorstores.rocksetdb.Rockset(client: Any, embeddings: Embeddings, collection_name: str, text_key: str, embedding_key: str)[source]¶ Bases: VectorStore Wrapper arpund Rockset vector database. To use, you should have the rockset python package installed. Note that to use this, the collection being used must already exist in your Rockset instance. You must also ensure you use a Rockset ingest transformation to apply VECTOR_ENFORCE on the column being used to store embedding_key in the collection. See: https://rockset.com/blog/introducing-vector-search-on-rockset/ for more details Everything below assumes commons Rockset workspace. TODO: Add support for workspace args. Example from langchain.vectorstores import Rockset from langchain.embeddings.openai import OpenAIEmbeddings import rockset # Make sure you use the right host (region) for your Rockset instance # and APIKEY has both read-write access to your collection. rs = rockset.RocksetClient(host=rockset.Regions.use1a1, api_key="***") collection_name = "langchain_demo" embeddings = OpenAIEmbeddings() vectorstore = Rockset(rs, collection_name, embeddings, "description", "description_embedding") Initialize with Rockset client. :param client: Rockset client object :param collection: Rockset collection to insert docs / query :param embeddings: Langchain Embeddings object to use to generate embedding for given text. Parameters text_key – column in Rockset collection to use to store the text embedding_key – column in Rockset collection to use to store the embedding. Note: We must apply VECTOR_ENFORCE() on this column via Rockset ingest transformation. Methods
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.rocksetdb.Rockset.html
23b16579c2b7-1
Rockset ingest transformation. Methods __init__(client, embeddings, ...) Initialize with Rockset client. :param client: Rockset client object :param collection: Rockset collection to insert docs / query :param embeddings: Langchain Embeddings object to use to generate embedding for given text. :param text_key: column in Rockset collection to use to store the text :param embedding_key: column in Rockset collection to use to store the embedding. Note: We must apply VECTOR_ENFORCE() on this column via Rockset ingest transformation. aadd_documents(documents, **kwargs) Run more documents through the embeddings and add to the vectorstore. aadd_texts(texts[, metadatas]) Run more texts through the embeddings and add to the vectorstore. add_documents(documents, **kwargs) Run more documents through the embeddings and add to the vectorstore. add_texts(texts[, metadatas, ids, batch_size]) Run more texts through the embeddings and add to the vectorstore afrom_documents(documents, embedding, **kwargs) Return VectorStore initialized from documents and embeddings. afrom_texts(texts, embedding[, metadatas]) Return VectorStore initialized from texts and embeddings. amax_marginal_relevance_search(query[, k, ...]) Return docs selected using the maximal marginal relevance. amax_marginal_relevance_search_by_vector(...) Return docs selected using the maximal marginal relevance. as_retriever(**kwargs) asearch(query, search_type, **kwargs) Return docs most similar to query using specified search type. asimilarity_search(query[, k]) Return docs most similar to query. asimilarity_search_by_vector(embedding[, k]) Return docs most similar to embedding vector.
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.rocksetdb.Rockset.html
23b16579c2b7-2
Return docs most similar to embedding vector. asimilarity_search_with_relevance_scores(query) Return docs most similar to query. delete(ids) Delete by vector ID. delete_texts(ids) Delete a list of docs from the Rockset collection from_documents(documents, embedding, **kwargs) Return VectorStore initialized from documents and embeddings. from_texts(texts, embedding[, metadatas, ...]) Create Rockset wrapper with existing texts. 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, distance_func, ...]) Same as similarity_search_with_relevance_scores but doesn't return the scores. similarity_search_by_vector(embedding[, k, ...]) Accepts a query_embedding (vector), and returns documents with similar embeddings. similarity_search_by_vector_with_relevance_scores(...) Accepts a query_embedding (vector), and returns documents with similar embeddings along with their relevance scores. similarity_search_with_relevance_scores(query) Perform a similarity search with Rockset class DistanceFunction(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶ Bases: Enum order_by() → str[source]¶ COSINE_SIM = 'COSINE_SIM'¶ DOT_PRODUCT = 'DOT_PRODUCT'¶ EUCLIDEAN_DIST = 'EUCLIDEAN_DIST'¶ async aadd_documents(documents: List[Document], **kwargs: Any) → List[str]¶
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.rocksetdb.Rockset.html
23b16579c2b7-3
Run more documents through the embeddings and add to the vectorstore. Parameters (List[Document] (documents) – Documents to add to the vectorstore. 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. add_documents(documents: List[Document], **kwargs: Any) → List[str]¶ Run more documents through the embeddings and add to the vectorstore. Parameters (List[Document] (documents) – Documents to add to the vectorstore. Returns List of IDs of the added texts. Return type List[str] add_texts(texts: Iterable[str], metadatas: Optional[List[dict]] = None, ids: Optional[List[str]] = None, batch_size: int = 32, **kwargs: Any) → List[str][source]¶ Run more texts through the embeddings and add to the vectorstore Args: 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. batch_size: Send documents in batches to rockset. Returns List of ids from adding the texts into the vectorstore. async classmethod afrom_documents(documents: List[Document], embedding: Embeddings, **kwargs: Any) → VST¶ Return VectorStore initialized from documents and embeddings. async classmethod afrom_texts(texts: List[str], embedding: Embeddings, metadatas: Optional[List[dict]] = None, **kwargs: Any) → VST¶ Return VectorStore initialized from texts and embeddings.
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.rocksetdb.Rockset.html
23b16579c2b7-4
Return VectorStore initialized from texts and embeddings. async amax_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. async amax_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. as_retriever(**kwargs: Any) → VectorStoreRetriever¶ async asearch(query: str, search_type: str, **kwargs: Any) → List[Document]¶ Return docs most similar to query using specified search type. async asimilarity_search(query: str, k: int = 4, **kwargs: Any) → List[Document]¶ Return docs most similar to query. async asimilarity_search_by_vector(embedding: List[float], k: int = 4, **kwargs: Any) → List[Document]¶ Return docs most similar to embedding vector. async asimilarity_search_with_relevance_scores(query: str, k: int = 4, **kwargs: Any) → List[Tuple[Document, float]]¶ Return docs most similar to query. delete(ids: List[str]) → Optional[bool]¶ Delete by vector ID. Parameters ids – List of ids to delete. Returns True if deletion is successful, False otherwise, None if not implemented. Return type Optional[bool] delete_texts(ids: List[str]) → None[source]¶ Delete a list of docs from the Rockset collection
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.rocksetdb.Rockset.html
23b16579c2b7-5
Delete a list of docs from the Rockset collection classmethod from_documents(documents: List[Document], embedding: Embeddings, **kwargs: Any) → VST¶ Return VectorStore initialized from documents and embeddings. classmethod from_texts(texts: List[str], embedding: Embeddings, metadatas: Optional[List[dict]] = None, client: Any = None, collection_name: str = '', text_key: str = '', embedding_key: str = '', ids: Optional[List[str]] = None, batch_size: int = 32, **kwargs: Any) → Rockset[source]¶ Create Rockset wrapper with existing texts. This is intended as a quicker way to get started. 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. Maximal marginal relevance optimizes for similarity to query AND diversity among selected documents. Parameters query – Text to look up documents similar to. 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 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[Document]¶ Return docs selected using the maximal marginal relevance. Maximal marginal relevance optimizes for similarity to query AND diversity
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.rocksetdb.Rockset.html
23b16579c2b7-6
Maximal marginal relevance optimizes for similarity to query AND diversity among selected documents. Parameters embedding – Embedding to look up documents similar to. 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 Documents selected by maximal marginal relevance. search(query: str, search_type: str, **kwargs: Any) → List[Document]¶ Return docs most similar to query using specified search type. similarity_search(query: str, k: int = 4, distance_func: DistanceFunction = DistanceFunction.COSINE_SIM, where_str: Optional[str] = None, **kwargs: Any) → List[Document][source]¶ Same as similarity_search_with_relevance_scores but doesn’t return the scores. similarity_search_by_vector(embedding: List[float], k: int = 4, distance_func: DistanceFunction = DistanceFunction.COSINE_SIM, where_str: Optional[str] = None, **kwargs: Any) → List[Document][source]¶ Accepts a query_embedding (vector), and returns documents with similar embeddings. similarity_search_by_vector_with_relevance_scores(embedding: List[float], k: int = 4, distance_func: DistanceFunction = DistanceFunction.COSINE_SIM, where_str: Optional[str] = None, **kwargs: Any) → List[Tuple[Document, float]][source]¶ Accepts a query_embedding (vector), and returns documents with similar embeddings along with their relevance scores.
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.rocksetdb.Rockset.html
23b16579c2b7-7
similar embeddings along with their relevance scores. similarity_search_with_relevance_scores(query: str, k: int = 4, distance_func: DistanceFunction = DistanceFunction.COSINE_SIM, where_str: Optional[str] = None, **kwargs: Any) → List[Tuple[Document, float]][source]¶ Perform a similarity search with Rockset Parameters query (str) – Text to look up documents similar to. distance_func (DistanceFunction) – how to compute distance between two vectors in Rockset. k (int, optional) – Top K neighbors to retrieve. Defaults to 4. where_str (Optional[str], optional) – Metadata filters supplied as a SQL where condition string. Defaults to None. eg. “price<=70.0 AND brand=’Nintendo’” NOTE – Please do not let end-user to fill this and always be aware of SQL injection. Returns List of documents with their relevance score Return type List[Tuple[Document, float]]
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.rocksetdb.Rockset.html
3be5a985bcde-0
langchain.vectorstores.chroma.Chroma¶ class langchain.vectorstores.chroma.Chroma(collection_name: str = 'langchain', embedding_function: Optional[Embeddings] = None, persist_directory: Optional[str] = None, client_settings: Optional[chromadb.config.Settings] = None, collection_metadata: Optional[Dict] = None, client: Optional[chromadb.Client] = None)[source]¶ Bases: VectorStore Wrapper around ChromaDB embeddings platform. To use, you should have the chromadb python package installed. Example from langchain.vectorstores import Chroma from langchain.embeddings.openai import OpenAIEmbeddings embeddings = OpenAIEmbeddings() vectorstore = Chroma("langchain_store", embeddings) Initialize with Chroma client. Methods __init__([collection_name, ...]) Initialize with Chroma client. aadd_documents(documents, **kwargs) Run more documents through the embeddings and add to the vectorstore. aadd_texts(texts[, metadatas]) Run more texts through the embeddings and add to the vectorstore. add_documents(documents, **kwargs) Run more documents through the embeddings and add to the vectorstore. add_texts(texts[, metadatas, ids]) Run more texts through the embeddings and add to the vectorstore. afrom_documents(documents, embedding, **kwargs) Return VectorStore initialized from documents and embeddings. afrom_texts(texts, embedding[, metadatas]) Return VectorStore initialized from texts and embeddings. amax_marginal_relevance_search(query[, k, ...]) Return docs selected using the maximal marginal relevance. amax_marginal_relevance_search_by_vector(...) Return docs selected using the maximal marginal relevance. as_retriever(**kwargs)
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.chroma.Chroma.html
3be5a985bcde-1
Return docs selected using the maximal marginal relevance. as_retriever(**kwargs) asearch(query, search_type, **kwargs) Return docs most similar to query using specified search type. 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 most similar to query. delete(ids) Delete by vector IDs. delete_collection() Delete the collection. from_documents(documents[, embedding, ids, ...]) Create a Chroma vectorstore from a list of documents. from_texts(texts[, embedding, metadatas, ...]) Create a Chroma vectorstore from a raw documents. get([ids, where, limit, offset, ...]) Gets the collection. 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. persist() Persist the collection. search(query, search_type, **kwargs) Return docs most similar to query using specified search type. similarity_search(query[, k, filter]) Run similarity search with Chroma. similarity_search_by_vector(embedding[, k, ...]) Return docs most similar to embedding vector. similarity_search_with_relevance_scores(query) Return docs and relevance scores in the range [0, 1]. similarity_search_with_score(query[, k, filter]) Run similarity search with Chroma with distance. update_document(document_id, document) Update a document in the collection.
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.chroma.Chroma.html
3be5a985bcde-2
update_document(document_id, document) Update a document in the collection. async aadd_documents(documents: List[Document], **kwargs: Any) → List[str]¶ Run more documents through the embeddings and add to the vectorstore. Parameters (List[Document] (documents) – Documents to add to the vectorstore. 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. add_documents(documents: List[Document], **kwargs: Any) → List[str]¶ Run more documents through the embeddings and add to the vectorstore. Parameters (List[Document] (documents) – Documents to add to the vectorstore. Returns List of IDs of the added texts. Return type List[str] add_texts(texts: Iterable[str], 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 texts (Iterable[str]) – Texts to add to the vectorstore. metadatas (Optional[List[dict]], optional) – Optional list of metadatas. ids (Optional[List[str]], optional) – Optional list of IDs. Returns List of IDs of the added texts. Return type List[str] async classmethod afrom_documents(documents: List[Document], embedding: Embeddings, **kwargs: Any) → VST¶ Return VectorStore initialized from documents and embeddings.
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.chroma.Chroma.html
3be5a985bcde-3
Return VectorStore initialized from documents and embeddings. async classmethod afrom_texts(texts: List[str], embedding: Embeddings, metadatas: Optional[List[dict]] = None, **kwargs: Any) → VST¶ Return VectorStore initialized from texts and embeddings. async amax_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. async amax_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. as_retriever(**kwargs: Any) → VectorStoreRetriever¶ async asearch(query: str, search_type: str, **kwargs: Any) → List[Document]¶ Return docs most similar to query using specified search type. async asimilarity_search(query: str, k: int = 4, **kwargs: Any) → List[Document]¶ Return docs most similar to query. async asimilarity_search_by_vector(embedding: List[float], k: int = 4, **kwargs: Any) → List[Document]¶ Return docs most similar to embedding vector. async asimilarity_search_with_relevance_scores(query: str, k: int = 4, **kwargs: Any) → List[Tuple[Document, float]]¶ Return docs most similar to query. delete(ids: List[str]) → None[source]¶ Delete by vector IDs. Parameters ids – List of ids to delete. delete_collection() → None[source]¶ Delete the collection.
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.chroma.Chroma.html
3be5a985bcde-4
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.Settings] = None, client: Optional[chromadb.Client] = None, **kwargs: Any) → Chroma[source]¶ Create a Chroma vectorstore from a list of documents. If a persist_directory is specified, the collection will be persisted there. Otherwise, the data will be ephemeral in-memory. Parameters collection_name (str) – Name of the collection to create. persist_directory (Optional[str]) – Directory to persist the collection. ids (Optional[List[str]]) – List of document IDs. Defaults to None. documents (List[Document]) – List of documents to add to the vectorstore. embedding (Optional[Embeddings]) – Embedding function. Defaults to None. client_settings (Optional[chromadb.config.Settings]) – Chroma client settings Returns Chroma vectorstore. Return type Chroma classmethod from_texts(texts: List[str], embedding: Optional[Embeddings] = None, metadatas: Optional[List[dict]] = None, ids: Optional[List[str]] = None, collection_name: str = 'langchain', persist_directory: Optional[str] = None, client_settings: Optional[chromadb.config.Settings] = None, client: Optional[chromadb.Client] = None, **kwargs: Any) → Chroma[source]¶ Create a Chroma vectorstore from a raw documents. If a persist_directory is specified, the collection will be persisted there. Otherwise, the data will be ephemeral in-memory. Parameters texts (List[str]) – List of texts to add to the collection.
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.chroma.Chroma.html
3be5a985bcde-5
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 None. metadatas (Optional[List[dict]]) – List of metadatas. Defaults to None. ids (Optional[List[str]]) – List of document IDs. Defaults to None. client_settings (Optional[chromadb.config.Settings]) – Chroma client settings Returns Chroma vectorstore. Return type Chroma get(ids: Optional[OneOrMany[ID]] = None, where: Optional[Where] = None, limit: Optional[int] = None, offset: Optional[int] = None, where_document: Optional[WhereDocument] = None, include: Optional[List[str]] = None) → Dict[str, Any][source]¶ Gets the collection. Parameters ids – The ids of the embeddings to get. Optional. where – A Where type dict used to filter results by. E.g. {“color” : “red”, “price”: 4.20}. Optional. limit – The number of documents to return. Optional. offset – The offset to start returning results from. Useful for paging results with limit. Optional. where_document – A WhereDocument type dict used to filter by the documents. E.g. {$contains: {“text”: “hello”}}. Optional. include – A list of what to include in the results. Can contain “embeddings”, “metadatas”, “documents”. Ids are always included. Defaults to [“metadatas”, “documents”]. Optional.
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.chroma.Chroma.html
3be5a985bcde-6
Defaults to [“metadatas”, “documents”]. Optional. max_marginal_relevance_search(query: str, k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, filter: Optional[Dict[str, str]] = None, **kwargs: Any) → List[Document][source]¶ Return docs selected using the maximal marginal relevance. Maximal marginal relevance optimizes for similarity to query AND diversity among selected documents. Parameters query – Text to look up documents similar to. 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. filter (Optional[Dict[str, str]]) – Filter by metadata. Defaults to None. 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[Document][source]¶ Return docs selected using the maximal marginal relevance. Maximal marginal relevance optimizes for similarity to query AND diversity among selected documents. Parameters embedding – Embedding to look up documents similar to. 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.
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.chroma.Chroma.html
3be5a985bcde-7
to maximum diversity and 1 to minimum diversity. Defaults to 0.5. filter (Optional[Dict[str, str]]) – Filter by metadata. Defaults to None. Returns List of Documents selected by maximal marginal relevance. persist() → None[source]¶ Persist the collection. This can be used to explicitly persist the data to disk. It will also be called automatically when the object is destroyed. search(query: str, search_type: str, **kwargs: Any) → List[Document]¶ Return docs most similar to query using specified search type. similarity_search(query: str, k: int = 4, filter: Optional[Dict[str, str]] = None, **kwargs: Any) → List[Document][source]¶ Run similarity search with Chroma. Parameters query (str) – Query text to search for. k (int) – Number of results to return. Defaults to 4. filter (Optional[Dict[str, str]]) – Filter by metadata. Defaults to None. Returns 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[Document][source]¶ Return docs most similar to embedding vector. :param embedding: Embedding to look up documents similar to. :type embedding: str :param k: Number of Documents to return. Defaults to 4. :type k: int :param filter: Filter by metadata. Defaults to None. :type filter: Optional[Dict[str, str]] Returns List of Documents most similar to the query vector.
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.chroma.Chroma.html
3be5a985bcde-8
Returns List of Documents most similar to the query vector. similarity_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 – input text k – Number of Documents to return. Defaults to 4. **kwargs – 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) similarity_search_with_score(query: str, k: int = 4, filter: Optional[Dict[str, str]] = None, **kwargs: Any) → List[Tuple[Document, float]][source]¶ Run similarity search with Chroma with distance. Parameters query (str) – Query text to search for. k (int) – Number of results to return. Defaults to 4. filter (Optional[Dict[str, str]]) – Filter by metadata. Defaults to None. Returns List of documents most similar to the query text and cosine distance in float for each. Lower score represents more similarity. Return type List[Tuple[Document, float]] update_document(document_id: str, document: Document) → None[source]¶ Update a document in the collection. Parameters document_id (str) – ID of the document to update. document (Document) – Document to update.
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.chroma.Chroma.html
b96e2bf28975-0
langchain.vectorstores.singlestoredb.DistanceStrategy¶ class langchain.vectorstores.singlestoredb.DistanceStrategy(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶ Bases: str, Enum Enumerator of the Distance strategies for SingleStoreDB. Methods __init__(*args, **kwds) capitalize() Return a capitalized version of the string. casefold() Return a version of the string suitable for caseless comparisons. center(width[, fillchar]) Return a centered string of length width. count(sub[, start[, end]]) Return the number of non-overlapping occurrences of substring sub in string S[start:end]. encode([encoding, errors]) Encode the string using the codec registered for encoding. endswith(suffix[, start[, end]]) Return True if S ends with the specified suffix, False otherwise. expandtabs([tabsize]) Return a copy where all tab characters are expanded using spaces. find(sub[, start[, end]]) Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. format(*args, **kwargs) Return a formatted version of S, using substitutions from args and kwargs. format_map(mapping) Return a formatted version of S, using substitutions from mapping. index(sub[, start[, end]]) Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. isalnum() Return True if the string is an alpha-numeric string, False otherwise. isalpha() Return True if the string is an alphabetic string, False otherwise. isascii() Return True if all characters in the string are ASCII, False otherwise. isdecimal() Return True if the string is a decimal string, False otherwise.
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.singlestoredb.DistanceStrategy.html
b96e2bf28975-1
isdecimal() Return True if the string is a decimal string, False otherwise. isdigit() Return True if the string is a digit string, False otherwise. isidentifier() Return True if the string is a valid Python identifier, False otherwise. islower() Return True if the string is a lowercase string, False otherwise. isnumeric() Return True if the string is a numeric string, False otherwise. isprintable() Return True if the string is printable, False otherwise. isspace() Return True if the string is a whitespace string, False otherwise. istitle() Return True if the string is a title-cased string, False otherwise. isupper() Return True if the string is an uppercase string, False otherwise. join(iterable, /) Concatenate any number of strings. ljust(width[, fillchar]) Return a left-justified string of length width. lower() Return a copy of the string converted to lowercase. lstrip([chars]) Return a copy of the string with leading whitespace removed. maketrans Return a translation table usable for str.translate(). partition(sep, /) Partition the string into three parts using the given separator. removeprefix(prefix, /) Return a str with the given prefix string removed if present. removesuffix(suffix, /) Return a str with the given suffix string removed if present. replace(old, new[, count]) Return a copy with all occurrences of substring old replaced by new. rfind(sub[, start[, end]]) Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. rindex(sub[, start[, end]]) Return the highest index in S where substring sub is found, such that sub is contained within S[start:end].
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.singlestoredb.DistanceStrategy.html
b96e2bf28975-2
rjust(width[, fillchar]) Return a right-justified string of length width. rpartition(sep, /) Partition the string into three parts using the given separator. rsplit([sep, maxsplit]) Return a list of the substrings in the string, using sep as the separator string. rstrip([chars]) Return a copy of the string with trailing whitespace removed. split([sep, maxsplit]) Return a list of the substrings in the string, using sep as the separator string. splitlines([keepends]) Return a list of the lines in the string, breaking at line boundaries. startswith(prefix[, start[, end]]) Return True if S starts with the specified prefix, False otherwise. strip([chars]) Return a copy of the string with leading and trailing whitespace removed. swapcase() Convert uppercase characters to lowercase and lowercase characters to uppercase. title() Return a version of the string where each word is titlecased. translate(table, /) Replace each character in the string using the given translation table. upper() Return a copy of the string converted to uppercase. zfill(width, /) Pad a numeric string with zeros on the left, to fill a field of the given width. Attributes EUCLIDEAN_DISTANCE DOT_PRODUCT capitalize()¶ Return a capitalized version of the string. More specifically, make the first character have upper case and the rest lower case. casefold()¶ Return a version of the string suitable for caseless comparisons. center(width, fillchar=' ', /)¶ Return a centered string of length width. Padding is done using the specified fill character (default is a space). count(sub[, start[, end]]) → int¶ Return the number of non-overlapping occurrences of substring sub in
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.singlestoredb.DistanceStrategy.html
b96e2bf28975-3
Return the number of non-overlapping occurrences of substring sub in string S[start:end]. Optional arguments start and end are interpreted as in slice notation. encode(encoding='utf-8', errors='strict')¶ Encode the string using the codec registered for encoding. encodingThe encoding in which to encode the string. errorsThe error handling scheme to use for encoding errors. The default is ‘strict’ meaning that encoding errors raise a UnicodeEncodeError. Other possible values are ‘ignore’, ‘replace’ and ‘xmlcharrefreplace’ as well as any other name registered with codecs.register_error that can handle UnicodeEncodeErrors. endswith(suffix[, start[, end]]) → bool¶ Return True if S ends with the specified suffix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. suffix can also be a tuple of strings to try. expandtabs(tabsize=8)¶ Return a copy where all tab characters are expanded using spaces. If tabsize is not given, a tab size of 8 characters is assumed. find(sub[, start[, end]]) → int¶ Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation. Return -1 on failure. format(*args, **kwargs) → str¶ Return a formatted version of S, using substitutions from args and kwargs. The substitutions are identified by braces (‘{’ and ‘}’). format_map(mapping) → str¶ Return a formatted version of S, using substitutions from mapping. The substitutions are identified by braces (‘{’ and ‘}’). index(sub[, start[, end]]) → int¶ Return the lowest index in S where substring sub is found,
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.singlestoredb.DistanceStrategy.html
b96e2bf28975-4
Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation. Raises ValueError when the substring is not found. isalnum()¶ Return True if the string is an alpha-numeric string, False otherwise. A string is alpha-numeric if all characters in the string are alpha-numeric and there is at least one character in the string. isalpha()¶ Return True if the string is an alphabetic string, False otherwise. A string is alphabetic if all characters in the string are alphabetic and there is at least one character in the string. isascii()¶ Return True if all characters in the string are ASCII, False otherwise. ASCII characters have code points in the range U+0000-U+007F. Empty string is ASCII too. isdecimal()¶ Return True if the string is a decimal string, False otherwise. A string is a decimal string if all characters in the string are decimal and there is at least one character in the string. isdigit()¶ Return True if the string is a digit string, False otherwise. A string is a digit string if all characters in the string are digits and there is at least one character in the string. isidentifier()¶ Return True if the string is a valid Python identifier, False otherwise. Call keyword.iskeyword(s) to test whether string s is a reserved identifier, such as “def” or “class”. islower()¶ Return True if the string is a lowercase string, False otherwise. A string is lowercase if all cased characters in the string are lowercase and there is at least one cased character in the string. isnumeric()¶ Return True if the string is a numeric string, False otherwise.
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.singlestoredb.DistanceStrategy.html
b96e2bf28975-5
isnumeric()¶ Return True if the string is a numeric string, False otherwise. A string is numeric if all characters in the string are numeric and there is at least one character in the string. isprintable()¶ Return True if the string is printable, False otherwise. A string is printable if all of its characters are considered printable in repr() or if it is empty. isspace()¶ Return True if the string is a whitespace string, False otherwise. A string is whitespace if all characters in the string are whitespace and there is at least one character in the string. istitle()¶ Return True if the string is a title-cased string, False otherwise. In a title-cased string, upper- and title-case characters may only follow uncased characters and lowercase characters only cased ones. isupper()¶ Return True if the string is an uppercase string, False otherwise. A string is uppercase if all cased characters in the string are uppercase and there is at least one cased character in the string. join(iterable, /)¶ Concatenate any number of strings. The string whose method is called is inserted in between each given string. The result is returned as a new string. Example: ‘.’.join([‘ab’, ‘pq’, ‘rs’]) -> ‘ab.pq.rs’ ljust(width, fillchar=' ', /)¶ Return a left-justified string of length width. Padding is done using the specified fill character (default is a space). lower()¶ Return a copy of the string converted to lowercase. lstrip(chars=None, /)¶ Return a copy of the string with leading whitespace removed. If chars is given and not None, remove characters in chars instead. static maketrans()¶ Return a translation table usable for str.translate().
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.singlestoredb.DistanceStrategy.html
b96e2bf28975-6
static maketrans()¶ Return a translation table usable for str.translate(). If there is only one argument, it must be a dictionary mapping Unicode ordinals (integers) or characters to Unicode ordinals, strings or None. Character keys will be then converted to ordinals. If there are two arguments, they must be strings of equal length, and in the resulting dictionary, each character in x will be mapped to the character at the same position in y. If there is a third argument, it must be a string, whose characters will be mapped to None in the result. partition(sep, /)¶ Partition the string into three parts using the given separator. This will search for the separator in the string. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it. If the separator is not found, returns a 3-tuple containing the original string and two empty strings. removeprefix(prefix, /)¶ Return a str with the given prefix string removed if present. If the string starts with the prefix string, return string[len(prefix):]. Otherwise, return a copy of the original string. removesuffix(suffix, /)¶ Return a str with the given suffix string removed if present. If the string ends with the suffix string and that suffix is not empty, return string[:-len(suffix)]. Otherwise, return a copy of the original string. replace(old, new, count=- 1, /)¶ Return a copy with all occurrences of substring old replaced by new. countMaximum number of occurrences to replace. -1 (the default value) means replace all occurrences. If the optional argument count is given, only the first count occurrences are replaced. rfind(sub[, start[, end]]) → int¶
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.singlestoredb.DistanceStrategy.html
b96e2bf28975-7
replaced. rfind(sub[, start[, end]]) → int¶ Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation. Return -1 on failure. rindex(sub[, start[, end]]) → int¶ Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation. Raises ValueError when the substring is not found. rjust(width, fillchar=' ', /)¶ Return a right-justified string of length width. Padding is done using the specified fill character (default is a space). rpartition(sep, /)¶ Partition the string into three parts using the given separator. This will search for the separator in the string, starting at the end. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it. If the separator is not found, returns a 3-tuple containing two empty strings and the original string. rsplit(sep=None, maxsplit=- 1)¶ Return a list of the substrings in the string, using sep as the separator string. sepThe separator used to split the string. When set to None (the default value), will split on any whitespace character (including \n \r \t \f and spaces) and will discard empty strings from the result. maxsplitMaximum number of splits (starting from the left). -1 (the default value) means no limit. Splitting starts at the end of the string and works to the front. rstrip(chars=None, /)¶ Return a copy of the string with trailing whitespace removed.
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.singlestoredb.DistanceStrategy.html
b96e2bf28975-8
rstrip(chars=None, /)¶ Return a copy of the string with trailing whitespace removed. If chars is given and not None, remove characters in chars instead. split(sep=None, maxsplit=- 1)¶ Return a list of the substrings in the string, using sep as the separator string. sepThe separator used to split the string. When set to None (the default value), will split on any whitespace character (including \n \r \t \f and spaces) and will discard empty strings from the result. maxsplitMaximum number of splits (starting from the left). -1 (the default value) means no limit. Note, str.split() is mainly useful for data that has been intentionally delimited. With natural text that includes punctuation, consider using the regular expression module. splitlines(keepends=False)¶ Return a list of the lines in the string, breaking at line boundaries. Line breaks are not included in the resulting list unless keepends is given and true. startswith(prefix[, start[, end]]) → bool¶ Return True if S starts with the specified prefix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. prefix can also be a tuple of strings to try. strip(chars=None, /)¶ Return a copy of the string with leading and trailing whitespace removed. If chars is given and not None, remove characters in chars instead. swapcase()¶ Convert uppercase characters to lowercase and lowercase characters to uppercase. title()¶ Return a version of the string where each word is titlecased. More specifically, words start with uppercased characters and all remaining cased characters have lower case. translate(table, /)¶ Replace each character in the string using the given translation table.
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.singlestoredb.DistanceStrategy.html
b96e2bf28975-9
translate(table, /)¶ Replace each character in the string using the given translation table. tableTranslation table, which must be a mapping of Unicode ordinals to Unicode ordinals, strings, or None. The table must implement lookup/indexing via __getitem__, for instance a dictionary or list. If this operation raises LookupError, the character is left untouched. Characters mapped to None are deleted. upper()¶ Return a copy of the string converted to uppercase. zfill(width, /)¶ Pad a numeric string with zeros on the left, to fill a field of the given width. The string is never truncated. DOT_PRODUCT = 'DOT_PRODUCT'¶ EUCLIDEAN_DISTANCE = 'EUCLIDEAN_DISTANCE'¶
https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.singlestoredb.DistanceStrategy.html
6223bab0d66c-0
langchain.server.main¶ langchain.server.main() → None[source]¶ Run the langchain server locally.
https://api.python.langchain.com/en/latest/server/langchain.server.main.html
e977b9b9e310-0
langchain.example_generator.generate_example¶ langchain.example_generator.generate_example(examples: List[dict], llm: BaseLanguageModel, prompt_template: PromptTemplate) → str[source]¶ Return another example given a list of examples for a prompt.
https://api.python.langchain.com/en/latest/example_generator/langchain.example_generator.generate_example.html
a6a81a1dc973-0
langchain.text_splitter.TokenTextSplitter¶ class langchain.text_splitter.TokenTextSplitter(encoding_name: str = 'gpt2', model_name: Optional[str] = None, allowed_special: Union[Literal['all'], AbstractSet[str]] = {}, disallowed_special: Union[Literal['all'], Collection[str]] = 'all', **kwargs: Any)[source]¶ Bases: TextSplitter Implementation of splitting text that looks at tokens. Create a new TextSplitter. Methods __init__([encoding_name, model_name, ...]) Create a new TextSplitter. atransform_documents(documents, **kwargs) Asynchronously transform a sequence of documents by splitting them. create_documents(texts[, metadatas]) Create documents from a list of texts. from_huggingface_tokenizer(tokenizer, **kwargs) Text splitter that uses HuggingFace tokenizer to count length. from_tiktoken_encoder([encoding_name, ...]) Text splitter that uses tiktoken encoder to count length. split_documents(documents) Split documents. split_text(text) Split text into multiple components. transform_documents(documents, **kwargs) Transform sequence of documents by splitting them. async atransform_documents(documents: Sequence[Document], **kwargs: Any) → Sequence[Document]¶ Asynchronously transform a sequence of documents by splitting them. create_documents(texts: List[str], metadatas: Optional[List[dict]] = None) → List[Document]¶ Create documents from a list of texts. classmethod from_huggingface_tokenizer(tokenizer: Any, **kwargs: Any) → TextSplitter¶ Text splitter that uses HuggingFace tokenizer to count length.
https://api.python.langchain.com/en/latest/text_splitter/langchain.text_splitter.TokenTextSplitter.html
a6a81a1dc973-1
Text splitter that uses HuggingFace tokenizer to count length. classmethod from_tiktoken_encoder(encoding_name: str = 'gpt2', model_name: Optional[str] = None, allowed_special: Union[Literal['all'], AbstractSet[str]] = {}, disallowed_special: Union[Literal['all'], Collection[str]] = 'all', **kwargs: Any) → TS¶ Text splitter that uses tiktoken encoder to count length. split_documents(documents: Iterable[Document]) → List[Document]¶ Split documents. split_text(text: str) → List[str][source]¶ Split text into multiple components. transform_documents(documents: Sequence[Document], **kwargs: Any) → Sequence[Document]¶ Transform sequence of documents by splitting them.
https://api.python.langchain.com/en/latest/text_splitter/langchain.text_splitter.TokenTextSplitter.html
663da3e72249-0
langchain.text_splitter.LatexTextSplitter¶ class langchain.text_splitter.LatexTextSplitter(**kwargs: Any)[source]¶ Bases: RecursiveCharacterTextSplitter Attempts to split the text along Latex-formatted layout elements. Initialize a LatexTextSplitter. Methods __init__(**kwargs) Initialize a LatexTextSplitter. atransform_documents(documents, **kwargs) Asynchronously transform a sequence of documents by splitting them. create_documents(texts[, metadatas]) Create documents from a list of texts. from_huggingface_tokenizer(tokenizer, **kwargs) Text splitter that uses HuggingFace tokenizer to count length. from_language(language, **kwargs) from_tiktoken_encoder([encoding_name, ...]) Text splitter that uses tiktoken encoder to count length. get_separators_for_language(language) split_documents(documents) Split documents. split_text(text) Split text into multiple components. transform_documents(documents, **kwargs) Transform sequence of documents by splitting them. async atransform_documents(documents: Sequence[Document], **kwargs: Any) → Sequence[Document]¶ Asynchronously transform a sequence of documents by splitting them. create_documents(texts: List[str], metadatas: Optional[List[dict]] = None) → List[Document]¶ Create documents from a list of texts. classmethod from_huggingface_tokenizer(tokenizer: Any, **kwargs: Any) → TextSplitter¶ Text splitter that uses HuggingFace tokenizer to count length. classmethod from_language(language: Language, **kwargs: Any) → RecursiveCharacterTextSplitter¶
https://api.python.langchain.com/en/latest/text_splitter/langchain.text_splitter.LatexTextSplitter.html
663da3e72249-1
classmethod from_language(language: Language, **kwargs: Any) → RecursiveCharacterTextSplitter¶ classmethod from_tiktoken_encoder(encoding_name: str = 'gpt2', model_name: Optional[str] = None, allowed_special: Union[Literal['all'], AbstractSet[str]] = {}, disallowed_special: Union[Literal['all'], Collection[str]] = 'all', **kwargs: Any) → TS¶ Text splitter that uses tiktoken encoder to count length. static get_separators_for_language(language: Language) → List[str]¶ split_documents(documents: Iterable[Document]) → List[Document]¶ Split documents. split_text(text: str) → List[str]¶ Split text into multiple components. transform_documents(documents: Sequence[Document], **kwargs: Any) → Sequence[Document]¶ Transform sequence of documents by splitting them.
https://api.python.langchain.com/en/latest/text_splitter/langchain.text_splitter.LatexTextSplitter.html
8146be2c8908-0
langchain.text_splitter.SpacyTextSplitter¶ class langchain.text_splitter.SpacyTextSplitter(separator: str = '\n\n', pipeline: str = 'en_core_web_sm', **kwargs: Any)[source]¶ Bases: TextSplitter Implementation of splitting text that looks at sentences using Spacy. Initialize the spacy text splitter. Methods __init__([separator, pipeline]) Initialize the spacy text splitter. atransform_documents(documents, **kwargs) Asynchronously transform a sequence of documents by splitting them. create_documents(texts[, metadatas]) Create documents from a list of texts. from_huggingface_tokenizer(tokenizer, **kwargs) Text splitter that uses HuggingFace tokenizer to count length. from_tiktoken_encoder([encoding_name, ...]) Text splitter that uses tiktoken encoder to count length. split_documents(documents) Split documents. split_text(text) Split incoming text and return chunks. transform_documents(documents, **kwargs) Transform sequence of documents by splitting them. async atransform_documents(documents: Sequence[Document], **kwargs: Any) → Sequence[Document]¶ Asynchronously transform a sequence of documents by splitting them. create_documents(texts: List[str], metadatas: Optional[List[dict]] = None) → List[Document]¶ Create documents from a list of texts. classmethod from_huggingface_tokenizer(tokenizer: Any, **kwargs: Any) → TextSplitter¶ Text splitter that uses HuggingFace tokenizer to count length.
https://api.python.langchain.com/en/latest/text_splitter/langchain.text_splitter.SpacyTextSplitter.html
8146be2c8908-1
Text splitter that uses HuggingFace tokenizer to count length. classmethod from_tiktoken_encoder(encoding_name: str = 'gpt2', model_name: Optional[str] = None, allowed_special: Union[Literal['all'], AbstractSet[str]] = {}, disallowed_special: Union[Literal['all'], Collection[str]] = 'all', **kwargs: Any) → TS¶ Text splitter that uses tiktoken encoder to count length. split_documents(documents: Iterable[Document]) → List[Document]¶ Split documents. split_text(text: str) → List[str][source]¶ Split incoming text and return chunks. transform_documents(documents: Sequence[Document], **kwargs: Any) → Sequence[Document]¶ Transform sequence of documents by splitting them.
https://api.python.langchain.com/en/latest/text_splitter/langchain.text_splitter.SpacyTextSplitter.html
a0d8865850a3-0
langchain.text_splitter.CharacterTextSplitter¶ class langchain.text_splitter.CharacterTextSplitter(separator: str = '\n\n', **kwargs: Any)[source]¶ Bases: TextSplitter Implementation of splitting text that looks at characters. Create a new TextSplitter. Methods __init__([separator]) Create a new TextSplitter. atransform_documents(documents, **kwargs) Asynchronously transform a sequence of documents by splitting them. create_documents(texts[, metadatas]) Create documents from a list of texts. from_huggingface_tokenizer(tokenizer, **kwargs) Text splitter that uses HuggingFace tokenizer to count length. from_tiktoken_encoder([encoding_name, ...]) Text splitter that uses tiktoken encoder to count length. split_documents(documents) Split documents. split_text(text) Split incoming text and return chunks. transform_documents(documents, **kwargs) Transform sequence of documents by splitting them. async atransform_documents(documents: Sequence[Document], **kwargs: Any) → Sequence[Document]¶ Asynchronously transform a sequence of documents by splitting them. create_documents(texts: List[str], metadatas: Optional[List[dict]] = None) → List[Document]¶ Create documents from a list of texts. classmethod from_huggingface_tokenizer(tokenizer: Any, **kwargs: Any) → TextSplitter¶ Text splitter that uses HuggingFace tokenizer to count length. classmethod from_tiktoken_encoder(encoding_name: str = 'gpt2', model_name: Optional[str] = None, allowed_special: Union[Literal['all'], AbstractSet[str]] = {}, disallowed_special: Union[Literal['all'], Collection[str]] = 'all', **kwargs: Any) → TS¶
https://api.python.langchain.com/en/latest/text_splitter/langchain.text_splitter.CharacterTextSplitter.html
a0d8865850a3-1
Text splitter that uses tiktoken encoder to count length. split_documents(documents: Iterable[Document]) → List[Document]¶ Split documents. split_text(text: str) → List[str][source]¶ Split incoming text and return chunks. transform_documents(documents: Sequence[Document], **kwargs: Any) → Sequence[Document]¶ Transform sequence of documents by splitting them.
https://api.python.langchain.com/en/latest/text_splitter/langchain.text_splitter.CharacterTextSplitter.html
3f1510e149ad-0
langchain.text_splitter.RecursiveCharacterTextSplitter¶ class langchain.text_splitter.RecursiveCharacterTextSplitter(separators: Optional[List[str]] = None, keep_separator: bool = True, **kwargs: Any)[source]¶ Bases: TextSplitter Implementation of splitting text that looks at characters. Recursively tries to split by different characters to find one that works. Create a new TextSplitter. Methods __init__([separators, keep_separator]) Create a new TextSplitter. atransform_documents(documents, **kwargs) Asynchronously transform a sequence of documents by splitting them. create_documents(texts[, metadatas]) Create documents from a list of texts. from_huggingface_tokenizer(tokenizer, **kwargs) Text splitter that uses HuggingFace tokenizer to count length. from_language(language, **kwargs) from_tiktoken_encoder([encoding_name, ...]) Text splitter that uses tiktoken encoder to count length. get_separators_for_language(language) split_documents(documents) Split documents. split_text(text) Split text into multiple components. transform_documents(documents, **kwargs) Transform sequence of documents by splitting them. async atransform_documents(documents: Sequence[Document], **kwargs: Any) → Sequence[Document]¶ Asynchronously transform a sequence of documents by splitting them. create_documents(texts: List[str], metadatas: Optional[List[dict]] = None) → List[Document]¶ Create documents from a list of texts. classmethod from_huggingface_tokenizer(tokenizer: Any, **kwargs: Any) → TextSplitter¶ Text splitter that uses HuggingFace tokenizer to count length. classmethod from_language(language: Language, **kwargs: Any) → RecursiveCharacterTextSplitter[source]¶
https://api.python.langchain.com/en/latest/text_splitter/langchain.text_splitter.RecursiveCharacterTextSplitter.html
3f1510e149ad-1
classmethod from_tiktoken_encoder(encoding_name: str = 'gpt2', model_name: Optional[str] = None, allowed_special: Union[Literal['all'], AbstractSet[str]] = {}, disallowed_special: Union[Literal['all'], Collection[str]] = 'all', **kwargs: Any) → TS¶ Text splitter that uses tiktoken encoder to count length. static get_separators_for_language(language: Language) → List[str][source]¶ split_documents(documents: Iterable[Document]) → List[Document]¶ Split documents. split_text(text: str) → List[str][source]¶ Split text into multiple components. transform_documents(documents: Sequence[Document], **kwargs: Any) → Sequence[Document]¶ Transform sequence of documents by splitting them.
https://api.python.langchain.com/en/latest/text_splitter/langchain.text_splitter.RecursiveCharacterTextSplitter.html
d3e4abd19129-0
langchain.text_splitter.NLTKTextSplitter¶ class langchain.text_splitter.NLTKTextSplitter(separator: str = '\n\n', **kwargs: Any)[source]¶ Bases: TextSplitter Implementation of splitting text that looks at sentences using NLTK. Initialize the NLTK splitter. Methods __init__([separator]) Initialize the NLTK splitter. atransform_documents(documents, **kwargs) Asynchronously transform a sequence of documents by splitting them. create_documents(texts[, metadatas]) Create documents from a list of texts. from_huggingface_tokenizer(tokenizer, **kwargs) Text splitter that uses HuggingFace tokenizer to count length. from_tiktoken_encoder([encoding_name, ...]) Text splitter that uses tiktoken encoder to count length. split_documents(documents) Split documents. split_text(text) Split incoming text and return chunks. transform_documents(documents, **kwargs) Transform sequence of documents by splitting them. async atransform_documents(documents: Sequence[Document], **kwargs: Any) → Sequence[Document]¶ Asynchronously transform a sequence of documents by splitting them. create_documents(texts: List[str], metadatas: Optional[List[dict]] = None) → List[Document]¶ Create documents from a list of texts. classmethod from_huggingface_tokenizer(tokenizer: Any, **kwargs: Any) → TextSplitter¶ Text splitter that uses HuggingFace tokenizer to count length. classmethod from_tiktoken_encoder(encoding_name: str = 'gpt2', model_name: Optional[str] = None, allowed_special: Union[Literal['all'], AbstractSet[str]] = {}, disallowed_special: Union[Literal['all'], Collection[str]] = 'all', **kwargs: Any) → TS¶
https://api.python.langchain.com/en/latest/text_splitter/langchain.text_splitter.NLTKTextSplitter.html
d3e4abd19129-1
Text splitter that uses tiktoken encoder to count length. split_documents(documents: Iterable[Document]) → List[Document]¶ Split documents. split_text(text: str) → List[str][source]¶ Split incoming text and return chunks. transform_documents(documents: Sequence[Document], **kwargs: Any) → Sequence[Document]¶ Transform sequence of documents by splitting them.
https://api.python.langchain.com/en/latest/text_splitter/langchain.text_splitter.NLTKTextSplitter.html
c7a7d6abc034-0
langchain.text_splitter.MarkdownTextSplitter¶ class langchain.text_splitter.MarkdownTextSplitter(**kwargs: Any)[source]¶ Bases: RecursiveCharacterTextSplitter Attempts to split the text along Markdown-formatted headings. Initialize a MarkdownTextSplitter. Methods __init__(**kwargs) Initialize a MarkdownTextSplitter. atransform_documents(documents, **kwargs) Asynchronously transform a sequence of documents by splitting them. create_documents(texts[, metadatas]) Create documents from a list of texts. from_huggingface_tokenizer(tokenizer, **kwargs) Text splitter that uses HuggingFace tokenizer to count length. from_language(language, **kwargs) from_tiktoken_encoder([encoding_name, ...]) Text splitter that uses tiktoken encoder to count length. get_separators_for_language(language) split_documents(documents) Split documents. split_text(text) Split text into multiple components. transform_documents(documents, **kwargs) Transform sequence of documents by splitting them. async atransform_documents(documents: Sequence[Document], **kwargs: Any) → Sequence[Document]¶ Asynchronously transform a sequence of documents by splitting them. create_documents(texts: List[str], metadatas: Optional[List[dict]] = None) → List[Document]¶ Create documents from a list of texts. classmethod from_huggingface_tokenizer(tokenizer: Any, **kwargs: Any) → TextSplitter¶ Text splitter that uses HuggingFace tokenizer to count length. classmethod from_language(language: Language, **kwargs: Any) → RecursiveCharacterTextSplitter¶
https://api.python.langchain.com/en/latest/text_splitter/langchain.text_splitter.MarkdownTextSplitter.html
c7a7d6abc034-1
classmethod from_language(language: Language, **kwargs: Any) → RecursiveCharacterTextSplitter¶ classmethod from_tiktoken_encoder(encoding_name: str = 'gpt2', model_name: Optional[str] = None, allowed_special: Union[Literal['all'], AbstractSet[str]] = {}, disallowed_special: Union[Literal['all'], Collection[str]] = 'all', **kwargs: Any) → TS¶ Text splitter that uses tiktoken encoder to count length. static get_separators_for_language(language: Language) → List[str]¶ split_documents(documents: Iterable[Document]) → List[Document]¶ Split documents. split_text(text: str) → List[str]¶ Split text into multiple components. transform_documents(documents: Sequence[Document], **kwargs: Any) → Sequence[Document]¶ Transform sequence of documents by splitting them.
https://api.python.langchain.com/en/latest/text_splitter/langchain.text_splitter.MarkdownTextSplitter.html
591574c832a2-0
langchain.text_splitter.PythonCodeTextSplitter¶ class langchain.text_splitter.PythonCodeTextSplitter(**kwargs: Any)[source]¶ Bases: RecursiveCharacterTextSplitter Attempts to split the text along Python syntax. Initialize a PythonCodeTextSplitter. Methods __init__(**kwargs) Initialize a PythonCodeTextSplitter. atransform_documents(documents, **kwargs) Asynchronously transform a sequence of documents by splitting them. create_documents(texts[, metadatas]) Create documents from a list of texts. from_huggingface_tokenizer(tokenizer, **kwargs) Text splitter that uses HuggingFace tokenizer to count length. from_language(language, **kwargs) from_tiktoken_encoder([encoding_name, ...]) Text splitter that uses tiktoken encoder to count length. get_separators_for_language(language) split_documents(documents) Split documents. split_text(text) Split text into multiple components. transform_documents(documents, **kwargs) Transform sequence of documents by splitting them. async atransform_documents(documents: Sequence[Document], **kwargs: Any) → Sequence[Document]¶ Asynchronously transform a sequence of documents by splitting them. create_documents(texts: List[str], metadatas: Optional[List[dict]] = None) → List[Document]¶ Create documents from a list of texts. classmethod from_huggingface_tokenizer(tokenizer: Any, **kwargs: Any) → TextSplitter¶ Text splitter that uses HuggingFace tokenizer to count length. classmethod from_language(language: Language, **kwargs: Any) → RecursiveCharacterTextSplitter¶
https://api.python.langchain.com/en/latest/text_splitter/langchain.text_splitter.PythonCodeTextSplitter.html
591574c832a2-1
classmethod from_language(language: Language, **kwargs: Any) → RecursiveCharacterTextSplitter¶ classmethod from_tiktoken_encoder(encoding_name: str = 'gpt2', model_name: Optional[str] = None, allowed_special: Union[Literal['all'], AbstractSet[str]] = {}, disallowed_special: Union[Literal['all'], Collection[str]] = 'all', **kwargs: Any) → TS¶ Text splitter that uses tiktoken encoder to count length. static get_separators_for_language(language: Language) → List[str]¶ split_documents(documents: Iterable[Document]) → List[Document]¶ Split documents. split_text(text: str) → List[str]¶ Split text into multiple components. transform_documents(documents: Sequence[Document], **kwargs: Any) → Sequence[Document]¶ Transform sequence of documents by splitting them.
https://api.python.langchain.com/en/latest/text_splitter/langchain.text_splitter.PythonCodeTextSplitter.html
da13464d2782-0
langchain.text_splitter.LineType¶ class langchain.text_splitter.LineType[source]¶ Bases: TypedDict Line type as typed dict. Methods __init__(*args, **kwargs) 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() Attributes metadata content 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.¶
https://api.python.langchain.com/en/latest/text_splitter/langchain.text_splitter.LineType.html
da13464d2782-1
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¶ content: str¶ metadata: Dict[str, str]¶
https://api.python.langchain.com/en/latest/text_splitter/langchain.text_splitter.LineType.html
b475742761ac-0
langchain.text_splitter.SentenceTransformersTokenTextSplitter¶ class langchain.text_splitter.SentenceTransformersTokenTextSplitter(chunk_overlap: int = 50, model_name: str = 'sentence-transformers/all-mpnet-base-v2', tokens_per_chunk: Optional[int] = None, **kwargs: Any)[source]¶ Bases: TextSplitter Implementation of splitting text that looks at tokens. Create a new TextSplitter. Methods __init__([chunk_overlap, model_name, ...]) Create a new TextSplitter. atransform_documents(documents, **kwargs) Asynchronously transform a sequence of documents by splitting them. count_tokens(*, text) create_documents(texts[, metadatas]) Create documents from a list of texts. from_huggingface_tokenizer(tokenizer, **kwargs) Text splitter that uses HuggingFace tokenizer to count length. from_tiktoken_encoder([encoding_name, ...]) Text splitter that uses tiktoken encoder to count length. split_documents(documents) Split documents. split_text(text) Split text into multiple components. transform_documents(documents, **kwargs) Transform sequence of documents by splitting them. async atransform_documents(documents: Sequence[Document], **kwargs: Any) → Sequence[Document]¶ Asynchronously transform a sequence of documents by splitting them. count_tokens(*, text: str) → int[source]¶ create_documents(texts: List[str], metadatas: Optional[List[dict]] = None) → List[Document]¶ Create documents from a list of texts. classmethod from_huggingface_tokenizer(tokenizer: Any, **kwargs: Any) → TextSplitter¶ Text splitter that uses HuggingFace tokenizer to count length.
https://api.python.langchain.com/en/latest/text_splitter/langchain.text_splitter.SentenceTransformersTokenTextSplitter.html
b475742761ac-1
Text splitter that uses HuggingFace tokenizer to count length. classmethod from_tiktoken_encoder(encoding_name: str = 'gpt2', model_name: Optional[str] = None, allowed_special: Union[Literal['all'], AbstractSet[str]] = {}, disallowed_special: Union[Literal['all'], Collection[str]] = 'all', **kwargs: Any) → TS¶ Text splitter that uses tiktoken encoder to count length. split_documents(documents: Iterable[Document]) → List[Document]¶ Split documents. split_text(text: str) → List[str][source]¶ Split text into multiple components. transform_documents(documents: Sequence[Document], **kwargs: Any) → Sequence[Document]¶ Transform sequence of documents by splitting them.
https://api.python.langchain.com/en/latest/text_splitter/langchain.text_splitter.SentenceTransformersTokenTextSplitter.html
54d1af11852d-0
langchain.text_splitter.HeaderType¶ class langchain.text_splitter.HeaderType[source]¶ Bases: TypedDict Header type as typed dict. Methods __init__(*args, **kwargs) 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() Attributes level name data 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.¶
https://api.python.langchain.com/en/latest/text_splitter/langchain.text_splitter.HeaderType.html
54d1af11852d-1
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¶ data: str¶ level: int¶ name: str¶
https://api.python.langchain.com/en/latest/text_splitter/langchain.text_splitter.HeaderType.html
63a7e2ef2e39-0
langchain.text_splitter.split_text_on_tokens¶ langchain.text_splitter.split_text_on_tokens(*, text: str, tokenizer: Tokenizer) → List[str][source]¶ Split incoming text and return chunks.
https://api.python.langchain.com/en/latest/text_splitter/langchain.text_splitter.split_text_on_tokens.html