id
stringlengths
14
16
text
stringlengths
36
2.73k
source
stringlengths
59
127
ffbc7c5e91ef-1
embedding: Embeddings, table_name: str, query_name: Union[str, None] = None, ) -> None: """Initialize with supabase client.""" try: import supabase # noqa: F401 except ImportError: raise ValueError( "Could not import supabase python pa...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/supabase.html
ffbc7c5e91ef-2
raise ValueError("Supabase document table_name is required.") embeddings = embedding.embed_documents(texts) docs = cls._texts_to_documents(texts, metadatas) _ids = cls._add_vectors(client, table_name, embeddings, docs) return cls( client=client, embedding=embeddin...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/supabase.html
ffbc7c5e91ef-3
) -> List[Tuple[Document, float]]: match_documents_params = dict(query_embedding=query, match_count=k) res = self._client.rpc(self.query_name, match_documents_params).execute() match_result = [ ( Document( metadata=search.get("metadata", {}), # ty...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/supabase.html
ffbc7c5e91ef-4
) -> List[Document]: """Return list of Documents from list of texts and metadatas.""" if metadatas is None: metadatas = repeat({}) docs = [ Document(page_content=text, metadata=metadata) for text, metadata in zip(texts, metadatas) ] return docs...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/supabase.html
ffbc7c5e91ef-5
self, embedding: List[float], k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, **kwargs: Any, ) -> List[Document]: """Return docs selected using the maximal marginal relevance. Maximal marginal relevance optimizes for similarity to query AND diversity ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/supabase.html
ffbc7c5e91ef-6
**kwargs: Any, ) -> List[Document]: """Return docs selected using the maximal marginal relevance. Maximal marginal relevance optimizes for similarity to query AND diversity among selected documents. Args: query: Text to look up documents similar to. k: Number ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/supabase.html
ffbc7c5e91ef-7
) return docs By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 16, 2023.
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/supabase.html
dc67dafeea5b-0
Source code for langchain.vectorstores.pinecone """Wrapper around Pinecone vector database.""" from __future__ import annotations import logging import uuid from typing import Any, Callable, Iterable, List, Optional, Tuple import numpy as np from langchain.docstore.document import Document from langchain.embeddings.bas...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/pinecone.html
dc67dafeea5b-1
f"client should be an instance of pinecone.index.Index, " f"got {type(index)}" ) self._index = index self._embedding_function = embedding_function self._text_key = text_key self._namespace = namespace [docs] def add_texts( self, texts: Itera...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/pinecone.html
dc67dafeea5b-2
self, query: str, k: int = 4, filter: Optional[dict] = None, namespace: Optional[str] = None, ) -> List[Tuple[Document, float]]: """Return pinecone documents most similar to query, along with scores. Args: query: Text to look up documents similar to. ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/pinecone.html
dc67dafeea5b-3
"""Return pinecone documents most similar to query. Args: query: Text to look up documents similar to. k: Number of Documents to return. Defaults to 4. filter: Dictionary of argument(s) to filter on metadata namespace: Namespace to search in. Default will search i...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/pinecone.html
dc67dafeea5b-4
""" if namespace is None: namespace = self._namespace results = self._index.query( [embedding], top_k=fetch_k, include_values=True, include_metadata=True, namespace=namespace, filter=filter, ) mmr_selecte...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/pinecone.html
dc67dafeea5b-5
Defaults to 0.5. Returns: List of Documents selected by maximal marginal relevance. """ embedding = self._embedding_function(query) return self.max_marginal_relevance_search_by_vector( embedding, k, fetch_k, lambda_mult, filter, namespace ) [docs] @clas...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/pinecone.html
dc67dafeea5b-6
"Please install it with `pip install pinecone-client`." ) indexes = pinecone.list_indexes() # checks if provided index exists if index_name in indexes: index = pinecone.Index(index_name) elif len(indexes) == 0: raise ValueError( "No active ind...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/pinecone.html
dc67dafeea5b-7
return cls(index, embedding.embed_query, text_key, namespace) [docs] @classmethod def from_existing_index( cls, index_name: str, embedding: Embeddings, text_key: str = "text", namespace: Optional[str] = None, ) -> Pinecone: """Load pinecone vectorstore from ind...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/pinecone.html
96ac11b0e0b1-0
Source code for langchain.vectorstores.weaviate """Wrapper around weaviate vector database.""" from __future__ import annotations import datetime from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Type from uuid import uuid4 import numpy as np from langchain.docstore.document import Document from ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/weaviate.html
96ac11b0e0b1-1
if weaviate_api_key is not None else None ) client = weaviate.Client(weaviate_url, auth_client_secret=auth) return client def _default_score_normalizer(val: float) -> float: return 1 - 1 / (1 + np.exp(val)) def _json_serializable(value: Any) -> Any: if isinstance(value, datetime.datetime): ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/weaviate.html
96ac11b0e0b1-2
) if not isinstance(client, weaviate.Client): raise ValueError( f"client should be an instance of weaviate.Client, got {type(client)}" ) self._client = client self._index_name = index_name self._embedding = embedding self._text_key = text_k...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/weaviate.html
96ac11b0e0b1-3
class_name=self._index_name, uuid=_id, vector=vector, ) ids.append(_id) return ids [docs] def similarity_search( self, query: str, k: int = 4, **kwargs: Any ) -> List[Document]: """Return docs most similar to query. ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/weaviate.html
96ac11b0e0b1-4
if kwargs.get("where_filter"): query_obj = query_obj.with_where(kwargs.get("where_filter")) if kwargs.get("additional"): query_obj = query_obj.with_additional(kwargs.get("additional")) result = query_obj.with_near_text(content).with_limit(k).do() if "errors" in result: ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/weaviate.html
96ac11b0e0b1-5
k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, **kwargs: Any, ) -> List[Document]: """Return docs selected using the maximal marginal relevance. Maximal marginal relevance optimizes for similarity to query AND diversity among selected documents. Args...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/weaviate.html
96ac11b0e0b1-6
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 algorithm. lambda_mult: Number between 0 and 1 that determines the degree ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/weaviate.html
96ac11b0e0b1-7
""" Return list of documents most similar to the query text and cosine distance in float for each. Lower score represents more similarity. """ if self._embedding is None: raise ValueError( "_embedding cannot be None for similarity_search_with_score" ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/weaviate.html
96ac11b0e0b1-8
**kwargs: Any, ) -> List[Tuple[Document, float]]: """Return docs and relevance scores, normalized on a scale from 0 to 1. 0 is dissimilar, 1 is most similar. """ if self._relevance_score_fn is None: raise ValueError( "relevance_score_fn must be provided to...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/weaviate.html
96ac11b0e0b1-9
) """ client = _create_weaviate_client(**kwargs) from weaviate.util import get_valid_uuid index_name = kwargs.get("index_name", f"LangChain_{uuid4().hex}") embeddings = embedding.embed_documents(texts) if embedding else None text_key = "text" schema = _default_sch...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/weaviate.html
96ac11b0e0b1-10
batch.add_data_object(**params) batch.flush() relevance_score_fn = kwargs.get("relevance_score_fn") by_text: bool = kwargs.get("by_text", False) return cls( client, index_name, text_key, embedding=embedding, attributes=attri...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/weaviate.html
bbbc79145bb2-0
Source code for langchain.vectorstores.zilliz from __future__ import annotations import logging from typing import Any, List, Optional from langchain.embeddings.base import Embeddings from langchain.vectorstores.milvus import Milvus logger = logging.getLogger(__name__) [docs]class Zilliz(Milvus): def _create_index(...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/zilliz.html
bbbc79145bb2-1
"Failed to create an index on collection: %s", self.collection_name ) raise e [docs] @classmethod def from_texts( cls, texts: List[str], embedding: Embeddings, metadatas: Optional[List[dict]] = None, collection_name: str = "LangChainCollecti...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/zilliz.html
bbbc79145bb2-2
""" vector_db = cls( embedding_function=embedding, collection_name=collection_name, connection_args=connection_args, consistency_level=consistency_level, index_params=index_params, search_params=search_params, drop_old=drop_old,...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/zilliz.html
88eb7242e864-0
Source code for langchain.vectorstores.singlestoredb """Wrapper around SingleStore DB.""" from __future__ import annotations import json from typing import ( Any, ClassVar, Collection, Iterable, List, Optional, Tuple, Type, ) from sqlalchemy.pool import QueuePool from langchain.docstore....
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/singlestoredb.html
88eb7242e864-1
timeout: float = 30, **kwargs: Any, ): """Initialize with necessary components. Args: embedding (Embeddings): A text embedding model. table_name (str, optional): Specifies the name of the table in use. Defaults to "embeddings". content_fiel...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/singlestoredb.html
88eb7242e864-2
local_infile (bool, optional): Allows local file uploads. charset (str, optional): Specifies the character set for string values. ssl_key (str, optional): Specifies the path of the file containing the SSL key. ssl_cert (str, optional): Specifies the path of the file c...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/singlestoredb.html
88eb7242e864-3
.. code-block:: python from langchain.embeddings import OpenAIEmbeddings from langchain.vectorstores import SingleStoreDB vectorstore = SingleStoreDB( OpenAIEmbeddings(), host="127.0.0.1", port=3306, ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/singlestoredb.html
88eb7242e864-4
{} BLOB, {} JSON);""".format( self.table_name, self.content_field, self.vector_field, self.metadata_field, ), ) finally: cur.close() finally: ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/singlestoredb.html
88eb7242e864-5
finally: cur.close() finally: conn.close() return [] [docs] def similarity_search( self, query: str, k: int = 4, **kwargs: Any ) -> List[Document]: """Returns the most similar indexed documents to the query text. Uses cosine similarity. ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/singlestoredb.html
88eb7242e864-6
self.vector_field, self.table_name, ), ( "[{}]".format(",".join(map(str, embedding))), k, ), ) for row in cur.fetchall(): doc = Document...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/singlestoredb.html
88eb7242e864-7
) """ instance = cls( embedding, table_name=table_name, content_field=content_field, metadata_field=metadata_field, vector_field=vector_field, pool_size=pool_size, max_overflow=max_overflow, timeout=timeout, ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/singlestoredb.html
dabc47655c46-0
Source code for langchain.vectorstores.annoy """Wrapper around Annoy vector database.""" from __future__ import annotations import os import pickle import uuid from configparser import ConfigParser from pathlib import Path from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple import numpy as np from l...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/annoy.html
dabc47655c46-1
): """Initialize with necessary components.""" self.embedding_function = embedding_function self.index = index self.metric = metric self.docstore = docstore self.index_to_docstore_id = index_to_docstore_id [docs] def add_texts( self, texts: Iterable[str...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/annoy.html
dabc47655c46-2
Args: query: Text to look up documents similar to. k: Number of Documents to return. Defaults to 4. search_k: inspect up to search_k nodes which defaults to n_trees * n if not provided Returns: List of Documents most similar to the query and score ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/annoy.html
dabc47655c46-3
k: Number of Documents to return. Defaults to 4. search_k: inspect up to search_k nodes which defaults to n_trees * n if not provided Returns: List of Documents most similar to the query and score for each """ embedding = self.embedding_function(query) ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/annoy.html
dabc47655c46-4
Returns: List of Documents most similar to the embedding. """ docs_and_scores = self.similarity_search_with_score_by_index( docstore_index, k, search_k ) return [doc for doc, _ in docs_and_scores] [docs] def similarity_search( self, query: str, k: int =...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/annoy.html
dabc47655c46-5
of diversity among the results with 0 corresponding to maximum diversity and 1 to minimum diversity. Defaults to 0.5. Returns: List of Documents selected by maximal marginal relevance. """ idxs = self.index.get_nns_by_vector( ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/annoy.html
dabc47655c46-6
k: Number of Documents to return. Defaults to 4. fetch_k: Number of Documents to fetch to pass to MMR algorithm. lambda_mult: Number between 0 and 1 that determines the degree of diversity among the results with 0 corresponding to maximum diversity...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/annoy.html
dabc47655c46-7
documents = [] for i, text in enumerate(texts): metadata = metadatas[i] if metadatas else {} documents.append(Document(page_content=text, metadata=metadata)) index_to_id = {i: str(uuid.uuid4()) for i in range(len(documents))} docstore = InMemoryDocstore( {inde...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/annoy.html
dabc47655c46-8
from langchain.embeddings import OpenAIEmbeddings embeddings = OpenAIEmbeddings() index = Annoy.from_texts(texts, embeddings) """ embeddings = embedding.embed_documents(texts) return cls.__from( texts, embeddings, embedding, metadatas, metric, trees, n...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/annoy.html
dabc47655c46-9
text_embedding_pairs = list(zip(texts, text_embeddings)) db = Annoy.from_embeddings(text_embedding_pairs, embeddings) """ texts = [t[0] for t in text_embeddings] embeddings = [t[1] for t in text_embeddings] return cls.__from( texts, embeddings, embedding, meta...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/annoy.html
dabc47655c46-10
Args: folder_path: folder path to load index, docstore, and index_to_docstore_id from. embeddings: Embeddings to use when generating queries. """ path = Path(folder_path) # load index separately since it is not picklable annoy = dependable_annoy_im...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/annoy.html
1f15a931ccb2-0
Source code for langchain.vectorstores.elastic_vector_search """Wrapper around Elasticsearch vector database.""" from __future__ import annotations import uuid from abc import ABC from typing import ( TYPE_CHECKING, Any, Dict, Iterable, List, Mapping, Optional, Tuple, Union, ) from l...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/elastic_vector_search.html
1f15a931ccb2-1
# defined as an abstract base class itself, allowing the creation of subclasses with # their own specific implementations. If you plan to subclass ElasticVectorSearch, # you can inherit from it and define your own implementation of the necessary methods # and attributes. [docs]class ElasticVectorSearch(VectorStore, ABC...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/elastic_vector_search.html
1f15a931ccb2-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...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/elastic_vector_search.html
1f15a931ccb2-3
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 string is mis-formatted. Got error: {e} " ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/elastic_vector_search.html
1f15a931ccb2-4
for i, text in enumerate(texts): metadata = metadatas[i] if metadatas else {} _id = str(uuid.uuid4()) request = { "_op_type": "index", "_index": self.index_name, "vector": embeddings[i], "text": text, "me...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/elastic_vector_search.html
1f15a931ccb2-5
""" embedding = self.embedding.embed_query(query) script_query = _default_script_query(embedding, filter) response = self.client_search( self.client, self.index_name, script_query, size=k ) hits = [hit for hit in response["hits"]["hits"]] docs_and_scores = [ ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/elastic_vector_search.html
1f15a931ccb2-6
) """ elasticsearch_url = elasticsearch_url or get_from_env( "elasticsearch_url", "ELASTICSEARCH_URL" ) index_name = index_name or uuid.uuid4().hex vectorsearch = cls(elasticsearch_url, index_name, embedding, **kwargs) vectorsearch.add_texts( texts...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/elastic_vector_search.html
1f15a931ccb2-7
""" def __init__( self, index_name: str, embedding: Embeddings, es_connection: Optional["Elasticsearch"] = None, es_cloud_id: Optional[str] = None, es_user: Optional[str] = None, es_password: Optional[str] = None, vector_query_field: Optional[str] = "v...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/elastic_vector_search.html
1f15a931ccb2-8
if es_cloud_id and es_user and es_password: self.client = elasticsearch.Elasticsearch( cloud_id=es_cloud_id, basic_auth=(es_user, es_password) ) else: raise ValueError( """Either provide a pre-existing Elasticsearch conn...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/elastic_vector_search.html
1f15a931ccb2-9
knn["query_vector_builder"] = { "text_embedding": { "model_id": model_id, # use 'model_id' argument "model_text": query, # use 'query' argument } } else: raise ValueError( "Either `query_vector` or ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/elastic_vector_search.html
1f15a931ccb2-10
`query` is provided. size: The number of search hits to return. Defaults to 10. source: Whether to include the source of each hit in the results. fields: The fields to include in the source of each hit. If None, all fields are included. vector_query_field:...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/elastic_vector_search.html
1f15a931ccb2-11
] = None, ) -> Dict[Any, Any]: """Performs a hybrid k-nearest neighbor (k-NN) and text-based search on the Elasticsearch index. The search can be conducted using either a raw query vector or a model ID. The method first generates the body of the k-NN search query and the ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/elastic_vector_search.html
1f15a931ccb2-12
both are provided. """ knn_query_body = self._default_knn_query( query_vector=query_vector, query=query, model_id=model_id, k=k ) # Modify the knn_query_body to add a "boost" parameter knn_query_body["boost"] = knn_boost # Generate the body of the standard Ela...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/elastic_vector_search.html
46209c3a05aa-0
Source code for langchain.vectorstores.qdrant """Wrapper around Qdrant vector database.""" from __future__ import annotations import uuid import warnings from itertools import islice from operator import itemgetter from typing import ( TYPE_CHECKING, Any, Callable, Dict, Iterable, List, Opti...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/qdrant.html
46209c3a05aa-1
metadata_payload_key: str = METADATA_KEY, embedding_function: Optional[Callable] = None, # deprecated ): """Initialize with necessary components.""" try: import qdrant_client except ImportError: raise ValueError( "Could not import qdrant-clien...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/qdrant.html
46209c3a05aa-2
"Using `embeddings` as `embedding_function` which is deprecated" ) self._embeddings_function = embeddings self.embeddings = None [docs] def add_texts( self, texts: Iterable[str], metadatas: Optional[List[dict]] = None, ids: Optional[Sequence[str]] =...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/qdrant.html
46209c3a05aa-3
ids=batch_ids, vectors=self._embed_texts(batch_texts), payloads=self._build_payloads( batch_texts, batch_metadatas, self.content_payload_key, self.metadata_payload_key, ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/qdrant.html
46209c3a05aa-4
- 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...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/qdrant.html
46209c3a05aa-5
score_threshold: Define a minimal score threshold for the result. If defined, less similar results will not be returned. Score of the returned result might be higher or smaller than the threshold depending on the Distance function used. E.g...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/qdrant.html
46209c3a05aa-6
with_vectors=False, # Langchain does not expect vectors to be returned score_threshold=score_threshold, consistency=consistency, **kwargs, ) return [ ( self._document_from_scored_point( result, self.content_payload_key,...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/qdrant.html
46209c3a05aa-7
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 that determines the degree ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/qdrant.html
46209c3a05aa-8
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, ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/qdrant.html
46209c3a05aa-9
location: If `:memory:` - use in-memory Qdrant instance. If `str` - use it as a `url` parameter. If `None` - fallback to relying on `host` and `port` parameters. url: either host or str of "Optional[scheme], host, Optional[port], Optional[prefi...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/qdrant.html
46209c3a05aa-10
Default: "Cosine" content_payload_key: A payload key used to store the content of the document. Default: "page_content" metadata_payload_key: A payload key used to store the metadata of the document. Default: "metadata" ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/qdrant.html
46209c3a05aa-11
**kwargs: Additional arguments passed directly into REST client initialization This is a user-friendly interface that: 1. Creates embeddings, one for each text 2. Initializes the Qdrant database as an in-memory docstore by default (and overridable to a remote docstore)...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/qdrant.html
46209c3a05aa-12
) client.recreate_collection( collection_name=collection_name, vectors_config=rest.VectorParams( size=vector_size, distance=rest.Distance[distance_func], ), shard_number=shard_number, replication_factor=replication_facto...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/qdrant.html
46209c3a05aa-13
embeddings=embedding, content_payload_key=content_payload_key, metadata_payload_key=metadata_payload_key, ) @classmethod def _build_payloads( cls, texts: Iterable[str], metadatas: Optional[List[dict]], content_payload_key: str, metadata_pay...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/qdrant.html
46209c3a05aa-14
for _value in value: if isinstance(_value, dict): out.extend(self._build_condition(f"{key}[]", _value)) else: out.extend(self._build_condition(f"{key}", _value)) else: out.append( rest.FieldCondition( ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/qdrant.html
46209c3a05aa-15
Args: texts: Iterable of texts to embed. Returns: List of floats representing the texts embedding. """ if self.embeddings is not None: embeddings = self.embeddings.embed_documents(list(texts)) if hasattr(embeddings, "tolist"): embed...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/qdrant.html
20f80b0c4075-0
Source code for langchain.vectorstores.hologres """VectorStore wrapper around a Hologres database.""" from __future__ import annotations import json import logging import uuid from typing import Any, Dict, Iterable, List, Optional, Tuple, Type from langchain.docstore.document import Document from langchain.embeddings.b...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/hologres.html
20f80b0c4075-1
'{"embedding":{"algorithm":"Graph", "distance_method":"SquaredEuclidean", "build_params":{"min_flush_proxima_row_count" : 1, "min_compaction_proxima_row_count" : 1, "max_total_size_to_merge_mb" : 2000}}}');""" ) self.conn.commit() def get_by_id(self, id: str) -> List[Tuple]: statement = ( ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/hologres.html
20f80b0c4075-2
params.append(key) params.append(val) filter_clause = "where " + " and ".join(conjuncts) sql = ( f"select document, metadata::text, " f"pm_approx_squared_euclidean_distance(array{json.dumps(embedding)}" f"::float4[], embedding) as distance from" ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/hologres.html
20f80b0c4075-3
) -> None: self.connection_string = connection_string self.ndims = ndims self.table_name = table_name self.embedding_function = embedding_function self.pre_delete_table = pre_delete_table self.logger = logger or logging.getLogger(__name__) self.__post_init__() ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/hologres.html
20f80b0c4075-4
embedding_function=embedding_function, ndims=ndims, table_name=table_name, pre_delete_table=pre_delete_table, ) store.add_embeddings( texts=texts, embeddings=embeddings, metadatas=metadatas, ids=ids, **kwargs ) return store [docs] def ad...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/hologres.html
20f80b0c4075-5
List of ids from adding the texts into the vectorstore. """ if ids is None: ids = [str(uuid.uuid1()) for _ in texts] embeddings = self.embedding_function.embed_documents(list(texts)) if not metadatas: metadatas = [{} for _ in texts] self.add_embeddings(tex...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/hologres.html
20f80b0c4075-6
Returns: List of Documents most similar to the query vector. """ docs_and_scores = self.similarity_search_with_score_by_vector( embedding=embedding, k=k, filter=filter ) return [doc for doc, _ in docs_and_scores] [docs] def similarity_search_with_score( ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/hologres.html
20f80b0c4075-7
] return docs [docs] @classmethod def from_texts( cls: Type[Hologres], texts: List[str], embedding: Embeddings, metadatas: Optional[List[dict]] = None, ndims: int = ADA_TOKEN_COUNT, table_name: str = _LANGCHAIN_DEFAULT_TABLE_NAME, ids: Optional[List...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/hologres.html
20f80b0c4075-8
Return VectorStore initialized from documents and embeddings. Postgres connection string is required "Either pass it as a parameter or set the HOLOGRES_CONNECTION_STRING environment variable. Example: .. code-block:: python from langchain import Hologres ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/hologres.html
20f80b0c4075-9
embedding_function=embedding, pre_delete_table=pre_delete_table, ) return store [docs] @classmethod def get_connection_string(cls, kwargs: Dict[str, Any]) -> str: connection_string: str = get_from_dict_or_env( data=kwargs, key="connection_string", ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/hologres.html
20f80b0c4075-10
ndims=ndims, table_name=table_name, **kwargs, ) [docs] @classmethod def connection_string_from_db_params( cls, host: str, port: int, database: str, user: str, password: str, ) -> str: """Return connection string from data...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/hologres.html
889538c38d3a-0
Source code for langchain.vectorstores.sklearn """ Wrapper around scikit-learn NearestNeighbors implementation. The vector store can be persisted in json, bson or parquet format. """ import json import math import os from abc import ABC, abstractmethod from typing import Any, Dict, Iterable, List, Literal, Optional, Tu...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/sklearn.html
889538c38d3a-1
with open(self.persist_path, "r") as fp: return json.load(fp) class BsonSerializer(BaseSerializer): """Serializes data in binary json using the bson python package.""" def __init__(self, persist_path: str) -> None: super().__init__(persist_path) self.bson = guard_import("bson") @...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/sklearn.html
889538c38d3a-2
raise exc else: os.remove(backup_path) else: self.pq.write_table(table, self.persist_path) def load(self) -> Any: table = self.pq.read_table(self.persist_path) df = table.to_pandas() return {col: series.tolist() for col, series in df.items()} S...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/sklearn.html
889538c38d3a-3
# data properties self._embeddings: List[List[float]] = [] self._texts: List[str] = [] self._metadatas: List[dict] = [] self._ids: List[str] = [] # cache properties self._embeddings_np: Any = np.asarray([]) if self._persist_path is not None and os.path.isfile(self...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/sklearn.html
889538c38d3a-4
) -> List[str]: _texts = list(texts) _ids = ids or [str(uuid4()) for _ in _texts] self._texts.extend(_texts) self._embeddings.extend(self._embedding_function.embed_documents(_texts)) self._metadatas.extend(metadatas or ([{}] * len(_texts))) self._ids.extend(_ids) ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/sklearn.html
889538c38d3a-5
query_embedding = self._embedding_function.embed_query(query) indices_dists = self._similarity_index_search_with_score( query_embedding, k=k, **kwargs ) return [ ( Document( page_content=self._texts[idx], metadata={"...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/sklearn.html
889538c38d3a-6
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...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/sklearn.html
889538c38d3a-7
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. lambda_mult: Number between 0 and 1 that determines the degree ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/sklearn.html
efa99fd80b9c-0
Source code for langchain.vectorstores.myscale """Wrapper around MyScale vector database.""" 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 pydantic import BaseSettings from langchain....
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/myscale.html
efa99fd80b9c-1
.. code-block:: python { 'id': 'text_id', 'vector': 'text_embedding', 'text': 'text_plain', 'metadata': 'metadata_dictionary_in_json', ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/myscale.html
efa99fd80b9c-2
config: Optional[MyScaleSettings] = None, **kwargs: Any, ) -> None: """MyScale Wrapper to LangChain embedding_function (Embeddings): config (MyScaleSettings): Configuration to MyScale Client Other keyword arguments will pass into [clickhouse-connect](https://docs....
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/myscale.html
efa99fd80b9c-3
CREATE TABLE IF NOT EXISTS {self.config.database}.{self.config.table}( {self.config.column_map['id']} String, {self.config.column_map['text']} String, {self.config.column_map['vector']} Array(Float32), {self.config.column_map['metadata']} JSON, ...
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/vectorstores/myscale.html