id
stringlengths
14
15
text
stringlengths
49
2.47k
source
stringlengths
61
166
13ba630d8980-36
cls, scored_point: Any, content_payload_key: str, metadata_payload_key: str, ) -> Document: return Document( page_content=scored_point.payload.get(content_payload_key), metadata=scored_point.payload.get(metadata_payload_key) or {}, ) @classmethod ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
13ba630d8980-37
self, filter: Optional[DictFilter] ) -> Optional[rest.Filter]: from qdrant_client.http import models as rest if not filter: return None return rest.Filter( must=[ condition for key, value in filter.items() for condition ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
13ba630d8980-38
if hasattr(embeddings, "tolist"): embedding = embedding.tolist() embeddings.append(embedding) else: raise ValueError("Neither of embeddings or embedding_function is set") return embeddings def _generate_rest_batches( self, texts: Iterab...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/qdrant.html
f5e7d92f5acf-0
Source code for langchain.vectorstores.mongodb_atlas from __future__ import annotations import logging from typing import ( TYPE_CHECKING, Any, Dict, Generator, Iterable, List, Optional, Tuple, TypeVar, Union, ) import numpy as np from langchain.docstore.document import Document ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/mongodb_atlas.html
f5e7d92f5acf-1
embedding_key: str = "embedding", ): """ Args: collection: MongoDB collection to add the texts to. embedding: Text embedding model to use. text_key: MongoDB field that will contain the text for each document. embedding_key: MongoDB fiel...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/mongodb_atlas.html
f5e7d92f5acf-2
metadatas: Optional list of metadatas associated with the texts. Returns: List of ids from adding the texts into the vectorstore. """ batch_size = kwargs.get("batch_size", DEFAULT_INSERT_BATCH_SIZE) _metadatas: Union[List, Generator] = metadatas or ({} for _ in texts) ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/mongodb_atlas.html
f5e7d92f5acf-3
pre_filter: Optional[dict] = None, post_filter_pipeline: Optional[List[Dict]] = None, ) -> List[Tuple[Document, float]]: knn_beta = { "vector": embedding, "path": self._embedding_key, "k": k, } if pre_filter: knn_beta["filter"] = pre_fi...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/mongodb_atlas.html
f5e7d92f5acf-4
may introduce breaking changes. For more: https://www.mongodb.com/docs/atlas/atlas-search/knn-beta Args: query: Text to look up documents similar to. k: Optional Number of Documents to return. Defaults to 4. pre_filter: Optional Dictionary of argument(s) to prefilter ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/mongodb_atlas.html
f5e7d92f5acf-5
pre_filter: Optional Dictionary of argument(s) to prefilter on document fields. post_filter_pipeline: Optional Pipeline of MongoDB aggregation stages following the knnBeta search. Returns: List of Documents most similar to the query and score for each ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/mongodb_atlas.html
f5e7d92f5acf-6
following the knnBeta search. Returns: List of Documents selected by maximal marginal relevance. """ query_embedding = self._embedding.embed_query(query) docs = self._similarity_search_with_score( query_embedding, k=fetch_k, pre_filter=pre_...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/mongodb_atlas.html
f5e7d92f5acf-7
vectorstore = MongoDBAtlasVectorSearch.from_texts( texts, embeddings, metadatas=metadatas, collection=collection ) """ if collection is None: raise ValueError("Must provide 'collection' named para...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/mongodb_atlas.html
4d4a7cedbb49-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...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/hologres.html
4d4a7cedbb49-1
+ """, 'proxima_vectors', '{"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() [docs] def get_by_id(self, id: str) -> Lis...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/hologres.html
4d4a7cedbb49-2
conjuncts.append("metadata->>%s=%s") 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)}" ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/hologres.html
4d4a7cedbb49-3
logger: Optional[logging.Logger] = None, ) -> 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.getLogg...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/hologres.html
4d4a7cedbb49-4
metadatas = [{} for _ in texts] connection_string = cls.get_connection_string(kwargs) store = cls( connection_string=connection_string, embedding_function=embedding_function, ndims=ndims, table_name=table_name, pre_delete_table=pre_delete_table...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/hologres.html
4d4a7cedbb49-5
Args: texts: Iterable of strings to add to the vectorstore. metadatas: Optional list of metadatas associated with the texts. kwargs: vectorstore specific parameters Returns: List of ids from adding the texts into the vectorstore. """ if ids is None...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/hologres.html
4d4a7cedbb49-6
"""Return docs most similar to embedding vector. Args: embedding: Embedding to look up documents similar to. k: Number of Documents to return. Defaults to 4. filter (Optional[Dict[str, str]]): Filter by metadata. Defaults to None. Returns: List of Document...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/hologres.html
4d4a7cedbb49-7
embedding, k, filter ) docs = [ ( Document( page_content=result[0], metadata=json.loads(result[1]), ), result[2], ) for result in results ] return docs [docs] @c...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/hologres.html
4d4a7cedbb49-8
pre_delete_table: bool = False, **kwargs: Any, ) -> Hologres: """Construct Hologres wrapper from raw documents and pre- generated embeddings. Return VectorStore initialized from documents and embeddings. Postgres connection string is required "Either pass it as a para...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/hologres.html
4d4a7cedbb49-9
embeddings """ connection_string = cls.get_connection_string(kwargs) store = cls( connection_string=connection_string, ndims=ndims, table_name=table_name, embedding_function=embedding, pre_delete_table=pre_delete_table, ) ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/hologres.html
4d4a7cedbb49-10
return cls.from_texts( texts=texts, pre_delete_collection=pre_delete_collection, embedding=embedding, metadatas=metadatas, ids=ids, ndims=ndims, table_name=table_name, **kwargs, ) [docs] @classmethod def conne...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/hologres.html
3039b2c69ed8-0
Source code for langchain.vectorstores.milvus """Wrapper around the Milvus vector database.""" from __future__ import annotations import logging from typing import Any, Iterable, List, Optional, Tuple, Union from uuid import uuid4 import numpy as np from langchain.docstore.document import Document from langchain.embedd...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/milvus.html
3039b2c69ed8-1
Defaults to "Session". index_params (Optional[dict]): Which index params to use. Defaults to HNSW/AUTOINDEX depending on service. search_params (Optional[dict]): Which search params to use. Defaults to default of index. drop_old (Optional[bool]): Whether to drop the curre...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/milvus.html
3039b2c69ed8-2
write the client.pem path. ca_pem_path (str): If use tls two-way authentication, need to write the ca.pem path. server_pem_path (str): If use tls one-way authentication, need to write the server.pem path. server_name (str): If use tls, need to write the common name. E...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/milvus.html
3039b2c69ed8-3
# Default search params when one is not provided. self.default_search_params = { "IVF_FLAT": {"metric_type": "L2", "params": {"nprobe": 10}}, "IVF_SQ8": {"metric_type": "L2", "params": {"nprobe": 10}}, "IVF_PQ": {"metric_type": "L2", "params": {"nprobe": 10}}, "HN...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/milvus.html
3039b2c69ed8-4
self._text_field = "text" # In order for compatibility, the vector field needs to be called "vector" self._vector_field = "vector" self.fields: list[str] = [] # Create the connection to the server if connection_args is None: connection_args = DEFAULT_MILVUS_CONNECTION...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/milvus.html
3039b2c69ed8-5
elif uri is not None: given_address = uri.split("https://")[1] elif address is not None: given_address = address else: given_address = None logger.debug("Missing standard address type for reuse atttempt") # User defaults to empty string when gettin...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/milvus.html
3039b2c69ed8-6
self._load() def _create_collection( self, embeddings: list, metadatas: Optional[list[dict]] = None ) -> None: from pymilvus import ( Collection, CollectionSchema, DataType, FieldSchema, MilvusException, ) from pymilvus....
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/milvus.html
3039b2c69ed8-7
# Create the vector field, supports binary or float vectors fields.append( FieldSchema(self._vector_field, infer_dtype_bydata(embeddings[0]), dim=dim) ) # Create the schema for the collection schema = CollectionSchema(fields) # Create the collection try: ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/milvus.html
3039b2c69ed8-8
if self.index_params is None: self.index_params = { "metric_type": "L2", "index_type": "HNSW", "params": {"M": 8, "efConstruction": 64}, } try: self.col.create_index( ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/milvus.html
3039b2c69ed8-9
def _load(self) -> None: """Load the collection if available.""" from pymilvus import Collection if isinstance(self.col, Collection) and self._get_index() is not None: self.col.load() [docs] def add_texts( self, texts: Iterable[str], metadatas: Optional[Lis...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/milvus.html
3039b2c69ed8-10
embeddings = self.embedding_func.embed_documents(texts) except NotImplementedError: embeddings = [self.embedding_func.embed_query(x) for x in texts] if len(embeddings) == 0: logger.debug("Nothing to insert, skipping.") return [] # If the collection hasn't been...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/milvus.html
3039b2c69ed8-11
) raise e return pks [docs] def similarity_search( self, query: str, k: int = 4, param: Optional[dict] = None, expr: Optional[str] = None, timeout: Optional[int] = None, **kwargs: Any, ) -> List[Document]: """Perform a simila...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/milvus.html
3039b2c69ed8-12
Args: embedding (List[float]): The embedding vector to search. k (int, optional): How many results to return. Defaults to 4. param (dict, optional): The search params for the index type. Defaults to None. expr (str, optional): Filtering expression. Default...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/milvus.html
3039b2c69ed8-13
param (dict): The search params for the specified index. Defaults to None. expr (str, optional): Filtering expression. Defaults to None. timeout (int, optional): How long to wait before timeout error. Defaults to None. kwargs: Collection.search() keywo...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/milvus.html
3039b2c69ed8-14
expr (str, optional): Filtering expression. Defaults to None. timeout (int, optional): How long to wait before timeout error. Defaults to None. kwargs: Collection.search() keyword arguments. Returns: List[Tuple[Document, float]]: Result doc and score. ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/milvus.html
3039b2c69ed8-15
"""Perform a search and return results that are reordered by MMR. Args: query (str): The text being searched. k (int, optional): How many results to give. Defaults to 4. fetch_k (int, optional): Total results to select k from. Defaults to 20. lambd...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/milvus.html
3039b2c69ed8-16
expr: Optional[str] = None, timeout: Optional[int] = None, **kwargs: Any, ) -> List[Document]: """Perform a search and return results that are reordered by MMR. Args: embedding (str): The embedding vector being searched. k (int, optional): How many results to ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/milvus.html
3039b2c69ed8-17
ids = [] documents = [] scores = [] for result in res[0]: meta = {x: result.entity.get(x) for x in output_fields} doc = Document(page_content=meta.pop(self._text_field), metadata=meta) documents.append(doc) scores.append(result.score) i...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/milvus.html
3039b2c69ed8-18
search_params: Optional[dict] = None, drop_old: bool = False, **kwargs: Any, ) -> Milvus: """Create a Milvus collection, indexes it with HNSW, and insert data. Args: texts (List[str]): Text data. embedding (Embeddings): Embedding function. metadata...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/milvus.html
3ebb4a9075e0-0
Source code for langchain.vectorstores.chroma """Wrapper around ChromaDB embeddings platform.""" from __future__ import annotations import logging import uuid from typing import ( TYPE_CHECKING, Any, Callable, Dict, Iterable, List, Optional, Tuple, Type, ) import numpy as np from lan...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/chroma.html
3ebb4a9075e0-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 = "...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/chroma.html
3ebb4a9075e0-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...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/chroma.html
3ebb4a9075e0-3
n_results: int = 4, where: 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 pytho...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/chroma.html
3ebb4a9075e0-4
if metadatas: # fill metadatas with empty dicts if somebody # did not specify metadata for all texts length_diff = len(texts) - len(metadatas) if length_diff: metadatas = metadatas + [{}] * length_diff empty_ids = [] non_empty_ids =...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/chroma.html
3ebb4a9075e0-5
embeddings=embeddings, documents=texts, ids=ids, ) return ids [docs] def similarity_search( self, query: str, k: int = DEFAULT_K, filter: Optional[Dict[str, str]] = None, **kwargs: Any, ) -> List[Document]: """Run...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/chroma.html
3ebb4a9075e0-6
[docs] def similarity_search_by_vector_with_relevance_scores( self, embedding: List[float], k: int = DEFAULT_K, filter: Optional[Dict[str, str]] = None, **kwargs: Any, ) -> List[Tuple[Document, float]]: """ Return docs most similar to embedding vector and s...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/chroma.html
3ebb4a9075e0-7
Lower score represents more similarity. """ if self._embedding_function is None: results = self.__query_collection( query_texts=[query], n_results=k, where=filter ) else: query_embedding = self._embedding_function.embed_query(query) ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/chroma.html
3ebb4a9075e0-8
self, embedding: List[float], k: int = DEFAULT_K, fetch_k: int = 20, lambda_mult: float = 0.5, filter: Optional[Dict[str, str]] = None, **kwargs: Any, ) -> List[Document]: """Return docs selected using the maximal marginal relevance. Maximal marginal r...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/chroma.html
3ebb4a9075e0-9
[docs] def max_marginal_relevance_search( self, query: str, k: int = DEFAULT_K, fetch_k: int = 20, lambda_mult: float = 0.5, filter: Optional[Dict[str, str]] = None, **kwargs: Any, ) -> List[Document]: """Return docs selected using the maximal margi...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/chroma.html
3ebb4a9075e0-10
self, ids: Optional[OneOrMany[ID]] = None, where: Optional[Where] = None, limit: Optional[int] = None, offset: Optional[int] = None, where_document: Optional[WhereDocument] = None, include: Optional[List[str]] = None, ) -> Dict[str, Any]: """Gets the collectio...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/chroma.html
3ebb4a9075e0-11
It will also be called automatically when the object is destroyed. """ if self._persist_directory is None: raise ValueError( "You must specify a persist_directory on" "creation to persist the collection." ) import chromadb # Maintai...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/chroma.html
3ebb4a9075e0-12
client: Optional[chromadb.Client] = None, collection_metadata: Optional[Dict] = None, **kwargs: Any, ) -> Chroma: """Create a Chroma vectorstore from a raw documents. If a persist_directory is specified, the collection will be persisted there. Otherwise, the data will be ephe...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/chroma.html
3ebb4a9075e0-13
collection_name: str = _LANGCHAIN_DEFAULT_COLLECTION_NAME, persist_directory: Optional[str] = None, client_settings: Optional[chromadb.config.Settings] = None, client: Optional[chromadb.Client] = None, # Add this line collection_metadata: Optional[Dict] = None, **kwargs: Any, ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/chroma.html
3ebb4a9075e0-14
"""Delete by vector IDs. Args: ids: List of ids to delete. """ self._collection.delete(ids=ids)
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/chroma.html
cbcbe9768f05-0
Source code for langchain.vectorstores.rocksetdb """Wrapper around Rockset vector database.""" from __future__ import annotations import logging from enum import Enum from typing import Any, Iterable, List, Optional, Tuple from langchain.docstore.document import Document from langchain.embeddings.base import Embeddings...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/rocksetdb.html
cbcbe9768f05-1
collection_name: str, text_key: str, embedding_key: str, workspace: str = "commons", ): """Initialize with Rockset client. Args: client: Rockset client object collection: Rockset collection to insert docs / query embeddings: Langchain Embed...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/rocksetdb.html
cbcbe9768f05-2
batch_size: int = 32, **kwargs: Any, ) -> List[str]: """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. id...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/rocksetdb.html
cbcbe9768f05-3
batch_size: int = 32, **kwargs: Any, ) -> Rockset: """Create Rockset wrapper with existing texts. This is intended as a quicker way to get started. """ # Sanitize imputs assert client is not None, "Rockset Client cannot be None" assert collection_name, "Collec...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/rocksetdb.html
cbcbe9768f05-4
vectors in Rockset. k (int, optional): Top K neighbors to retrieve. Defaults to 4. where_str (Optional[str], optional): Metadata filters supplied as a SQL `where` condition string. Defaults to None. eg. "price<=70.0 AND brand='Nintendo'" NOTE: Please d...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/rocksetdb.html
cbcbe9768f05-5
"""Accepts a query_embedding (vector), and returns documents with similar embeddings.""" docs_and_scores = self.similarity_search_by_vector_with_relevance_scores( embedding, k, distance_func, where_str, **kwargs ) return [doc for doc, _ in docs_and_scores] [docs] def simil...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/rocksetdb.html
cbcbe9768f05-6
self._text_key, type(v) ) page_content = v elif k == "dist": assert isinstance( v, float ), "Computed distance between vectors must of type `float`. \ But found {}".format( ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/rocksetdb.html
cbcbe9768f05-7
collection=self._collection_name, data=batch, workspace=self._workspace ) return [doc_status._id for doc_status in add_doc_res.data] [docs] def delete_texts(self, ids: List[str]) -> None: """Delete a list of docs from the Rockset collection""" try: from rockset.models impo...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/rocksetdb.html
21efb6091a59-0
Source code for langchain.vectorstores.supabase from __future__ import annotations import uuid from itertools import repeat from typing import ( TYPE_CHECKING, Any, Dict, Iterable, List, Optional, Tuple, Type, Union, ) import numpy as np from langchain.docstore.document import Docume...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/supabase.html
21efb6091a59-1
] embeddings = OpenAIEmbeddings() supabase_client = create_client("my_supabase_url", "my_supabase_key") vector_store = SupabaseVectorStore.from_documents( docs, embeddings, client=supabase_client, table_name="documents", query_name="mat...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/supabase.html
21efb6091a59-2
@property def embeddings(self) -> Embeddings: return self._embedding [docs] def add_texts( self, texts: Iterable[str], metadatas: Optional[List[Dict[Any, Any]]] = None, ids: Optional[List[str]] = None, **kwargs: Any, ) -> List[str]: ids = ids or [str(uu...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/supabase.html
21efb6091a59-3
client=client, embedding=embedding, table_name=table_name, query_name=query_name, ) [docs] def add_vectors( self, vectors: List[List[float]], documents: List[Document], ids: List[str], ) -> List[str]: return self._add_vectors(sel...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/supabase.html
21efb6091a59-4
return self.similarity_search_by_vector_with_relevance_scores( vectors[0], k=k, filter=filter ) [docs] def match_args( self, query: List[float], k: int, filter: Optional[Dict[str, Any]] ) -> Dict[str, Any]: ret = dict(query_embedding=query, match_count=k) if filter: ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/supabase.html
21efb6091a59-5
page_content=search.get("content", ""), ), search.get("similarity", 0.0), # Supabase returns a vector type as its string represation (!). # This is a hack to convert the string to numpy array. np.fromstring( search.get("...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/supabase.html
21efb6091a59-6
# is 500 chunk_size = 500 id_list: List[str] = [] for i in range(0, len(rows), chunk_size): chunk = rows[i : i + chunk_size] result = client.from_(table_name).upsert(chunk).execute() # type: ignore if len(result.data) == 0: raise Exception("Er...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/supabase.html
21efb6091a59-7
) matched_documents = [doc_tuple[0] for doc_tuple in result] matched_embeddings = [doc_tuple[2] for doc_tuple in result] mmr_selected = maximal_marginal_relevance( np.array([embedding], dtype=np.float32), matched_embeddings, k=k, lambda_mult=lambda...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/supabase.html
21efb6091a59-8
id uuid, content text, metadata jsonb, embedding vector(1536), similarity float) LANGUAGE plpgsql AS $$ # variable_conflict use_column BEGIN RETURN query SELECT id, ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/supabase.html
2784022ddcff-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....
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/myscale.html
2784022ddcff-1
column_map (Dict) : Column type map to project column name onto langchain semantics. Must have keys: `text`, `id`, `vector`, must be same size to number of columns. For example: .. code-block:: python { ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/myscale.html
2784022ddcff-2
constraints and even sub-queries. For more information, please visit [myscale official site](https://docs.myscale.com/en/overview/) """ [docs] def __init__( self, embedding: Embeddings, config: Optional[MyScaleSettings] = None, **kwargs: Any, ) -> None: """...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/myscale.html
2784022ddcff-3
dim = len(embedding.embed_query("try this out")) index_params = ( ", " + ",".join([f"'{k}={v}'" for k, v in self.config.index_param.items()]) if self.config.index_param else "" ) schema_ = f""" CREATE TABLE IF NOT EXISTS {self.config.database}.{sel...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/myscale.html
2784022ddcff-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) def _build_istr(self, transac: Iterable, column_names: Iterable[str]) -> str: ks = ",".join(column_names) _data = [] for n in transac: n = ","...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/myscale.html
2784022ddcff-5
""" # Embed and create the documents ids = ids or [sha1(t.encode("utf-8")).hexdigest() for t in texts] colmap_ = self.config.column_map transac = [] column_names = { colmap_["id"]: ids, colmap_["text"]: texts, colmap_["vector"]: map(self._embed...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/myscale.html
2784022ddcff-6
cls, texts: Iterable[str], embedding: Embeddings, metadatas: Optional[List[Dict[Any, Any]]] = None, config: Optional[MyScaleSettings] = None, text_ids: Optional[Iterable[str]] = None, batch_size: int = 32, **kwargs: Any, ) -> MyScale: """Create Myscale...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/myscale.html
2784022ddcff-7
_repr += f"\033[1musername: {self.config.username}\033[0m\n\nTable Schema:\n" _repr += "-" * 51 + "\n" for r in self.client.query( f"DESC {self.config.database}.{self.config.table}" ).named_results(): _repr += ( f"|\033[94m{r['name']:24s}\033[0m|\033[96m{r...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/myscale.html
2784022ddcff-8
Args: query (str): query string k (int, optional): Top K neighbors to retrieve. Defaults to 4. where_str (Optional[str], optional): where condition string. Defaults to None. NOTE: Please do not let end-user to fill this and...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/myscale.html
2784022ddcff-9
Document( page_content=r[self.config.column_map["text"]], metadata=r[self.config.column_map["metadata"]], ) for r in self.client.query(q_str).named_results() ] except Exception as e: logger.error(f"\033[91m\033[1m{ty...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/myscale.html
2784022ddcff-10
), r["dist"], ) for r in self.client.query(q_str).named_results() ] except Exception as e: logger.error(f"\033[91m\033[1m{type(e)}\033[0m \033[95m{str(e)}\033[0m") return [] [docs] def drop(self) -> None: """ ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/myscale.html
b0239527e9ed-0
Source code for langchain.vectorstores.tigris from __future__ import annotations import itertools from typing import TYPE_CHECKING, Any, Iterable, List, Optional, Tuple from langchain.embeddings.base import Embeddings from langchain.schema import Document from langchain.vectorstores import VectorStore if TYPE_CHECKING:...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/tigris.html
b0239527e9ed-1
"""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 for documents. Ids will be autogenerated...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/tigris.html
b0239527e9ed-2
text with distance in float. """ vector = self._embed_fn.embed_query(query) result = self.search_index.similarity_search( vector=vector, k=k, filter_by=filter ) docs: List[Tuple[Document, float]] = [] for r in result: docs.append( (...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/tigris.html
b0239527e9ed-3
for t, m, e, _id in itertools.zip_longest( texts, metadatas or [], embeddings or [], ids or [] ): doc: TigrisDocument = { "text": t, "embeddings": e or [], "metadata": m or {}, } if _id: doc["id"] = _...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/tigris.html
113b00c10c02-0
Source code for langchain.vectorstores.clickhouse """Wrapper around open source ClickHouse VectorSearch capability.""" 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, Union from pydantic im...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/clickhouse.html
113b00c10c02-1
Defaults to 'vector_table'. metric (str) : Metric to compute distance, supported are ('angular', 'euclidean', 'manhattan', 'hamming', 'dot'). Defaults to 'angular'. https://github.com/spotify/annoy/blob/main/src/annoymodule.cc#L149-L169 ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/clickhouse.html
113b00c10c02-2
return getattr(self, item) class Config: env_file = ".env" env_prefix = "clickhouse_" env_file_encoding = "utf-8" [docs]class Clickhouse(VectorStore): """Wrapper around ClickHouse vector database You need a `clickhouse-connect` python package, and a valid account to connect to Cl...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/clickhouse.html
113b00c10c02-3
assert self.config assert self.config.host and self.config.port assert ( self.config.column_map and self.config.database and self.config.table and self.config.metric ) for k in ["id", "embedding", "document", "metadata", "uuid"]: ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/clickhouse.html
113b00c10c02-4
""" self.dim = dim self.BS = "\\" self.must_escape = ("\\", "'") self.embedding_function = embedding self.dist_order = "ASC" # Only support ConsingDistance and L2Distance # Create a connection to clickhouse self.client = get_client( host=self.config.h...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/clickhouse.html
113b00c10c02-5
self.client.command(_insert_query) [docs] def add_texts( self, texts: Iterable[str], metadatas: Optional[List[dict]] = None, batch_size: int = 32, ids: Optional[Iterable[str]] = None, **kwargs: Any, ) -> List[str]: """Insert more texts through the embedding...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/clickhouse.html
113b00c10c02-6
) transac.append(v) if len(transac) == batch_size: if t: t.join() t = Thread(target=self._insert, args=[transac, keys]) t.start() transac = [] if len(transac) > 0: ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/clickhouse.html
113b00c10c02-7
Other keyword arguments will pass into [clickhouse-connect](https://clickhouse.com/docs/en/integrations/python#clickhouse-connect-driver-api) Returns: ClickHouse Index """ ctx = cls(embedding, config, **kwargs) ctx.add_texts(texts, ids=text_ids, batch_size=bat...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/clickhouse.html
113b00c10c02-8
if where_str: where_str = f"PREWHERE {where_str}" else: where_str = "" settings_strs = [] if self.config.index_query_params: for k in self.config.index_query_params: settings_strs.append(f"SETTING {k}={self.config.index_query_params[k]}") ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/clickhouse.html
113b00c10c02-9
self.embedding_function.embed_query(query), k, where_str, **kwargs ) [docs] def similarity_search_by_vector( self, embedding: List[float], k: int = 4, where_str: Optional[str] = None, **kwargs: Any, ) -> List[Document]: """Perform a similarity search with C...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/clickhouse.html
113b00c10c02-10
) -> List[Tuple[Document, float]]: """Perform a similarity search with ClickHouse Args: query (str): query string k (int, optional): Top K neighbors to retrieve. Defaults to 4. where_str (Optional[str], optional): where condition string. ...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/clickhouse.html
a228a16b6200-0
Source code for langchain.vectorstores.analyticdb """VectorStore wrapper around a Postgres/PGVector database.""" from __future__ import annotations import logging import uuid from typing import Any, Callable, Dict, Iterable, List, Optional, Sequence, Tuple, Type from sqlalchemy import REAL, Column, String, Table, creat...
https://api.python.langchain.com/en/latest/_modules/langchain/vectorstores/analyticdb.html