id
stringlengths
14
15
text
stringlengths
49
2.47k
source
stringlengths
61
166
a3995490ca87-2
4. Click "Reset password" 5. Follow the prompts to reset the password The format for Elastic Cloud URLs is https://username:password@cluster_id.region_id.gcp.cloud.es.io:9243. Example: .. code-block:: python from langchain import ElasticVectorSearch from langchain.embeddi...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/elastic_vector_search.html
a3995490ca87-3
) self.embedding = embedding self.index_name = index_name _ssl_verify = ssl_verify or {} try: self.client = elasticsearch.Elasticsearch(elasticsearch_url, **_ssl_verify) except ValueError as e: raise ValueError( f"Your elasticsearch client ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/elastic_vector_search.html
a3995490ca87-4
# check to see if the index already exists try: self.client.indices.get(index=self.index_name) except NotFoundError: # TODO would be nice to create index before embedding, # just to save expensive steps for last self.create_index(self.client, self.index_na...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/elastic_vector_search.html
a3995490ca87-5
"""Return docs most similar to query. Args: query: Text to look up documents similar to. k: Number of Documents to return. Defaults to 4. Returns: List of Documents most similar to the query. """ embedding = self.embedding.embed_query(query) sc...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/elastic_vector_search.html
a3995490ca87-6
embeddings = OpenAIEmbeddings() elastic_vector_search = ElasticVectorSearch.from_texts( texts, embeddings, elasticsearch_url="http://localhost:9200" ) """ elasticsearch_url = get_from_dict_or_env( kwa...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/elastic_vector_search.html
a3995490ca87-7
) return response [docs] def delete(self, ids: Optional[List[str]] = None, **kwargs: Any) -> None: """Delete by vector IDs. Args: ids: List of ids to delete. """ if ids is None: raise ValueError("No ids provided to delete.") # TODO: Check if thi...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/elastic_vector_search.html
a3995490ca87-8
>>> from embeddings import Embeddings >>> embedding = Embeddings.load('glove') >>> es_search = ElasticKnnSearch('my_index', embedding) >>> es_search.add_texts(['Hello world!', 'Another text']) >>> results = es_search.knn_search('Hello') [(Document(page_content='Hello world!', met...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/elastic_vector_search.html
a3995490ca87-9
raise ValueError( """Either provide a pre-existing Elasticsearch connection, \ or valid credentials for creating a new connection.""" ) @staticmethod def _default_knn_mapping( dims: int, similarity: Optional[str] = "dot_product" ) -> Dict: ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/elastic_vector_search.html
a3995490ca87-10
} } else: raise ValueError( "Either `query_vector` or `model_id` must be provided, but not both." ) return knn [docs] def similarity_search( self, query: str, k: int = 4, filter: Optional[dict] = None, **kwargs: Any ) -> List[Document]: ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/elastic_vector_search.html
a3995490ca87-11
k (int, optional): The number of nearest neighbors to return. query_vector (List[float], optional): The query vector to search for. model_id (str, optional): The ID of the model to use for transforming the query text into a vector. size (int, optional): The number of ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/elastic_vector_search.html
a3995490ca87-12
metadata=hit["fields"] if fields else {}, ), hit["_score"], ) for hit in hits ] return docs_and_scores [docs] def knn_hybrid_search( self, query: Optional[str] = None, k: Optional[int] = 10, query_vector: Optional...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/elastic_vector_search.html
a3995490ca87-13
results. fields (List[Mapping[str, Any]], optional): The fields to return in the search results. page_content (str, optional): The name of the field that contains the page content. Returns: A list of tuples, where each tuple contains a Document...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/elastic_vector_search.html
a3995490ca87-14
), hit["_score"], ) for hit in hits ] return docs_and_scores [docs] def create_knn_index(self, mapping: Dict) -> None: """ Create a new k-NN index in Elasticsearch. Args: mapping (Dict): The mapping to use for the new index. ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/elastic_vector_search.html
a3995490ca87-15
optional_args = {} if similarity is not None: optional_args["similarity"] = similarity mapping = self._default_knn_mapping(dims=dims, **optional_args) self.create_knn_index(mapping) embeddings = self.embedding.embed_documents(list(texts)) # body = [] ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/elastic_vector_search.html
a3995490ca87-16
Returns: A new ElasticKnnSearch instance. """ index_name = kwargs.get("index_name", str(uuid.uuid4())) es_connection = kwargs.get("es_connection") es_cloud_id = kwargs.get("es_cloud_id") es_user = kwargs.get("es_user") es_password = kwargs.get("es_password") ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/elastic_vector_search.html
9f60b6d53214-0
Source code for langchain.vectorstores.redis """Wrapper around Redis vector database.""" from __future__ import annotations import json import logging import uuid from typing import ( TYPE_CHECKING, Any, Callable, Dict, Iterable, List, Literal, Mapping, Optional, Tuple, Type,...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/redis.html
9f60b6d53214-1
) >= int(module["ver"]): return # otherwise raise error error_message = ( "Redis cannot be used as a vector database without RediSearch >=2.4" "Please head to https://redis.io/docs/stack/search/quick_start/" "to know more about installing the RediSearch module within Redis St...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/redis.html
9f60b6d53214-2
embedding_function=embeddings.embed_query, ) To use a redis replication setup with multiple redis server and redis sentinels set "redis_url" to "redis+sentinel://" scheme. With this url format a path is needed holding the name of the redis service within the sentinels to get the correct redi...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/redis.html
9f60b6d53214-3
except ValueError as e: raise ValueError(f"Redis failed to connect: {e}") self.client = redis_client self.content_key = content_key self.metadata_key = metadata_key self.vector_key = vector_key self.distance_metric = distance_metric self.relevance_score_fn = r...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/redis.html
9f60b6d53214-4
"DISTANCE_METRIC": self.distance_metric, }, ), ) prefix = _redis_prefix(self.index_name) # Create Redis Index self.client.ft(self.index_name).create_index( fields=schema, definition=IndexDefinition(prefix...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/redis.html
9f60b6d53214-5
# Use provided values by default or fallback key = keys_or_ids[i] if keys_or_ids else _redis_key(prefix) metadata = metadatas[i] if metadatas else {} embedding = embeddings[i] if embeddings else self.embedding_function(text) pipeline.hset( key, ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/redis.html
9f60b6d53214-6
Args: query (str): The query text for which to find similar documents. k (int): The number of documents to return. Default is 4. score_threshold (float): The minimum matching score required for a document to be considered a match. Defaults to 0.2. Beca...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/redis.html
9f60b6d53214-7
self, query: str, k: int = 4 ) -> List[Tuple[Document, float]]: """Return docs most similar to query. Args: query: Text to look up documents similar to. k: Number of Documents to return. Defaults to 4. Returns: List of Documents most similar to the query a...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/redis.html
9f60b6d53214-8
**kwargs: Any, ) -> Tuple[Redis, List[str]]: """Create a Redis vectorstore from raw documents. This is a user-friendly interface that: 1. Embeds documents. 2. Creates a new index for the embeddings in Redis. 3. Adds the documents to the newly created Redis index. 4. R...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/redis.html
9f60b6d53214-9
return instance, keys [docs] @classmethod def from_texts( cls: Type[Redis], texts: List[str], embedding: Embeddings, metadatas: Optional[List[dict]] = None, index_name: Optional[str] = None, content_key: str = "content", metadata_key: str = "metadata", ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/redis.html
9f60b6d53214-10
) -> bool: """ Delete a Redis entry. Args: ids: List of ids (keys) to delete. Returns: bool: Whether or not the deletions were successful. """ redis_url = get_from_dict_or_env(kwargs, "redis_url", "REDIS_URL") if ids is None: ra...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/redis.html
9f60b6d53214-11
Returns: bool: Whether or not the drop was successful. """ redis_url = get_from_dict_or_env(kwargs, "redis_url", "REDIS_URL") try: import redis # noqa: F401 except ImportError: raise ValueError( "Could not import redis python package. ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/redis.html
9f60b6d53214-12
"Please install it with `pip install redis`." ) try: # We need to first remove redis_url from kwargs, # otherwise passing it to Redis will result in an error. if "redis_url" in kwargs: kwargs.pop("redis_url") client = get_client(redis_u...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/redis.html
9f60b6d53214-13
"""Score threshold for similarity_limit search.""" class Config: """Configuration for this pydantic object.""" arbitrary_types_allowed = True @root_validator() def validate_search_type(cls, values: Dict) -> Dict: """Validate search type.""" if "search_type" in values: ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/redis.html
9f60b6d53214-14
) -> List[str]: """Add documents to vectorstore.""" return await self.vectorstore.aadd_documents(documents, **kwargs)
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/redis.html
7b8d04498303-0
Source code for langchain.vectorstores.singlestoredb """Wrapper around SingleStore DB.""" from __future__ import annotations import json from typing import ( Any, Callable, ClassVar, Collection, Iterable, List, Optional, Tuple, Type, ) from sqlalchemy.pool import QueuePool from langc...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/singlestoredb.html
7b8d04498303-1
[docs] def __init__( self, embedding: Embeddings, *, distance_strategy: DistanceStrategy = DEFAULT_DISTANCE_STRATEGY, table_name: str = "embeddings", content_field: str = "content", metadata_field: str = "metadata", vector_field: str = "vector", ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/singlestoredb.html
7b8d04498303-2
max_overflow (int, optional): Determines the maximum number of connections allowed beyond the pool_size. Defaults to 10. timeout (float, optional): Specifies the maximum wait time in seconds for establishing a connection. Defaults to 30. Following arguments pertai...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/singlestoredb.html
7b8d04498303-3
conv (dict[int, Callable], optional): A dictionary of data conversion functions. credential_type (str, optional): Specifies the type of authentication to use: auth.PASSWORD, auth.JWT, or auth.BROWSER_SSO. autocommit (bool, optional): Enables autocommits. ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/singlestoredb.html
7b8d04498303-4
vectorstore = SingleStoreDB(OpenAIEmbeddings()) """ self.embedding = embedding self.distance_strategy = distance_strategy self.table_name = table_name self.content_field = content_field self.metadata_field = metadata_field self.vector_field = vector_field ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/singlestoredb.html
7b8d04498303-5
), ) finally: cur.close() finally: conn.close() [docs] def add_texts( self, texts: Iterable[str], metadatas: Optional[List[dict]] = None, embeddings: Optional[List[List[float]]] = None, **kwargs: Any, ) -> Lis...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/singlestoredb.html
7b8d04498303-6
conn.close() return [] [docs] def similarity_search( self, query: str, k: int = 4, filter: Optional[dict] = None, **kwargs: Any ) -> List[Document]: """Returns the most similar indexed documents to the query text. Uses cosine similarity. Args: query (str): The ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/singlestoredb.html
7b8d04498303-7
filter: A dictionary of metadata fields and values to filter by. Defaults to None. Returns: List of Documents most similar to the query and score for each """ # Creates embedding vector from user query embedding = self.embedding.embed_query(query) ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/singlestoredb.html
7b8d04498303-8
where_clause, ORDERING_DIRECTIVE[self.distance_strategy], ), ("[{}]".format(",".join(map(str, embedding))),) + tuple(where_clause_values) + (k,), ) for row in cur.fetchall(): ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/singlestoredb.html
7b8d04498303-9
texts, OpenAIEmbeddings(), host="username:password@localhost:3306/database" ) """ instance = cls( embedding, distance_strategy=distance_strategy, table_name=table_name, content_field=content_field, ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/singlestoredb.html
7b8d04498303-10
) -> List[Document]: raise NotImplementedError( "SingleStoreDBVectorStoreRetriever does not support async" )
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/singlestoredb.html
f84046fabc8a-0
Source code for langchain.vectorstores.azuresearch """Wrapper around Azure Cognitive Search.""" from __future__ import annotations import base64 import json import logging import uuid from typing import ( TYPE_CHECKING, Any, Callable, Dict, Iterable, List, Optional, Tuple, Type, ) im...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/azuresearch.html
f84046fabc8a-1
) MAX_UPLOAD_BATCH_SIZE = 1000 def _get_search_client( endpoint: str, key: str, index_name: str, semantic_configuration_name: Optional[str] = None, fields: Optional[List[SearchField]] = None, vector_search: Optional[VectorSearch] = None, semantic_settings: Optional[SemanticSettings] = None, ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/azuresearch.html
f84046fabc8a-2
missing_fields = { key: mandatory_fields[key] for key, value in set(mandatory_fields.items()) - set(fields_types.items()) } if len(missing_fields) > 0: fmt_err = lambda x: ( # noqa: E731 f"{x} current type: '{fi...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/azuresearch.html
f84046fabc8a-3
prioritized_fields=PrioritizedFields( prioritized_content_fields=[ SemanticField(field_name=FIELDS_CONTENT) ], ), ) ] ) # Create the search index with t...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/azuresearch.html
f84046fabc8a-4
# Initialize base class self.embedding_function = embedding_function default_fields = [ SimpleField( name=FIELDS_ID, type=SearchFieldDataType.String, key=True, filterable=True, ), SearchableField( ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/azuresearch.html
f84046fabc8a-5
ids = [] # Write data to index data = [] for i, text in enumerate(texts): # Use provided key otherwise use default key key = keys[i] if keys else str(uuid.uuid4()) # Encoding key for Azure Search valid characters key = base64.urlsafe_b64encode(byte...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/azuresearch.html
f84046fabc8a-6
return ids else: raise Exception(response) [docs] def similarity_search( self, query: str, k: int = 4, **kwargs: Any ) -> List[Document]: search_type = kwargs.get("search_type", self.search_type) if search_type == "similarity": docs = self.vector_search(que...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/azuresearch.html
f84046fabc8a-7
Args: query: Text to look up documents similar to. k: Number of Documents to return. Defaults to 4. Returns: List of Documents most similar to the query and score for each """ results = self.client.search( search_text="", vector=np.arra...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/azuresearch.html
f84046fabc8a-8
) -> List[Tuple[Document, float]]: """Return docs most similar to query with an hybrid query. Args: query: Text to look up documents similar to. k: Number of Documents to return. Defaults to 4. Returns: List of Documents most similar to the query and score for...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/azuresearch.html
f84046fabc8a-9
[docs] def semantic_hybrid_search_with_score( self, query: str, k: int = 4, filters: Optional[str] = None ) -> List[Tuple[Document, float]]: """Return docs most similar to query with an hybrid query. Args: query: Text to look up documents similar to. k: Number of D...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/azuresearch.html
f84046fabc8a-10
"text": result.get("@search.captions", [{}])[0].text, "highlights": result.get("@search.captions", [{}])[ 0 ].highlights, } if result.get("@search.captions") ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/azuresearch.html
f84046fabc8a-11
"""Number of documents to return.""" class Config: """Configuration for this pydantic object.""" arbitrary_types_allowed = True @root_validator() def validate_search_type(cls, values: Dict) -> Dict: """Validate search type.""" if "search_type" in values: search_ty...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/azuresearch.html
3e0354471797-0
Source code for langchain.vectorstores.marqo """Wrapper around weaviate vector database.""" from __future__ import annotations import json import uuid from typing import ( TYPE_CHECKING, Any, Callable, Dict, Iterable, List, Optional, Tuple, Type, Union, ) from langchain.docstore....
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/marqo.html
3e0354471797-1
add_documents_settings: Optional[Dict[str, Any]] = None, searchable_attributes: Optional[List[str]] = None, page_content_builder: Optional[Callable[[Dict[str, Any]], str]] = None, ): """Initialize with Marqo client.""" try: import marqo except ImportError: ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/marqo.html
3e0354471797-2
order that matches the metadatas. metadatas (Optional[List[dict]], optional): a list of metadatas. Raises: ValueError: if metadatas is provided and the number of metadatas differs from the number of texts. Returns: List[str]: The list of ids that were adde...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/marqo.html
3e0354471797-3
ids += [item["_id"] for item in response["items"]] return ids [docs] def similarity_search( self, query: Union[str, Dict[str, float]], k: int = 4, **kwargs: Any, ) -> List[Document]: """Search the marqo index for the most similar documents. Args: ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/marqo.html
3e0354471797-4
return scored_documents [docs] def bulk_similarity_search( self, queries: Iterable[Union[str, Dict[str, float]]], k: int = 4, **kwargs: Any, ) -> List[List[Document]]: """Search the marqo index for the most similar documents in bulk with multiple queries. A...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/marqo.html
3e0354471797-5
k (int, optional): The number of documents to return. Defaults to 4. Returns: List[Tuple[Document, float]]: A list of lists of the matching documents and their scores for each query """ bulk_results = self.marqo_bulk_similarity_search(queries=queries, k=k) bulk_do...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/marqo.html
3e0354471797-6
) -> List[Document]: """Helper to convert Marqo results into documents. Args: results (List[dict]): A marqo results object with the 'hits'. include_scores (bool, optional): Include scores alongside documents. Defaults to False. Returns: Union[List[...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/marqo.html
3e0354471797-7
) -> Dict[str, List[Dict[str, List[Dict[str, str]]]]]: """Return documents from Marqo using a bulk search, exposes Marqo's output directly Args: queries (Iterable[Union[str, Dict[str, float]]]): A list of queries. k (int, optional): The number of documents to return for e...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/marqo.html
3e0354471797-8
return cls.from_texts(texts, metadatas=metadatas, **kwargs) [docs] @classmethod def from_texts( cls, texts: List[str], embedding: Any = None, metadatas: Optional[List[dict]] = None, index_name: str = "", url: str = "http://localhost:8882", api_key: str = ""...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/marqo.html
3e0354471797-9
embedding (Any, optional): Embeddings (not required). Defaults to None. index_name (str, optional): The name of the index to use, if none is provided then one will be created with a UUID. Defaults to None. url (str, optional): The URL for Marqo. Defaults to "http://localhost:8882". ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/marqo.html
3e0354471797-10
client.create_index(index_name, settings_dict=index_settings) if verbose: print(f"Created {index_name} successfully.") except Exception: if verbose: print(f"Index {index_name} exists.") instance: Marqo = cls( client, index_n...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/marqo.html
13ba630d8980-0
Source code for langchain.vectorstores.qdrant """Wrapper around Qdrant vector database.""" 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, Callable, Dict, ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
13ba630d8980-1
except NotImplementedError: # If the async method is not implemented, call the synchronous method # 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``. ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
13ba630d8980-2
raise ValueError( "Could not import qdrant-client python package. " "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_cl...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
13ba630d8980-3
self.distance_strategy = distance_strategy.upper() @property 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, bat...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
13ba630d8980-4
"""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. Ids have to...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
13ba630d8980-5
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 val...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
13ba630d8980-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
13ba630d8980-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
13ba630d8980-8
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 val...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
13ba630d8980-9
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]: """Return docs...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
13ba630d8980-10
embedding, k, filter=filter, search_params=search_params, offset=offset, score_threshold=score_threshold, consistency=consistency, **kwargs, ) return list(map(itemgetter(0), results)) [docs] @sync_call_fallback as...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
13ba630d8980-11
- 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
13ba630d8980-12
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 th...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
13ba630d8980-13
search_params=search_params, limit=k, offset=offset, with_payload=True, with_vectors=False, # Langchain does not expect vectors to be returned score_threshold=score_threshold, consistency=consistency, **kwargs, ) return...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
13ba630d8980-14
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
13ba630d8980-15
filter=qdrant_filter, params=search_params, limit=k, offset=offset, with_payload=grpc.WithPayloadSelector(enable=True), with_vectors=grpc.WithVectorsSelector(enable=False), score_threshold=score_threshold, re...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
13ba630d8980-16
query_embedding, k, fetch_k, lambda_mult, **kwargs ) [docs] @sync_call_fallback async def amax_marginal_relevance_search( self, query: str, k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, **kwargs: Any, ) -> List[Document]: """Return do...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
13ba630d8980-17
Maximal marginal relevance optimizes for similarity to query AND diversity among selected documents. Args: 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 algor...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
13ba630d8980-18
to maximum diversity and 1 to minimum diversity. Defaults to 0.5. Returns: List of Documents selected by maximal marginal relevance and distance for each. """ results = await self.amax_marginal_relevance_search_with_score_by_vector( emb...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
13ba630d8980-19
query_vector=query_vector, with_payload=True, with_vectors=True, limit=fetch_k, ) embeddings = [ result.vector.get(self.vector_name) # type: ignore[index, union-attr] if self.vector_name is not None else result.vector f...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
13ba630d8980-20
Defaults to 0.5. Returns: List of Documents selected by maximal marginal relevance and distance for each. """ from qdrant_client import grpc # noqa from qdrant_client.conversions.conversion import GrpcToRest response = await self.client.async_grpc_points....
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
13ba630d8980-21
Returns: Optional[bool]: True if deletion is successful, False otherwise, None if not implemented. """ from qdrant_client.http import models as rest result = self.client.delete( collection_name=self.collection_name, points_selector=ids, ) ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
13ba630d8980-22
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
13ba630d8980-23
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/v...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
13ba630d8980-24
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 ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
13ba630d8980-25
Example: .. code-block:: python from langchain import Qdrant from langchain.embeddings import OpenAIEmbeddings embeddings = OpenAIEmbeddings() qdrant = Qdrant.from_texts(texts, embeddings, "localhost") """ qdrant = cls._construc...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
13ba630d8980-26
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 = CONTENT_KEY, ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
13ba630d8980-27
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...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
13ba630d8980-28
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/_modules/langchain/vectorstores/qdrant.html
13ba630d8980-29
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 ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
13ba630d8980-30
on_disk, force_recreate, **kwargs, ) await qdrant.aadd_texts(texts, metadatas, ids, batch_size) return qdrant @classmethod def _construct_instance( cls: Type[Qdrant], texts: List[str], embedding: Embeddings, location: Optional[str] ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
13ba630d8980-31
init_from: Optional[common_types.InitFrom] = None, on_disk: Optional[bool] = None, force_recreate: bool = False, **kwargs: Any, ) -> Qdrant: try: import qdrant_client except ImportError: raise ValueError( "Could not import qdrant-client...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
13ba630d8980-32
current_vector_config = collection_info.config.params.vectors if isinstance(current_vector_config, dict) and vector_name is not None: if vector_name not in current_vector_config: raise QdrantException( f"Existing Qdrant collection {collection_name}...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
13ba630d8980-33
) # Check if the vector configuration has the same dimensionality. if current_vector_config.size != vector_size: # type: ignore[union-attr] raise QdrantException( f"Existing Qdrant collection is configured for vectors with " f"{current_vec...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
13ba630d8980-34
collection_name=collection_name, vectors_config=vectors_config, shard_number=shard_number, replication_factor=replication_factor, write_consistency_factor=write_consistency_factor, on_disk_payload=on_disk_payload, hnsw_confi...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
13ba630d8980-35
) def _similarity_search_with_relevance_scores( self, 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. Args: query: input text...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html