id
stringlengths
14
16
text
stringlengths
13
2.7k
source
stringlengths
57
178
9cdde1982c83-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...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/supabase.html
9cdde1982c83-2
self.query_name = query_name or "match_documents" self.chunk_size = chunk_size or 500 # According to the SupabaseVectorStore JS implementation, the best chunk size # is 500. Though for large datasets it can be too large so it is configurable. @property def embeddings(self) -> Embeddings:...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/supabase.html
9cdde1982c83-3
embeddings = embedding.embed_documents(texts) ids = [str(uuid.uuid4()) for _ in texts] docs = cls._texts_to_documents(texts, metadatas) cls._add_vectors(client, table_name, embeddings, docs, ids, chunk_size) return cls( client=client, embedding=embedding, ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/supabase.html
9cdde1982c83-4
self, query: str, k: int = 4, filter: Optional[Dict[str, Any]] = None, **kwargs: Any, ) -> List[Tuple[Document, float]]: vector = self._embedding.embed_query(query) return self.similarity_search_by_vector_with_relevance_scores( vector, k=k, filter=filter ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/supabase.html
9cdde1982c83-5
if search.get("content") ] return match_result [docs] def similarity_search_by_vector_returning_embeddings( self, query: List[float], k: int, filter: Optional[Dict[str, Any]] = None, postgrest_filter: Optional[str] = None, ) -> List[Tuple[Document, float, n...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/supabase.html
9cdde1982c83-6
if metadatas is None: metadatas = repeat({}) docs = [ Document(page_content=text, metadata=metadata) for text, metadata in zip(texts, metadatas) ] return docs @staticmethod def _add_vectors( client: supabase.client.Client, table_name: s...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/supabase.html
9cdde1982c83-7
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: embedding: Embedding to look up d...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/supabase.html
9cdde1982c83-8
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 return. Defaults to 4. fetch_k: Number of Documents to fetch to pass to MMR algorithm. ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/supabase.html
9cdde1982c83-9
"""Delete by vector IDs. Args: ids: List of ids to delete. """ if ids is None: raise ValueError("No ids provided to delete.") rows: List[Dict[str, Any]] = [ { "id": id, } for id in ids ] # TODO: C...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/supabase.html
950c0400f22a-0
Source code for langchain.vectorstores.sqlitevss from __future__ import annotations import json import logging import warnings from typing import ( TYPE_CHECKING, Any, Iterable, List, Optional, Tuple, Type, ) from langchain.docstore.document import Document from langchain.schema.embeddings i...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/sqlitevss.html
950c0400f22a-1
self._embedding = embedding self.create_table_if_not_exists() [docs] def create_table_if_not_exists(self) -> None: self._connection.execute( f""" CREATE TABLE IF NOT EXISTS {self._table} ( rowid INTEGER PRIMARY KEY AUTOINCREMENT, text TE...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/sqlitevss.html
950c0400f22a-2
max_id = 0 embeds = self._embedding.embed_documents(list(texts)) if not metadatas: metadatas = [{} for _ in texts] data_input = [ (text, json.dumps(metadata), json.dumps(embed)) for text, metadata, embed in zip(texts, metadatas, embeds) ] self....
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/sqlitevss.html
950c0400f22a-3
documents.append((doc, row["distance"])) return documents [docs] def similarity_search( self, query: str, k: int = 4, **kwargs: Any ) -> List[Document]: """Return docs most similar to query.""" embedding = self._embedding.embed_query(query) documents = self.similarity_sear...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/sqlitevss.html
950c0400f22a-4
connection = cls.create_connection(db_file) vss = cls( table=table, connection=connection, db_file=db_file, embedding=embedding ) vss.add_texts(texts=texts, metadatas=metadatas) return vss [docs] @staticmethod def create_connection(db_file: str) -> sqlite3.Connection: ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/sqlitevss.html
2afc1092a31b-0
Source code for langchain.vectorstores.awadb from __future__ import annotations import logging import uuid from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Optional, Set, Tuple, Type import numpy as np from langchain.docstore.document import Document from langchain.schema.embeddings import Embeddings from l...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/awadb.html
2afc1092a31b-1
"Please install it with `pip install awadb`." ) if client is not None: self.awadb_client = client else: if log_and_data_dir is not None: self.awadb_client = awadb.Client(log_and_data_dir) else: self.awadb_client = awadb.Clie...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/awadb.html
2afc1092a31b-2
""" if self.awadb_client is None: raise ValueError("AwaDB client is None!!!") embeddings = None if self.using_table_name in self.table2embeddings: embeddings = self.table2embeddings[self.using_table_name].embed_documents( list(texts) ) ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/awadb.html
2afc1092a31b-3
E.g. `{"max_price" : 15.66, "min_price": 4.20}` `price` is the metadata field, means range filter(4.20<'price'<15.66). E.g. `{"maxe_price" : 15.66, "mine_price": 4.20}` `price` is the metadata field, means range filter(4.20<='price'<=15.66). kwargs: Any possible extend pa...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/awadb.html
2afc1092a31b-4
Args: query: Text query. k: The k most similar documents to the text query. text_in_page_content: Filter by the text in page_content of Document. meta_filter: Filter by metadata. Defaults to None. kwargs: Any possible extend parameters in the future. R...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/awadb.html
2afc1092a31b-5
[docs] def similarity_search_by_vector( self, embedding: Optional[List[float]] = None, k: int = DEFAULT_TOPN, text_in_page_content: Optional[str] = None, meta_filter: Optional[dict] = None, not_include_fields_in_metadata: Optional[Set[str]] = None, **kwargs: An...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/awadb.html
2afc1092a31b-6
if item_key in not_include_fields_in_metadata: continue meta_data[item_key] = item_detail[item_key] results.append(Document(page_content=content, metadata=meta_data)) return results [docs] def max_marginal_relevance_search( self, query: str,...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/awadb.html
2afc1092a31b-7
else: from awadb import AwaEmbedding embedding = AwaEmbedding().Embedding(query) if embedding.__len__() == 0: return [] results = self.max_marginal_relevance_search_by_vector( embedding, k, fetch_k, lambda_mult=lambda_mu...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/awadb.html
2afc1092a31b-8
""" if self.awadb_client is None: raise ValueError("AwaDB client is None!!!") results: List[Document] = [] if embedding is None: return results not_include_fields: set = {"_id", "score"} retrieved_docs = self.similarity_search_by_vector( embedd...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/awadb.html
2afc1092a31b-9
limit: The number of documents to return. Defaults to 5. Optional. Returns: Documents which satisfy the input conditions. """ if self.awadb_client is None: raise ValueError("AwaDB client is None!!!") docs_detail = self.awadb_client.Get( ids=ids, ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/awadb.html
2afc1092a31b-10
return ret ret = self.awadb_client.Delete(ids) return ret [docs] def update( self, ids: List[str], texts: Iterable[str], metadatas: Optional[List[dict]] = None, **kwargs: Any, ) -> List[str]: """Update the documents which have the specified ids. ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/awadb.html
2afc1092a31b-11
return ret [docs] def list_tables( self, **kwargs: Any, ) -> List[str]: """List all the tables created by the client.""" if self.awadb_client is None: return [] return self.awadb_client.ListAllTables() [docs] def get_current_table( self, **kw...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/awadb.html
2afc1092a31b-12
log_and_data_dir=log_and_data_dir, client=client, ) awadb_client.add_texts(texts=texts, metadatas=metadatas) return awadb_client [docs] @classmethod def from_documents( cls: Type[AwaDB], documents: List[Document], embedding: Optional[Embeddings] = None,...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/awadb.html
8f68c7541f78-0
Source code for langchain.vectorstores.pgembedding from __future__ import annotations import logging import uuid from typing import Any, Dict, Iterable, List, Optional, Tuple, Type import sqlalchemy from sqlalchemy import func from sqlalchemy.dialects.postgresql import JSON, UUID from sqlalchemy.orm import Session, rel...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/pgembedding.html
8f68c7541f78-1
) -> Tuple["CollectionStore", bool]: """ Get or create a collection. Returns [Collection, bool] where the bool is True if the collection was created. """ created = False collection = cls.get_by_name(session, name) if collection: return collection, crea...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/pgembedding.html
8f68c7541f78-2
`langchain.embeddings.base.Embeddings` interface. - `collection_name` is the name of the collection to use. (default: langchain) - NOTE: This is not the name of the table, but the name of the collection. The tables will be created when initializing the store (if not exists) So, make ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/pgembedding.html
8f68c7541f78-3
engine = sqlalchemy.create_engine(self.connection_string) conn = engine.connect() return conn [docs] def create_hnsw_extension(self) -> None: try: with Session(self._conn) as session: statement = sqlalchemy.text("CREATE EXTENSION IF NOT EXISTS embedding") ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/pgembedding.html
8f68c7541f78-4
) # Execute the queries try: with Session(self._conn) as session: # Create the HNSW index session.execute(create_index_query) session.commit() print("HNSW extension and index created successfully.") except Exception as e: ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/pgembedding.html
8f68c7541f78-5
pre_delete_collection=pre_delete_collection, ) store.add_embeddings( texts=texts, embeddings=embeddings, metadatas=metadatas, ids=ids, **kwargs ) return store [docs] def add_embeddings( self, texts: List[str], embeddings: List[List[float]], ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/pgembedding.html
8f68c7541f78-6
embedding_store = EmbeddingStore( embedding=embedding, document=text, cmetadata=metadata, custom_id=id, ) collection.embeddings.append(embedding_store) session.add(embedding_store) ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/pgembedding.html
8f68c7541f78-7
if filter is not None: filter_clauses = [] for key, value in filter.items(): IN = "in" if isinstance(value, dict) and IN in map(str.lower, value): value_case_insensitive = { k.lower(): v for k, v ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/pgembedding.html
8f68c7541f78-8
metadata=result.EmbeddingStore.cmetadata, ), result.distance if self.embedding_function is not None else None, ) for result in results ] return docs [docs] def similarity_search_by_vector( self, embedding: List[float], k:...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/pgembedding.html
8f68c7541f78-9
ids: Optional[List[str]] = None, pre_delete_collection: bool = False, **kwargs: Any, ) -> PGEmbedding: texts = [t[0] for t in text_embeddings] embeddings = [t[1] for t in text_embeddings] return cls._initialize_from_embeddings( texts, embeddings, ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/pgembedding.html
8f68c7541f78-10
def from_documents( cls: Type[PGEmbedding], documents: List[Document], embedding: Embeddings, collection_name: str = _LANGCHAIN_DEFAULT_COLLECTION_NAME, ids: Optional[List[str]] = None, pre_delete_collection: bool = False, **kwargs: Any, ) -> PGEmbedding: ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/pgembedding.html
b806188a751d-0
Source code for langchain.vectorstores.timescalevector """VectorStore wrapper around a Postgres-TimescaleVector database.""" from __future__ import annotations import enum import logging import uuid from datetime import timedelta from typing import ( TYPE_CHECKING, Any, Callable, Dict, Iterable, ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/timescalevector.html
b806188a751d-1
from langchain.embeddings.openai import OpenAIEmbeddings SERVICE_URL = "postgres://tsdbadmin:<password>@<id>.tsdb.cloud.timescale.com:<port>/tsdb?sslmode=require" COLLECTION_NAME = "state_of_the_union_test" embeddings = OpenAIEmbeddings() vectorestore = TimescaleVector.fr...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/timescalevector.html
b806188a751d-2
self._time_partition_interval = time_partition_interval self.sync_client = client.Sync( self.service_url, self.collection_name, self.num_dimensions, self._distance_strategy.value.lower(), time_partition_interval=self._time_partition_interval, ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/timescalevector.html
b806188a751d-3
metadatas = [{} for _ in texts] if service_url is None: service_url = cls.get_service_url(kwargs) store = cls( service_url=service_url, num_dimensions=num_dimensions, collection_name=collection_name, embedding=embedding, distance_st...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/timescalevector.html
b806188a751d-4
**kwargs, ) await store.aadd_embeddings( texts=texts, embeddings=embeddings, metadatas=metadatas, ids=ids, **kwargs ) return store [docs] def add_embeddings( self, texts: Iterable[str], embeddings: List[List[float]], metadatas: Optional[List...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/timescalevector.html
b806188a751d-5
kwargs: vectorstore specific parameters """ if ids is None: ids = [str(uuid.uuid1()) for _ in texts] if not metadatas: metadatas = [{} for _ in texts] records = list(zip(ids, metadatas, texts, embeddings)) await self.async_client.upsert(records) re...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/timescalevector.html
b806188a751d-6
kwargs: vectorstore specific parameters Returns: List of ids from adding the texts into the vectorstore. """ embeddings = self.embedding.embed_documents(list(texts)) return await self.aadd_embeddings( texts=texts, embeddings=embeddings, metadatas=metadatas, ids=id...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/timescalevector.html
b806188a751d-7
filter: Optional[Union[dict, list]] = None, predicates: Optional[Predicates] = None, **kwargs: Any, ) -> List[Document]: """Run similarity search with TimescaleVector with distance. Args: query (str): Query text to search for. k (int): Number of results to ret...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/timescalevector.html
b806188a751d-8
predicates=predicates, **kwargs, ) return docs [docs] async def asimilarity_search_with_score( self, query: str, k: int = 4, filter: Optional[Union[dict, list]] = None, predicates: Optional[Predicates] = None, **kwargs: Any, ) -> List[Tu...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/timescalevector.html
b806188a751d-9
"Please install it with `pip install timescale-vector`." ) return client.UUIDTimeRange(**constructor_args) [docs] def similarity_search_with_score_by_vector( self, embedding: Optional[List[float]], k: int = 4, filter: Optional[Union[dict, list]] = None, pre...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/timescalevector.html
b806188a751d-10
raise ImportError( "Could not import timescale_vector python package. " "Please install it with `pip install timescale-vector`." ) results = await self.async_client.search( embedding, limit=k, filter=filter, predicates=p...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/timescalevector.html
b806188a751d-11
embedding: Optional[List[float]], k: int = 4, filter: Optional[Union[dict, list]] = None, predicates: Optional[Predicates] = None, **kwargs: Any, ) -> List[Document]: """Return docs most similar to embedding vector. Args: embedding: Embedding to look up do...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/timescalevector.html
b806188a751d-12
embeddings, embedding, metadatas=metadatas, ids=ids, collection_name=collection_name, distance_strategy=distance_strategy, pre_delete_collection=pre_delete_collection, **kwargs, ) [docs] @classmethod async def afrom_texts...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/timescalevector.html
b806188a751d-13
ids: Optional[List[str]] = None, pre_delete_collection: bool = False, **kwargs: Any, ) -> TimescaleVector: """Construct TimescaleVector wrapper from raw documents and pre- generated embeddings. Return VectorStore initialized from documents and embeddings. Postgres con...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/timescalevector.html
b806188a751d-14
**kwargs: Any, ) -> TimescaleVector: """Construct TimescaleVector 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 parameter or set the T...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/timescalevector.html
b806188a751d-15
""" service_url = cls.get_service_url(kwargs) store = cls( service_url=service_url, collection_name=collection_name, embedding=embedding, distance_strategy=distance_strategy, pre_delete_collection=pre_delete_collection, ) return...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/timescalevector.html
b806188a751d-16
# Default strategy is to rely on distance strategy provided # in vectorstore constructor if self._distance_strategy == DistanceStrategy.COSINE: return self._cosine_relevance_score_fn elif self._distance_strategy == DistanceStrategy.EUCLIDEAN_DISTANCE: return self._euclide...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/timescalevector.html
b806188a751d-17
False otherwise, None if not implemented. """ self.sync_client.delete_by_metadata(filter) return True class IndexType(str, enum.Enum): """Enumerator for the supported Index types""" TIMESCALE_VECTOR = "tsv" PGVECTOR_IVFFLAT = "ivfflat" PGVECTOR_HNSW = "hnsw" ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/timescalevector.html
4cb2cc145e35-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 ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/mongodb_atlas.html
4cb2cc145e35-1
text_key: str = "text", embedding_key: str = "embedding", ): """ Args: collection: MongoDB collection to add the texts to. embedding: Text embedding model to use. text_key: MongoDB field that will contain the text for each document. ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/mongodb_atlas.html
4cb2cc145e35-2
) db_name, collection_name = namespace.split(".") collection = client[db_name][collection_name] return cls(collection, embedding, **kwargs) [docs] def add_texts( self, texts: Iterable[str], metadatas: Optional[List[Dict[str, Any]]] = None, **kwargs: Any, ) ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/mongodb_atlas.html
4cb2cc145e35-3
embeddings = self._embedding.embed_documents(texts) to_insert = [ {self._text_key: t, self._embedding_key: embedding, **m} for t, m, embedding in zip(texts, metadatas, embeddings) ] # insert the documents in MongoDB Atlas insert_result = self._collection.insert_ma...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/mongodb_atlas.html
4cb2cc145e35-4
query: str, *, k: int = 4, pre_filter: Optional[Dict] = None, post_filter_pipeline: Optional[List[Dict]] = None, ) -> List[Tuple[Document, float]]: """Return MongoDB documents most similar to the given query and their scores. Uses the knnBeta Operator available in Mon...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/mongodb_atlas.html
4cb2cc145e35-5
"""Return MongoDB documents most similar to the given query. Uses the knnBeta Operator available in MongoDB Atlas Search. This feature is in early access and available only for evaluation purposes, to validate functionality, and to gather feedback from a small closed group of early acces...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/mongodb_atlas.html
4cb2cc145e35-6
Args: query: Text to look up documents similar to. k: (Optional) number of documents to return. Defaults to 4. fetch_k: (Optional) number of documents to fetch before passing to MMR algorithm. Defaults to 20. lambda_mult: Number between 0 and 1 that determ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/mongodb_atlas.html
4cb2cc145e35-7
**kwargs: Any, ) -> MongoDBAtlasVectorSearch: """Construct a `MongoDB Atlas Vector Search` vector store from raw documents. This is a user-friendly interface that: 1. Embeds documents. 2. Adds the documents to a provided MongoDB Atlas Vector Search index (Luce...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/mongodb_atlas.html
32546b1c8542-0
Source code for langchain.vectorstores.astradb from __future__ import annotations import uuid import warnings from concurrent.futures import ThreadPoolExecutor from typing import ( Any, Callable, Dict, Iterable, List, Optional, Set, Tuple, Type, TypeVar, ) import numpy as np from...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/astradb.html
32546b1c8542-1
visited_keys.add(item_key) new_lst.append(item) return new_lst [docs]class AstraDB(VectorStore): """Wrapper around DataStax Astra DB for vector-store workloads. To use it, you need a recent installation of the `astrapy` library and an Astra DB cloud database. For quickstart and details, ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/astradb.html
32546b1c8542-2
namespace: Optional[str] = None, metric: Optional[str] = None, batch_size: Optional[int] = None, bulk_insert_batch_concurrency: Optional[int] = None, bulk_insert_overwrite_concurrency: Optional[int] = None, bulk_delete_concurrency: Optional[int] = None, ) -> None: try...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/astradb.html
32546b1c8542-3
available in Astra DB. If left out, it will use Astra DB API's defaults (i.e. "cosine" - but, for performance reasons, "dot_product" is suggested if embeddings are normalized to one). Advanced arguments (coming with sensible defaults): batch_size (Optional[int]): Size...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/astradb.html
32546b1c8542-4
"'token' and 'api_endpoint'." ) self.embedding = embedding self.collection_name = collection_name self.token = token self.api_endpoint = api_endpoint self.namespace = namespace # Concurrency settings self.batch_size: int = batch_size or DEFAULT_BAT...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/astradb.html
32546b1c8542-5
are set other than actual deletion on the backend. """ _ = self.astra_db.delete_collection( collection_name=self.collection_name, ) return None def _provision_collection(self) -> None: """ Run the API invocation to create the collection on the backend. ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/astradb.html
32546b1c8542-6
""" deletion_response = self.collection.delete(document_id) return ((deletion_response or {}).get("status") or {}).get( "deletedCount", 0 ) == 1 [docs] def delete( self, ids: Optional[List[str]] = None, concurrency: Optional[int] = None, **kwargs: A...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/astradb.html
32546b1c8542-7
return None [docs] def add_texts( self, texts: Iterable[str], metadatas: Optional[List[dict]] = None, ids: Optional[List[str]] = None, *, batch_size: Optional[int] = None, batch_concurrency: Optional[int] = None, overwrite_concurrency: Optional[int] = N...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/astradb.html
32546b1c8542-8
docs.datastax.com/en/astra-serverless/docs/develop/dev-with-json.html Returns: List[str]: List of ids of the added texts. """ if kwargs: warnings.warn( "Method 'add_texts' of AstraDB vector store invoked with " f"unsupported arguments ({', ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/astradb.html
32546b1c8542-9
f"API Exception while running bulk insertion: {str(im_result)}" ) batch_inserted = im_result["status"]["insertedIds"] # estimation of the preexisting documents that failed missed_inserted_ids = { document["_id"] for document in document_batch ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/astradb.html
32546b1c8542-10
_b_max_workers = batch_concurrency or self.bulk_insert_batch_concurrency with ThreadPoolExecutor(max_workers=_b_max_workers) as tpe: all_ids_nested = tpe.map( _handle_batch, batch_iterate( batch_size or self.batch_size, uniqued_...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/astradb.html
32546b1c8542-11
hit["_id"], ) for hit in hits ] [docs] def similarity_search_with_score_id( self, query: str, k: int = 4, filter: Optional[Dict[str, str]] = None, ) -> List[Tuple[Document, float, str]]: embedding_vector = self.embedding.embed_query(query) ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/astradb.html
32546b1c8542-12
return self.similarity_search_by_vector( embedding_vector, k, filter=filter, ) [docs] def similarity_search_by_vector( self, embedding: List[float], k: int = 4, filter: Optional[Dict[str, str]] = None, **kwargs: Any, ) -> List[Do...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/astradb.html
32546b1c8542-13
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 and 1 to minimum diversity. Returns: Lis...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/astradb.html
32546b1c8542-14
**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 (str): Text to look up documents similar to. k (i...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/astradb.html
32546b1c8542-15
*Additional arguments*: you can pass any argument that you would to 'add_texts' and/or to the 'AstraDB' class constructor (see these methods for details). These arguments will be routed to the respective methods as they are. Returns: an `AstraDb` vecto...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/astradb.html
32546b1c8542-16
bulk_insert_batch_concurrency=kwargs.get("bulk_insert_batch_concurrency"), bulk_insert_overwrite_concurrency=kwargs.get( "bulk_insert_overwrite_concurrency" ), bulk_delete_concurrency=kwargs.get("bulk_delete_concurrency"), ) astra_db_store.add_texts( ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/astradb.html
1544452feae7-0
Source code for langchain.vectorstores.myscale 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 BaseSettings...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/myscale.html
1544452feae7-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 { ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/myscale.html
1544452feae7-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: """...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/myscale.html
1544452feae7-3
logger.warning( "Lower case metric types will be deprecated " "the future. Please use one of ('IP', 'Cosine', 'L2')" ) # initialize the schema dim = len(embedding.embed_query("try this out")) index_params = ( ", " + ",".join([f"'{k}={v}'" f...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/myscale.html
1544452feae7-4
password=self.config.password, **kwargs, ) self.client.command("SET allow_experimental_object_type=1") self.client.command(schema_) @property def embeddings(self) -> Embeddings: return self._embeddings [docs] def escape_str(self, value: str) -> str: return ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/myscale.html
1544452feae7-5
ids: Optional list of ids to associate with the texts. batch_size: Batch size of insertion metadata: Optional column data to be inserted Returns: List of ids from adding the texts into the vectorstore. """ # Embed and create the documents ids = ids or ...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/myscale.html
1544452feae7-6
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, texts: Iterable[str], embedding: Embeddings, metadatas: Optional[List[Dict[Any...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/myscale.html
1544452feae7-7
"""Text representation for myscale, prints backends, username and schemas. Easy to use with `str(Myscale())` Returns: repr: string to show connection info and data schema """ _repr = f"\033[92m\033[1m{self.config.database}.{self.config.table} @ " _repr += f"{self....
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/myscale.html
1544452feae7-8
AS dist {self.dist_order} LIMIT {topk} """ return q_str [docs] def similarity_search( self, query: str, k: int = 4, where_str: Optional[str] = None, **kwargs: Any ) -> List[Document]: """Perform a similarity search with MyScale Args: query (str)...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/myscale.html
1544452feae7-9
of SQL injection. When dealing with metadatas, remember to use `{self.metadata_column}.attribute` instead of `attribute` alone. The default name for it is `metadata`. Returns: List[Document]: List of (Document, similarity) """ q_str = self._build_q...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/myscale.html
1544452feae7-10
and cosine distance in float for each. Lower score represents more similarity. """ q_str = self._build_qstr(self._embeddings.embed_query(query), k, where_str) try: return [ ( Document( page_content=r[self.config....
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/myscale.html
1544452feae7-11
conds = [] if ids: conds.extend([f"{self.config.column_map['id']} = '{id}'" for id in ids]) if where_str: conds.append(where_str) assert len(conds) > 0 where_str_final = " AND ".join(conds) qstr = ( f"DELETE FROM {self.config.database}.{self.co...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/myscale.html
1544452feae7-12
) -> str: q_emb_str = ",".join(map(str, q_emb)) if where_str: where_str = f"PREWHERE {where_str}" else: where_str = "" q_str = f""" SELECT {self.config.column_map['text']}, dist, {','.join(self.must_have_cols)} FROM {self.c...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/myscale.html
1544452feae7-13
Document( page_content=r[self.config.column_map["text"]], metadata={k: r[k] for k in self.must_have_cols}, ) for r in self.client.query(q_str).named_results() ] except Exception as e: logger.error(f"\033[91m\033[1m{t...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/myscale.html
1544452feae7-14
), 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 [] @property def metadata_column(self) -> str...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/myscale.html
9e5865f764a7-0
Source code for langchain.vectorstores.meilisearch from __future__ import annotations import uuid from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Optional, Tuple, Type from langchain.docstore.document import Document from langchain.schema.embeddings import Embeddings from langchain.schema.vectorstore impor...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/meilisearch.html
9e5865f764a7-1
To use this, you need to have `meilisearch` python package installed, and a running Meilisearch instance. To learn more about Meilisearch Python, refer to the in-depth Meilisearch Python documentation: https://meilisearch.github.io/meilisearch-python/. See the following documentation for how to run a Me...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/meilisearch.html
9e5865f764a7-2
self._index_name = index_name self._embedding = embedding self._text_key = text_key self._metadata_key = metadata_key [docs] def add_texts( self, texts: Iterable[str], metadatas: Optional[List[dict]] = None, ids: Optional[List[str]] = None, **kwargs: An...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/meilisearch.html
9e5865f764a7-3
return ids [docs] def similarity_search( self, query: str, k: int = 4, filter: Optional[Dict[str, str]] = None, **kwargs: Any, ) -> List[Document]: """Return meilisearch documents most similar to the query. Args: query (str): Query text for whic...
lang/api.python.langchain.com/en/latest/_modules/langchain/vectorstores/meilisearch.html