id
stringlengths
14
16
text
stringlengths
13
2.7k
source
stringlengths
57
178
0275cedc3677-4
} if filter: payload["filter"] = filter r = self._client.data().vector_search(self._table_name, payload=payload) if r.status_code != 200: raise Exception(f"Error running similarity search: {r.status_code} {r}") hits = r["records"] docs_and_scores = [ ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/xata.html
0275cedc3677-5
] self._client.records().transaction(payload={"operations": operations}) else: raise ValueError("Either ids or delete_all must be set.") def _delete_all(self) -> None: """Delete all records in the table.""" while True: r = self._client.data().query(sel...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/xata.html
59e89252a429-0
Source code for langchain.vectorstores.chroma from __future__ import annotations import base64 import logging import uuid from typing import ( TYPE_CHECKING, Any, Callable, Dict, Iterable, List, Optional, Tuple, Type, ) import numpy as np from langchain.docstore.document import Docum...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/chroma.html
59e89252a429-1
.. code-block:: python from langchain.vectorstores import Chroma from langchain.embeddings.openai import OpenAIEmbeddings embeddings = OpenAIEmbeddings() vectorstore = Chroma("langchain_store", embeddings) """ _LANGCHAIN_DEFAULT_COLLECTION_NAME = "...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/chroma.html
59e89252a429-2
major, minor, _ = chromadb.__version__.split(".") if int(major) == 0 and int(minor) < 4: client_settings.chroma_db_impl = "duckdb+parquet" _client_settings = client_settings elif persist_directory: # Maintain backwards compatibility...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/chroma.html
59e89252a429-3
where_document: Optional[Dict[str, str]] = None, **kwargs: Any, ) -> List[Document]: """Query the chroma collection.""" try: import chromadb # noqa: F401 except ImportError: raise ValueError( "Could not import chromadb python package. " ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/chroma.html
59e89252a429-4
# Populate IDs if ids is None: ids = [str(uuid.uuid1()) for _ in uris] embeddings = None # Set embeddings if self._embedding_function is not None and hasattr( self._embedding_function, "embed_image" ): embeddings = self._embedding_function.embe...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/chroma.html
59e89252a429-5
"langchain.vectorstores.utils.filter_complex_metadata." ) raise ValueError(e.args[0] + "\n\n" + msg) else: raise e if empty_ids: images_without_metadatas = [uris[j] for j in empty_ids] ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/chroma.html
59e89252a429-6
embeddings = None texts = list(texts) if self._embedding_function is not None: embeddings = self._embedding_function.embed_documents(texts) if metadatas: # fill metadatas with empty dicts if somebody # did not specify metadata for all texts length_...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/chroma.html
59e89252a429-7
else: raise e if empty_ids: texts_without_metadatas = [texts[j] for j in empty_ids] embeddings_without_metadatas = ( [embeddings[j] for j in empty_ids] if embeddings else None ) ids_without_metadatas ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/chroma.html
59e89252a429-8
where_document: Optional[Dict[str, str]] = None, **kwargs: Any, ) -> List[Document]: """Return docs most similar to embedding vector. Args: embedding (List[float]): Embedding to look up documents similar to. k (int): Number of Documents to return. Defaults to 4. ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/chroma.html
59e89252a429-9
query_embeddings=embedding, n_results=k, where=filter, where_document=where_document, ) return _results_to_docs_and_scores(results) [docs] def similarity_search_with_score( self, query: str, k: int = DEFAULT_K, filter: Optional[Dict[...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/chroma.html
59e89252a429-10
The 'correct' relevance function may differ depending on a few things, including: - the distance / similarity metric used by the VectorStore - the scale of your embeddings (OpenAI's are unit normed. Many others are not!) - embedding dimensionality - etc. """ if se...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/chroma.html
59e89252a429-11
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 algorithm. lambda_mult: Number between 0 and 1 that determines the degree of diversity...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/chroma.html
59e89252a429-12
) -> List[Document]: """Return docs selected using the maximal marginal relevance. Maximal marginal relevance optimizes for similarity to query AND diversity among selected documents. Args: query: Text to look up documents similar to. k: Number of Documents to ret...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/chroma.html
59e89252a429-13
include: Optional[List[str]] = None, ) -> Dict[str, Any]: """Gets the collection. Args: 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...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/chroma.html
59e89252a429-14
# Maintain backwards compatibility with chromadb < 0.4.0 major, minor, _ = chromadb.__version__.split(".") if int(major) == 0 and int(minor) < 4: self._client.persist() [docs] def update_document(self, document_id: str, document: Document) -> None: """Update a document in the coll...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/chroma.html
59e89252a429-15
embeddings=batch[1], documents=batch[3], metadatas=batch[2], ) else: self._collection.update( ids=ids, embeddings=embeddings, documents=text, metadatas=metadata, ) [doc...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/chroma.html
59e89252a429-16
Defaults to None. Returns: Chroma: Chroma vectorstore. """ chroma_collection = cls( collection_name=collection_name, embedding_function=embedding, persist_directory=persist_directory, client_settings=client_settings, client=...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/chroma.html
59e89252a429-17
collection_metadata: Optional[Dict] = None, **kwargs: Any, ) -> Chroma: """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. Args: col...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/chroma.html
3454d191cb44-0
Source code for langchain.vectorstores.starrocks from __future__ import annotations import json import logging from hashlib import sha1 from threading import Thread from typing import Any, Dict, Iterable, List, Optional, Tuple from langchain.docstore.document import Document from langchain.pydantic_v1 import BaseSettin...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/starrocks.html
3454d191cb44-1
for idx, datum in enumerate(value): k = columns[idx][0] r[k] = datum result.append(r) debug_output(result) cursor.close() return result [docs]class StarRocksSettings(BaseSettings): """StarRocks client configuration. Attribute: StarRocks_host (str) : An URL to ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/starrocks.html
3454d191cb44-2
"metadata": "metadata", } database: str = "default" table: str = "langchain" def __getitem__(self, item: str) -> Any: return getattr(self, item) class Config: env_file = ".env" env_prefix = "starrocks_" env_file_encoding = "utf-8" [docs]class StarRocks(VectorStore): ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/starrocks.html
3454d191cb44-3
except ImportError: # Just in case if tqdm is not installed self.pgbar = lambda x, **kwargs: x super().__init__() if config is not None: self.config = config else: self.config = StarRocksSettings() assert self.config assert self.con...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/starrocks.html
3454d191cb44-4
[docs] def escape_str(self, value: str) -> str: return "".join(f"{self.BS}{c}" if c in self.must_escape else c for c in value) @property def embeddings(self) -> Embeddings: return self.embedding_function def _build_insert_sql(self, transac: Iterable, column_names: Iterable[str]) -> str: ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/starrocks.html
3454d191cb44-5
"""Insert more texts through the embeddings and add to the VectorStore. Args: texts: Iterable of strings to add to the VectorStore. ids: Optional list of ids to associate with the texts. batch_size: Batch size of insertion metadata: Optional column data to be inse...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/starrocks.html
3454d191cb44-6
if t: t.join() self._insert(transac, keys) return [i for i in ids] except Exception as e: logger.error(f"\033[91m\033[1m{type(e)}\033[0m \033[95m{str(e)}\033[0m") return [] [docs] @classmethod def from_texts( cls, tex...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/starrocks.html
3454d191cb44-7
"""Text representation for StarRocks Vector Store, prints backends, username and schemas. Easy to use with `str(StarRocks())` Returns: repr: string to show connection info and data schema """ _repr = f"\033[92m\033[1m{self.config.database}.{self.config.table} @ " ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/starrocks.html
3454d191cb44-8
return _repr def _build_query_sql( self, q_emb: List[float], topk: int, where_str: Optional[str] = None ) -> str: q_emb_str = ",".join(map(str, q_emb)) if where_str: where_str = f"WHERE {where_str}" else: where_str = "" q_str = f""" SEL...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/starrocks.html
3454d191cb44-9
""" return self.similarity_search_by_vector( 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, )...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/starrocks.html
3454d191cb44-10
return [] [docs] def similarity_search_with_relevance_scores( self, query: str, k: int = 4, where_str: Optional[str] = None, **kwargs: Any ) -> List[Tuple[Document, float]]: """Perform a similarity search with StarRocks Args: query (str): query string k (int, optio...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/starrocks.html
3454d191cb44-11
f"DROP TABLE IF EXISTS {self.config.database}.{self.config.table}", ) @property def metadata_column(self) -> str: return self.config.column_map["metadata"]
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/starrocks.html
eec294367d7f-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-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 ) ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-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]: ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-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: ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-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: ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-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. ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-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, ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-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. ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-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 ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-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, ) ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-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: ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-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. ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-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:...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-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. ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-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: ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-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 ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-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 ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-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, ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-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`." ) ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-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, ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-42
raise QdrantException( f"Existing Qdrant collection {collection_name} uses named vectors. " f"If you want to reuse it, please set `vector_name` to any of the " f"existing named vectors: " f"{', '.join(current_vector_config.keys())}." # noq...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-43
f"Existing Qdrant collection is configured for " f"{current_vector_config.distance} " # type: ignore[union-attr] f"similarity. Please set `distance_func` parameter to " f"`{distance_func}` if you want to reuse it. If you want to " f"recrea...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-44
distance_strategy=distance_func, vector_name=vector_name, ) return qdrant @staticmethod def _cosine_relevance_score_fn(distance: float) -> float: """Normalize the distance to a score on a scale [0, 1].""" return (distance + 1.0) / 2.0 def _select_relevance_score_f...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-45
**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) """ return self.si...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-46
metadata_payload_key: str, ) -> Document: from qdrant_client.conversions.conversion import grpc_to_payload payload = grpc_to_payload(scored_point.payload) return Document( page_content=payload[content_payload_key], metadata=payload.get(metadata_payload_key) or {}, ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-47
Args: query: Query text. Returns: List of floats representing the query embedding. """ if self.embeddings is not None: embedding = self.embeddings.embed_query(query) else: if self._embeddings_function is not None: embedding ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-48
embeddings = await self.embeddings.aembed_documents(list(texts)) if hasattr(embeddings, "tolist"): embeddings = embeddings.tolist() elif self._embeddings_function is not None: embeddings = [] for text in texts: embedding = self._embeddings_func...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-49
) for point_id, vector, payload in zip( batch_ids, batch_embeddings, self._build_payloads( batch_texts, batch_metadatas, self.content_payload_key, s...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
eec294367d7f-50
batch_texts, batch_metadatas, self.content_payload_key, self.metadata_payload_key, ), ) ] yield batch_ids, points
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
4bfae7e95860-0
Source code for langchain.vectorstores.epsilla """Wrapper around Epsilla vector database.""" from __future__ import annotations import logging import uuid from typing import TYPE_CHECKING, Any, Iterable, List, Optional, Type from langchain.docstore.document import Document from langchain.schema.embeddings import Embedd...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/epsilla.html
4bfae7e95860-1
""" _LANGCHAIN_DEFAULT_DB_NAME = "langchain_store" _LANGCHAIN_DEFAULT_DB_PATH = "/tmp/langchain-epsilla" _LANGCHAIN_DEFAULT_TABLE_NAME = "langchain_collection" [docs] def __init__( self, client: Any, embeddings: Embeddings, db_path: Optional[str] = _LANGCHAIN_DEFAULT_DB_PA...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/epsilla.html
4bfae7e95860-2
""" self._collection_name = collection_name [docs] def clear_data(self, collection_name: str = "") -> None: """ Clear data in a collection. Args: collection_name (Optional[str]): The name of the collection. If not provided, the default collection will be us...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/epsilla.html
4bfae7e95860-3
dim = len(embeddings[0]) fields: List[dict] = [ {"name": "id", "dataType": "INT"}, {"name": "text", "dataType": "STRING"}, {"name": "embeddings", "dataType": "VECTOR_FLOAT", "dimensions": dim}, ] if metadatas is not None: field_names = [field["name...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/epsilla.html
4bfae7e95860-4
drop_old: Optional[bool] = False, **kwargs: Any, ) -> List[str]: """ Embed texts and add them to the database. Args: texts (Iterable[str]): The texts to embed. metadatas (Optional[List[dict]]): Metadata dicts attached to each of the tex...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/epsilla.html
4bfae7e95860-5
metadata = metadatas[index].items() for key, value in metadata: record[key] = value records.append(record) status_code, response = self._client.insert( table_name=collection_name, records=records ) if status_code != 200: log...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/epsilla.html
4bfae7e95860-6
return list( map( lambda item: Document( page_content=item["text"], metadata={ key: item[key] for key in item if key not in exclude_keys }, ), response["result"], )...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/epsilla.html
4bfae7e95860-7
drop_old (Optional[bool]): Whether to drop the previous collection and create a new one. Defaults to False. Returns: Epsilla: Epsilla vector store. """ instance = Epsilla(client, embedding, db_path=db_path, db_name=db_name) instance.add_texts( ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/epsilla.html
4bfae7e95860-8
collection_name (Optional[str]): Which collection to use. Defaults to "langchain_collection". If provided, default collection name will be set as well. drop_old (Optional[bool]): Whether to drop the previous collection and create a new one. Default...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/epsilla.html
1437a67e6df1-0
Source code for langchain.vectorstores.dingo from __future__ import annotations import logging import uuid from typing import Any, Iterable, List, Optional, Tuple import numpy as np from langchain.docstore.document import Document from langchain.schema.embeddings import Embeddings from langchain.schema.vectorstore impo...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/dingo.html
1437a67e6df1-1
dingo_client = client else: try: # connect to dingo db dingo_client = dingodb.DingoDB(user, password, host) except ValueError as e: raise ValueError(f"Dingo failed to connect: {e}") self._text_key = text_key self._client = d...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/dingo.html
1437a67e6df1-2
""" # Embed and create the documents ids = ids or [str(uuid.uuid1().int)[:13] for _ in texts] metadatas_list = [] texts = list(texts) embeds = self._embedding.embed_documents(texts) for i, text in enumerate(texts): metadata = metadatas[i] if metadatas else {} ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/dingo.html
1437a67e6df1-3
[docs] def similarity_search_with_score( self, query: str, k: int = 4, search_params: Optional[dict] = None, timeout: Optional[int] = None, **kwargs: Any, ) -> List[Tuple[Document, float]]: """Return Dingo documents most similar to query, along with scores....
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/dingo.html
1437a67e6df1-4
k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, search_params: Optional[dict] = None, **kwargs: Any, ) -> List[Document]: """Return docs selected using the maximal marginal relevance. Maximal marginal relevance optimizes for similarity to query AND diversity ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/dingo.html
1437a67e6df1-5
for metadata in selected ] [docs] def max_marginal_relevance_search( self, query: str, k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, search_params: Optional[dict] = None, **kwargs: Any, ) -> List[Document]: """Return docs selected...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/dingo.html
1437a67e6df1-6
host: List[str] = ["172.20.31.10:13000"], user: str = "root", password: str = "123123", batch_size: int = 500, **kwargs: Any, ) -> Dingo: """Construct Dingo wrapper from raw documents. This is a user friendly interface that: 1. Embeds docum...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/dingo.html
1437a67e6df1-7
): dingo_client.create_index( index_name, dimension=dimension, auto_id=False ) else: if ( index_name is not None and index_name not in dingo_client.get_index() and index_name.upper() not in dingo_clie...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/dingo.html