id
stringlengths
14
15
text
stringlengths
44
2.47k
source
stringlengths
61
181
2c58abcc3b7c-2
return getattr(self, item) class Config: env_file = ".env" env_prefix = "clickhouse_" env_file_encoding = "utf-8" [docs]class Clickhouse(VectorStore): """`ClickHouse VectorSearch` vector store. You need a `clickhouse-connect` python package, and a valid account to connect to Clic...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/clickhouse.html
2c58abcc3b7c-3
assert self.config assert self.config.host and self.config.port assert ( self.config.column_map and self.config.database and self.config.table and self.config.metric ) for k in ["id", "embedding", "document", "metadata", "uuid"]: ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/clickhouse.html
2c58abcc3b7c-4
""" self.dim = dim self.BS = "\\" self.must_escape = ("\\", "'") self.embedding_function = embedding self.dist_order = "ASC" # Only support ConsingDistance and L2Distance # Create a connection to clickhouse self.client = get_client( host=self.config.h...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/clickhouse.html
2c58abcc3b7c-5
self.client.command(_insert_query) [docs] def add_texts( self, texts: Iterable[str], metadatas: Optional[List[dict]] = None, batch_size: int = 32, ids: Optional[Iterable[str]] = None, **kwargs: Any, ) -> List[str]: """Insert more texts through the embedding...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/clickhouse.html
2c58abcc3b7c-6
) transac.append(v) if len(transac) == batch_size: if t: t.join() t = Thread(target=self._insert, args=[transac, keys]) t.start() transac = [] if len(transac) > 0: ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/clickhouse.html
2c58abcc3b7c-7
Other keyword arguments will pass into [clickhouse-connect](https://clickhouse.com/docs/en/integrations/python#clickhouse-connect-driver-api) Returns: ClickHouse Index """ ctx = cls(embedding, config, **kwargs) ctx.add_texts(texts, ids=text_ids, batch_size=bat...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/clickhouse.html
2c58abcc3b7c-8
if where_str: where_str = f"PREWHERE {where_str}" else: where_str = "" settings_strs = [] if self.config.index_query_params: for k in self.config.index_query_params: settings_strs.append(f"SETTING {k}={self.config.index_query_params[k]}") ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/clickhouse.html
2c58abcc3b7c-9
self.embedding_function.embed_query(query), k, where_str, **kwargs ) [docs] def similarity_search_by_vector( self, embedding: List[float], k: int = 4, where_str: Optional[str] = None, **kwargs: Any, ) -> List[Document]: """Perform a similarity search with C...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/clickhouse.html
2c58abcc3b7c-10
) -> List[Tuple[Document, float]]: """Perform a similarity search with ClickHouse Args: query (str): query string k (int, optional): Top K neighbors to retrieve. Defaults to 4. where_str (Optional[str], optional): where condition string. ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/clickhouse.html
1acb732ef70c-0
Source code for langchain.vectorstores.cassandra from __future__ import annotations import typing import uuid from typing import ( Any, Callable, Dict, Iterable, List, Optional, Tuple, Type, TypeVar, Union, ) import numpy as np if typing.TYPE_CHECKING: from cassandra.cluster ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/cassandra.html
1acb732ef70c-1
return filter_dict def _get_embedding_dimension(self) -> int: if self._embedding_dimension is None: self._embedding_dimension = len( self.embedding.embed_query("This is a sample sentence.") ) return self._embedding_dimension [docs] def __init__( sel...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/cassandra.html
1acb732ef70c-2
so here the final score transformation is not reversing the interval: """ return self._dont_flip_the_cos_score [docs] def delete_collection(self) -> None: """ Just an alias for `clear` (to better align with other VectorStore implementations). """ self.clear() [...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/cassandra.html
1acb732ef70c-3
ids (Optional[List[str]], optional): Optional list of IDs. batch_size (int): Number of concurrent requests to send to the server. ttl_seconds (Optional[int], optional): Optional time-to-live for the added texts. Returns: List[str]: List of IDs of the added tex...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/cassandra.html
1acb732ef70c-4
) -> List[Tuple[Document, float, str]]: """Return docs most similar to embedding vector. Args: embedding (str): Embedding to look up documents similar to. k (int): Number of Documents to return. Defaults to 4. Returns: List of (Document, score, id), the most s...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/cassandra.html
1acb732ef70c-5
self, embedding: List[float], k: int = 4, filter: Optional[Dict[str, str]] = None, ) -> List[Tuple[Document, float]]: """Return docs most similar to embedding vector. Args: embedding (str): Embedding to look up documents similar to. k (int): Number of ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/cassandra.html
1acb732ef70c-6
self, query: str, k: int = 4, filter: Optional[Dict[str, str]] = None, ) -> List[Tuple[Document, float]]: embedding_vector = self.embedding.embed_query(query) return self.similarity_search_with_score_by_vector( embedding_vector, k, filter=f...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/cassandra.html
1acb732ef70c-7
mmrChosenIndices = maximal_marginal_relevance( np.array(embedding, dtype=np.float32), [pfHit["embedding_vector"] for pfHit in prefetchHits], k=k, lambda_mult=lambda_mult, ) mmrHits = [ pfHit for pfIndex, pfHit in enumerate(prefetchH...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/cassandra.html
1acb732ef70c-8
embedding_vector, k, fetch_k, lambda_mult=lambda_mult, filter=filter, ) [docs] @classmethod def from_texts( cls: Type[CVST], texts: List[str], embedding: Embeddings, metadatas: Optional[List[dict]] = None, batch_size:...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/cassandra.html
1acb732ef70c-9
table_name: str = kwargs["table_name"] return cls.from_texts( texts=texts, metadatas=metadatas, embedding=embedding, session=session, keyspace=keyspace, table_name=table_name, )
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/cassandra.html
b5cb05ebca5f-0
Source code for langchain.vectorstores.zep from __future__ import annotations import logging import warnings from dataclasses import asdict, dataclass from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Optional, Tuple import numpy as np from langchain.docstore.document import Document from langchain.schema.em...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/zep.html
b5cb05ebca5f-1
Args: api_url (str): The URL of the Zep API. collection_name (str): The name of the collection in the Zep store. api_key (Optional[str]): The API key for the Zep API. config (Optional[CollectionConfig]): The configuration for the collection. Required if the collection does no...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/zep.html
b5cb05ebca5f-2
@property def embeddings(self) -> Optional[Embeddings]: """Access the query embedding object if available.""" return self._embedding def _load_collection(self) -> DocumentCollection: """ Load the collection from the Zep backend. """ from zep_python import NotFound...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/zep.html
b5cb05ebca5f-3
embeddings = self._embedding.embed_documents(list(texts)) if self._collection and self._collection.embedding_dimensions != len( embeddings[0] ): raise ValueError( "The embedding dimensions of the collection and the embedding" ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/zep.html
b5cb05ebca5f-4
"collection should be an instance of a Zep DocumentCollection" ) documents = self._generate_documents_to_add(texts, metadatas, document_ids) uuids = self._collection.add_documents(documents) return uuids [docs] async def aadd_texts( self, texts: Iterable[str], ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/zep.html
b5cb05ebca5f-5
"search_type to be 'similarity' or 'mmr'." ) [docs] async def asearch( self, query: str, search_type: str, metadata: Optional[Dict[str, Any]] = None, k: int = 3, **kwargs: Any, ) -> List[Document]: """Return docs most similar to query using spec...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/zep.html
b5cb05ebca5f-6
**kwargs: Any, ) -> List[Tuple[Document, float]]: """Run similarity search with distance.""" return self._similarity_search_with_relevance_scores( query, k=k, metadata=metadata, **kwargs ) def _similarity_search_with_relevance_scores( self, query: str, ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/zep.html
b5cb05ebca5f-7
) return [ ( Document( page_content=doc.content, metadata=doc.metadata, ), doc.score or 0.0, ) for doc in results ] [docs] async def asimilarity_search_with_relevance_scores( ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/zep.html
b5cb05ebca5f-8
results = await self.asimilarity_search_with_relevance_scores( query, k, metadata=metadata, **kwargs ) return [doc for doc, _ in results] [docs] def similarity_search_by_vector( self, embedding: List[float], k: int = 4, metadata: Optional[Dict[str, Any]] = ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/zep.html
b5cb05ebca5f-9
embedding=embedding, limit=k, metadata=metadata, **kwargs ) return [ Document( page_content=doc.content, metadata=doc.metadata, ) for doc in results ] def _max_marginal_relevance_selection( self, query_vector...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/zep.html
b5cb05ebca5f-10
of diversity among the results with 0 corresponding to maximum diversity and 1 to minimum diversity. Defaults to 0.5. metadata: Optional, metadata to filter the resulting set of retrieved docs Returns: List of Documents selected by maximal ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/zep.html
b5cb05ebca5f-11
embedding=query_vector, limit=k, metadata=metadata, **kwargs ) else: results, query_vector = await self._collection.asearch_return_query_vector( query, limit=k, metadata=metadata, **kwargs ) return self._max_marginal_relevance_selection( qu...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/zep.html
b5cb05ebca5f-12
embedding=embedding, limit=k, metadata=metadata, **kwargs ) return self._max_marginal_relevance_selection( embedding, results, k=k, lambda_mult=lambda_mult ) [docs] async def amax_marginal_relevance_search_by_vector( self, embedding: List[float], k: int = 4...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/zep.html
b5cb05ebca5f-13
texts (List[str]): The list of texts to add to the vectorstore. embedding (Optional[Embeddings]): Optional embedding function to use to embed the texts. metadatas (Optional[List[Dict[str, Any]]]): Optional list of metadata associated with the texts. coll...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/zep.html
337556dc637f-0
Source code for langchain.vectorstores.mongodb_atlas from __future__ import annotations import logging from typing import ( TYPE_CHECKING, Any, Dict, Generator, Iterable, List, Optional, Tuple, TypeVar, Union, ) import numpy as np from langchain.docstore.document import Document ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/mongodb_atlas.html
337556dc637f-1
text_key: str = "text", embedding_key: str = "embedding", ): """ Args: collection: MongoDB collection to add the texts to. embedding: Text embedding model to use. text_key: MongoDB field that will contain the text for each document. ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/mongodb_atlas.html
337556dc637f-2
return cls(collection, embedding, **kwargs) [docs] def add_texts( self, texts: Iterable[str], metadatas: Optional[List[Dict[str, Any]]] = None, **kwargs: Any, ) -> List: """Run more texts through the embeddings and add to the vectorstore. Args: texts: I...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/mongodb_atlas.html
337556dc637f-3
{self._text_key: t, self._embedding_key: embedding, **m} for t, m, embedding in zip(texts, metadatas, embeddings) ] # insert the documents in MongoDB Atlas insert_result = self._collection.insert_many(to_insert) # type: ignore return insert_result.inserted_ids def _simil...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/mongodb_atlas.html
337556dc637f-4
pre_filter: Optional[Dict] = None, post_filter_pipeline: Optional[List[Dict]] = None, ) -> List[Tuple[Document, float]]: """Return MongoDB documents most similar to the given query and their scores. Uses the knnBeta Operator available in MongoDB Atlas Search. This feature is in early...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/mongodb_atlas.html
337556dc637f-5
Uses the knnBeta Operator available in MongoDB Atlas Search. This feature is in early access and available only for evaluation purposes, to validate functionality, and to gather feedback from a small closed group of early access users. It is not recommended for production deployments as we ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/mongodb_atlas.html
337556dc637f-6
Args: query: Text to look up documents similar to. k: (Optional) number of documents to return. Defaults to 4. fetch_k: (Optional) number of documents to fetch before passing to MMR algorithm. Defaults to 20. lambda_mult: Number between 0 and 1 that determ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/mongodb_atlas.html
337556dc637f-7
**kwargs: Any, ) -> MongoDBAtlasVectorSearch: """Construct a `MongoDB Atlas Vector Search` vector store from raw documents. This is a user-friendly interface that: 1. Embeds documents. 2. Adds the documents to a provided MongoDB Atlas Vector Search index (Luce...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/mongodb_atlas.html
9dba8091508e-0
Source code for langchain.vectorstores.clarifai from __future__ import annotations import logging import os import traceback from concurrent.futures import ThreadPoolExecutor from typing import Any, Iterable, List, Optional, Tuple import requests from langchain.docstore.document import Document from langchain.schema.em...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/clarifai.html
9dba8091508e-1
ValueError: If user ID, app ID or personal access token is not provided. """ try: from clarifai.auth.helper import DEFAULT_BASE, ClarifaiAuthHelper from clarifai.client import create_stub except ImportError: raise ImportError( "Could not import...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/clarifai.html
9dba8091508e-2
) -> List[str]: """Post text to Clarifai and return the ID of the input. Args: text (str): Text to post. metadata (dict): Metadata to post. Returns: str: ID of the input. """ try: from clarifai_grpc.grpc.api import resources_pb2, se...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/clarifai.html
9dba8091508e-3
) input_ids = [] for input in post_inputs_response.inputs: input_ids.append(input.id) return input_ids [docs] def add_texts( self, texts: Iterable[str], metadatas: Optional[List[dict]] = None, ids: Optional[List[str]] = None, **kwargs: Any, ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/clarifai.html
9dba8091508e-4
result_ids = self._post_texts_as_inputs(batch_texts, batch_metadatas) input_ids.extend(result_ids) logger.debug(f"Input {result_ids} posted successfully.") except Exception as error: logger.warning(f"Post inputs failed: {error}") traceback.prin...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/clarifai.html
9dba8091508e-5
user_app_id=self._userDataObject, searches=[ resources_pb2.Search( query=resources_pb2.Query( ranks=[ resources_pb2.Rank( annotation=resources_pb2.Annotation( ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/clarifai.html
9dba8091508e-6
off input: {hit.input.id}, text: {requested_text[:125]}" ) return (Document(page_content=requested_text, metadata=metadata), hit.score) # Iterate over hits and retrieve metadata and text futures = [executor.submit(hit_to_document, hit) for hit in hits] docs_and_scores = [...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/clarifai.html
9dba8091508e-7
texts (List[str]): List of texts to add. pat (Optional[str]): Personal access token. Defaults to None. number_of_docs (Optional[int]): Number of documents to return during vector search. Defaults to None. api_base (Optional[str]): API base. Defaults to None. m...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/clarifai.html
9dba8091508e-8
during vector search. Defaults to None. api_base (Optional[str]): API base. Defaults to None. Returns: Clarifai: Clarifai vectorstore. """ texts = [doc.page_content for doc in documents] metadatas = [doc.metadata for doc in documents] return cls.from_texts...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/clarifai.html
f799e335b8a8-0
Source code for langchain.vectorstores.vald """Wrapper around Vald vector database.""" from __future__ import annotations from typing import Any, Iterable, List, Optional, Tuple, Type import numpy as np from langchain.docstore.document import Document from langchain.schema.embeddings import Embeddings from langchain.sc...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/vald.html
f799e335b8a8-1
metadatas: Optional[List[dict]] = None, skip_strict_exist_check: bool = False, **kwargs: Any, ) -> List[str]: """ Args: skip_strict_exist_check: Deprecated. This is not used basically. """ try: import grpc from vald.v1.payload impor...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/vald.html
f799e335b8a8-2
) -> Optional[bool]: """ Args: skip_strict_exist_check: Deprecated. This is not used basically. """ try: import grpc from vald.v1.payload import payload_pb2 from vald.v1.vald import remove_pb2_grpc except ImportError: ra...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/vald.html
f799e335b8a8-3
docs.append(doc) return docs [docs] def similarity_search_with_score( self, query: str, k: int = 4, radius: float = -1.0, epsilon: float = 0.01, timeout: int = 3000000000, **kwargs: Any, ) -> List[Tuple[Document, float]]: emb = self._embeddi...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/vald.html
f799e335b8a8-4
from vald.v1.vald import search_pb2_grpc except ImportError: raise ValueError( "Could not import vald-client-python python package. " "Please install it with `pip install vald-client-python`." ) channel = grpc.insecure_channel(self.target, options=...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/vald.html
f799e335b8a8-5
timeout=timeout, lambda_mult=lambda_mult, ) return docs [docs] def max_marginal_relevance_search_by_vector( self, embedding: List[float], k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, radius: float = -1.0, epsilon: float =...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/vald.html
f799e335b8a8-6
docs.append(doc) mmr = maximal_marginal_relevance( np.array(embedding), embs, lambda_mult=lambda_mult, k=k, ) channel.close() return [docs[i] for i in mmr] [docs] @classmethod def from_texts( cls: Type[Vald], texts: L...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/vald.html
f799e335b8a8-7
# ) -> List[str]: # pass # # def _select_relevance_score_fn(self) -> Callable[[float], float]: # pass # # def _similarity_search_with_relevance_scores( # self, # query: str, # k: int = 4, # **kwargs: Any, # ) -> List[Tuple[Document, float]]: # pass # # def...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/vald.html
2fa4c578ba06-0
Source code for langchain.vectorstores.qdrant from __future__ import annotations import asyncio import functools import uuid import warnings from itertools import islice from operator import itemgetter from typing import ( TYPE_CHECKING, Any, AsyncGenerator, Callable, Dict, Generator, Iterab...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
2fa4c578ba06-1
# by removing the first letter from the method name. For example, # if the async method is called ``aaad_texts``, the synchronous method # will be called ``aad_texts``. sync_method = functools.partial( getattr(self, method.__name__[1:]), *args, **kwargs ) ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
2fa4c578ba06-2
"Please install it with `pip install qdrant-client`." ) if not isinstance(client, qdrant_client.QdrantClient): raise ValueError( f"client should be an instance of qdrant_client.QdrantClient, " f"got {type(client)}" ) if embeddings is No...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
2fa4c578ba06-3
def embeddings(self) -> Optional[Embeddings]: return self._embeddings [docs] def add_texts( self, texts: Iterable[str], metadatas: Optional[List[dict]] = None, ids: Optional[Sequence[str]] = None, batch_size: int = 64, **kwargs: Any, ) -> List[str]: ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
2fa4c578ba06-4
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. Ids have to be uuid-like strings. batch_size: ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
2fa4c578ba06-5
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...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
2fa4c578ba06-6
filter: Optional[MetadataFilter] = None, **kwargs: Any, ) -> List[Document]: """Return docs most similar to query. Args: query: Text to look up documents similar to. k: Number of Documents to return. Defaults to 4. filter: Filter by metadata. Defaults to N...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
2fa4c578ba06-7
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: ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
2fa4c578ba06-8
Args: 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. ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
2fa4c578ba06-9
**kwargs, ) [docs] def similarity_search_by_vector( self, 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, ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
2fa4c578ba06-10
- 'all' - query all replicas, and return values present in all replicas **kwargs: Any other named arguments to pass through to QdrantClient.search() Returns: List of Documents most similar to the query. """ results = self.similarity_search_with_score_by_ve...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
2fa4c578ba06-11
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...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
2fa4c578ba06-12
**kwargs: Any, ) -> List[Tuple[Document, float]]: """Return docs most similar to embedding vector. Args: 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. ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
2fa4c578ba06-13
"filters directly: " "https://qdrant.tech/documentation/concepts/filtering/", DeprecationWarning, ) qdrant_filter = self._qdrant_filter_from_dict(filter) else: qdrant_filter = filter query_vector = embedding if self.vector_name ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
2fa4c578ba06-14
from qdrant_client import grpc # noqa from qdrant_client.conversions.conversion import RestToGrpc from qdrant_client.http import models as rest if filter is not None and isinstance(filter, dict): warnings.warn( "Using dict as a `filter` is deprecated. Please use qdra...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
2fa4c578ba06-15
offset: int = 0, score_threshold: Optional[float] = None, consistency: Optional[common_types.ReadConsistency] = None, **kwargs: Any, ) -> List[Tuple[Document, float]]: """Return docs most similar to embedding vector. Args: embedding: Embedding vector to look up do...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
2fa4c578ba06-16
""" response = await self._asearch_with_score_by_vector( embedding, k=k, filter=filter, search_params=search_params, offset=offset, score_threshold=score_threshold, consistency=consistency, **kwargs, ) ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
2fa4c578ba06-17
filter: Filter by metadata. Defaults to None. search_params: Additional search params 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 hig...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
2fa4c578ba06-18
lambda_mult: float = 0.5, filter: Optional[MetadataFilter] = None, search_params: Optional[common_types.SearchParams] = None, score_threshold: Optional[float] = None, consistency: Optional[common_types.ReadConsistency] = None, **kwargs: Any, ) -> List[Document]: """Re...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
2fa4c578ba06-19
all of them - 'all' - query all replicas, and return values present in all replicas **kwargs: Any other named arguments to pass through to QdrantClient.async_grpc_points.Search(). Returns: List of Documents selected by maximal marginal rele...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
2fa4c578ba06-20
of diversity among the results with 0 corresponding to maximum diversity and 1 to minimum diversity. Defaults to 0.5. filter: Filter by metadata. Defaults to None. search_params: Additional search params score_threshold: ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
2fa4c578ba06-21
self, embedding: List[float], k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, filter: Optional[MetadataFilter] = None, search_params: Optional[common_types.SearchParams] = None, score_threshold: Optional[float] = None, consistency: Optional[common...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
2fa4c578ba06-22
- int - number of replicas to query, values should present in all queried replicas - 'majority' - query all replicas, but return values present in the majority of replicas - 'quorum' - query the majority of replicas, return values pr...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
2fa4c578ba06-23
among selected documents. Args: 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 t...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
2fa4c578ba06-24
results = self.client.search( collection_name=self.collection_name, query_vector=query_vector, query_filter=filter, search_params=search_params, limit=fetch_k, with_payload=True, with_vectors=True, score_threshold=score_thre...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
2fa4c578ba06-25
among selected documents. Args: 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 t...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
2fa4c578ba06-26
) for i in mmr_selected ] [docs] def delete(self, ids: Optional[List[str]] = None, **kwargs: Any) -> Optional[bool]: """Delete by vector ID or other criteria. Args: ids: List of ids to delete. **kwargs: Other keyword arguments that subclasses might use. ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
2fa4c578ba06-27
vector_name: Optional[str] = VECTOR_NAME, 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.HnswCon...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
2fa4c578ba06-28
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:...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
2fa4c578ba06-29
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. ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
2fa4c578ba06-30
2. Initializes the Qdrant database as an in-memory docstore by default (and overridable to a remote docstore) 3. Adds the text embeddings to the Qdrant database This is intended to be a quick way to get started. Example: .. code-block:: python from langchai...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
2fa4c578ba06-31
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] = N...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
2fa4c578ba06-32
Args: 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. ids: ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
2fa4c578ba06-33
'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 ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
2fa4c578ba06-34
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 ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
2fa4c578ba06-35
content_payload_key, metadata_payload_key, vector_name, shard_number, replication_factor, write_consistency_factor, on_disk_payload, hnsw_config, optimizers_config, wal_config, quantization_config, ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
2fa4c578ba06-36
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_typ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
2fa4c578ba06-37
if force_recreate: raise ValueError # Get the vector configuration of the existing collection and vector, if it # was specified. If the old configuration does not match the current one, # an exception is being thrown. collection_info = client.get_collectio...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
2fa4c578ba06-38
f"Existing Qdrant collection {collection_name} doesn't use named " f"vectors. If you want to reuse it, please set `vector_name` to " f"`None`. If you want to recreate the collection, set " f"`force_recreate` parameter to `True`." ) ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
2fa4c578ba06-39
on_disk=on_disk, ) # If vector name was provided, we're going to use the named vectors feature # with just a single vector. if vector_name is not None: vectors_config = { # type: ignore[assignment] vector_name: vectors_config, ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
2fa4c578ba06-40
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 = CONTENT_KEY, metadata_payload_key: str = METADAT...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
2fa4c578ba06-41
vector_size = len(partial_embeddings[0]) collection_name = collection_name or uuid.uuid4().hex distance_func = distance_func.upper() client = qdrant_client.QdrantClient( location=location, url=url, port=port, grpc_port=grpc_port, prefer...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html