id
stringlengths
14
16
text
stringlengths
45
2.05k
source
stringlengths
53
111
ea179fab1e3d-0
Source code for langchain.vectorstores.milvus """Wrapper around the Milvus vector database.""" from __future__ import annotations import uuid from typing import Any, Iterable, List, Optional, Tuple import numpy as np from langchain.docstore.document import Document from langchain.embeddings.base import Embeddings from ...
ERROR: type should be string, got "https://langchain.readthedocs.io\\en\\latest\\_modules\\langchain\\vectorstores\\milvus.html"
ea179fab1e3d-1
if not connections.has_connection("default"): connections.connect(**connection_args) self.embedding_func = embedding_function self.collection_name = collection_name self.text_field = text_field self.auto_id = False self.primary_field = None self.vector_field =...
ERROR: type should be string, got "https://langchain.readthedocs.io\\en\\latest\\_modules\\langchain\\vectorstores\\milvus.html"
ea179fab1e3d-2
texts: Iterable[str], metadatas: Optional[List[dict]] = None, partition_name: Optional[str] = None, timeout: Optional[int] = None, **kwargs: Any, ) -> List[str]: """Insert text data into Milvus. When using add_texts() it is assumed that a collecton has already ...
ERROR: type should be string, got "https://langchain.readthedocs.io\\en\\latest\\_modules\\langchain\\vectorstores\\milvus.html"
ea179fab1e3d-3
# Insert into the collection. res = self.col.insert( insert_list, partition_name=partition_name, timeout=timeout ) # Flush to make sure newly inserted is immediately searchable. self.col.flush() return res.primary_keys def _worker_search( self, que...
ERROR: type should be string, got "https://langchain.readthedocs.io\\en\\latest\\_modules\\langchain\\vectorstores\\milvus.html"
ea179fab1e3d-4
ret.append( ( Document(page_content=meta.pop(self.text_field), metadata=meta), result.distance, result.id, ) ) return data[0], ret [docs] def similarity_search_with_score( self, query: str,...
ERROR: type should be string, got "https://langchain.readthedocs.io\\en\\latest\\_modules\\langchain\\vectorstores\\milvus.html"
ea179fab1e3d-5
) return [(x, y) for x, y, _ in result] [docs] def max_marginal_relevance_search( self, query: str, k: int = 4, fetch_k: int = 20, param: Optional[dict] = None, expr: Optional[str] = None, partition_names: Optional[List[str]] = None, round_decim...
ERROR: type should be string, got "https://langchain.readthedocs.io\\en\\latest\\_modules\\langchain\\vectorstores\\milvus.html"
ea179fab1e3d-6
# Extract result IDs. ids = [x for _, _, x in res] # Get the raw vectors from Milvus. vectors = self.col.query( expr=f"{self.primary_field} in {ids}", output_fields=[self.primary_field, self.vector_field], ) # Reorganize the results from query to match res...
ERROR: type should be string, got "https://langchain.readthedocs.io\\en\\latest\\_modules\\langchain\\vectorstores\\milvus.html"
ea179fab1e3d-7
Defaults to None. expr (str, optional): Filtering expression. Defaults to None. partition_names (List[str], optional): What partitions to search. Defaults to None. round_decimal (int, optional): What decimal point to round to. Defaults to -1. ...
ERROR: type should be string, got "https://langchain.readthedocs.io\\en\\latest\\_modules\\langchain\\vectorstores\\milvus.html"
ea179fab1e3d-8
"Please install it with `pip install pymilvus`." ) # Connect to Milvus instance if not connections.has_connection("default"): connections.connect(**kwargs.get("connection_args", {"port": 19530})) # Determine embedding dim embeddings = embedding.embed_query(texts[0...
ERROR: type should be string, got "https://langchain.readthedocs.io\\en\\latest\\_modules\\langchain\\vectorstores\\milvus.html"
ea179fab1e3d-9
) else: fields.append(FieldSchema(key, dtype)) # Find out max length of texts max_length = 0 for y in texts: max_length = max(max_length, len(y)) # Create the text field fields.append( FieldSchema(text_field, DataType.VA...
ERROR: type should be string, got "https://langchain.readthedocs.io\\en\\latest\\_modules\\langchain\\vectorstores\\milvus.html"
bcd0338d91b4-0
Source code for langchain.vectorstores.opensearch_vector_search """Wrapper around OpenSearch vector database.""" from __future__ import annotations import uuid from typing import Any, Dict, Iterable, List, Optional from langchain.docstore.document import Document from langchain.embeddings.base import Embeddings from la...
ERROR: type should be string, got "https://langchain.readthedocs.io\\en\\latest\\_modules\\langchain\\vectorstores\\opensearch_vector_search.html"
bcd0338d91b4-1
f"Got error: {e} " ) return client def _validate_embeddings_and_bulk_size(embeddings_length: int, bulk_size: int) -> None: """Validate Embeddings Length and Bulk Size.""" if embeddings_length == 0: raise RuntimeError("Embeddings size is zero") if bulk_size < embeddings_length: ra...
ERROR: type should be string, got "https://langchain.readthedocs.io\\en\\latest\\_modules\\langchain\\vectorstores\\opensearch_vector_search.html"
bcd0338d91b4-2
return { "mappings": { "properties": { "vector_field": {"type": "knn_vector", "dimension": dim}, } } } def _default_text_mapping( dim: int, engine: str = "nmslib", space_type: str = "l2", ef_search: int = 512, ef_construction: int = 512, ...
ERROR: type should be string, got "https://langchain.readthedocs.io\\en\\latest\\_modules\\langchain\\vectorstores\\opensearch_vector_search.html"
bcd0338d91b4-3
pre_filter: Dict = MATCH_ALL_QUERY, ) -> Dict: """For Script Scoring Search, this is the default query.""" return { "query": { "script_score": { "query": pre_filter, "script": { "source": "knn_score", "lang": "knn", ...
ERROR: type should be string, got "https://langchain.readthedocs.io\\en\\latest\\_modules\\langchain\\vectorstores\\opensearch_vector_search.html"
bcd0338d91b4-4
}, }, } } } def _get_kwargs_value(kwargs: Any, key: str, default_value: Any) -> Any: """Get the value of the key if present. Else get the default_value.""" if key in kwargs: return kwargs.get(key) return default_value [docs]class OpenSearchVectorSearch(VectorS...
ERROR: type should be string, got "https://langchain.readthedocs.io\\en\\latest\\_modules\\langchain\\vectorstores\\opensearch_vector_search.html"
bcd0338d91b4-5
self.embedding_function.embed_documents([text])[0] for text in texts ] _validate_embeddings_and_bulk_size(len(embeddings), bulk_size) return _bulk_ingest_embeddings( self.client, self.index_name, embeddings, texts, metadatas ) [docs] def similarity_search( self, qu...
ERROR: type should be string, got "https://langchain.readthedocs.io\\en\\latest\\_modules\\langchain\\vectorstores\\opensearch_vector_search.html"
bcd0338d91b4-6
nearest neighbors; default: {"match_all": {}} """ embedding = self.embedding_function.embed_query(query) search_type = _get_kwargs_value(kwargs, "search_type", "approximate_search") if search_type == "approximate_search": size = _get_kwargs_value(kwargs, "size", 4) ...
ERROR: type should be string, got "https://langchain.readthedocs.io\\en\\latest\\_modules\\langchain\\vectorstores\\opensearch_vector_search.html"
bcd0338d91b4-7
**kwargs: Any, ) -> OpenSearchVectorSearch: """Construct OpenSearchVectorSearch wrapper from raw documents. Example: .. code-block:: python from langchain import OpenSearchVectorSearch from langchain.embeddings import OpenAIEmbeddings embed...
ERROR: type should be string, got "https://langchain.readthedocs.io\\en\\latest\\_modules\\langchain\\vectorstores\\opensearch_vector_search.html"
bcd0338d91b4-8
kwargs, "opensearch_url", "OPENSEARCH_URL" ) client = _get_opensearch_client(opensearch_url) embeddings = embedding.embed_documents(texts) _validate_embeddings_and_bulk_size(len(embeddings), bulk_size) dim = len(embeddings[0]) # Get the index name from either from kwargs ...
ERROR: type should be string, got "https://langchain.readthedocs.io\\en\\latest\\_modules\\langchain\\vectorstores\\opensearch_vector_search.html"
1a602d598c64-0
Source code for langchain.vectorstores.pinecone """Wrapper around Pinecone vector database.""" from __future__ import annotations import uuid from typing import Any, Callable, Iterable, List, Optional, Tuple from langchain.docstore.document import Document from langchain.embeddings.base import Embeddings from langchain...
ERROR: type should be string, got "https://langchain.readthedocs.io\\en\\latest\\_modules\\langchain\\vectorstores\\pinecone.html"
1a602d598c64-1
self._namespace = namespace [docs] def add_texts( self, texts: Iterable[str], metadatas: Optional[List[dict]] = None, ids: Optional[List[str]] = None, namespace: Optional[str] = None, batch_size: int = 32, **kwargs: Any, ) -> List[str]: """Run more ...
ERROR: type should be string, got "https://langchain.readthedocs.io\\en\\latest\\_modules\\langchain\\vectorstores\\pinecone.html"
1a602d598c64-2
"""Return pinecone documents most similar to query, along with scores. 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. De...
ERROR: type should be string, got "https://langchain.readthedocs.io\\en\\latest\\_modules\\langchain\\vectorstores\\pinecone.html"
1a602d598c64-3
namespace = self._namespace query_obj = self._embedding_function(query) docs = [] results = self._index.query( [query_obj], top_k=k, include_metadata=True, namespace=namespace, filter=filter, ) for res in results["matche...
ERROR: type should be string, got "https://langchain.readthedocs.io\\en\\latest\\_modules\\langchain\\vectorstores\\pinecone.html"
1a602d598c64-4
"Please install it with `pip install pinecone-client`." ) _index_name = index_name or str(uuid.uuid4()) indexes = pinecone.list_indexes() # checks if provided index exists if _index_name in indexes: index = pinecone.Index(_index_name) else: index = No...
ERROR: type should be string, got "https://langchain.readthedocs.io\\en\\latest\\_modules\\langchain\\vectorstores\\pinecone.html"
1a602d598c64-5
cls, index_name: str, embedding: Embeddings, text_key: str = "text", namespace: Optional[str] = None, ) -> Pinecone: """Load pinecone vectorstore from index name.""" try: import pinecone except ImportError: raise ValueError( ...
ERROR: type should be string, got "https://langchain.readthedocs.io\\en\\latest\\_modules\\langchain\\vectorstores\\pinecone.html"
7fbe5ab172b7-0
Source code for langchain.vectorstores.qdrant """Wrapper around Qdrant vector database.""" import uuid from operator import itemgetter from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Union, cast from langchain.docstore.document import Document from langchain.embeddings.base import Embeddings fr...
ERROR: type should be string, got "https://langchain.readthedocs.io\\en\\latest\\_modules\\langchain\\vectorstores\\qdrant.html"
7fbe5ab172b7-1
f"got {type(client)}" ) self.client: qdrant_client.QdrantClient = client self.collection_name = collection_name self.embedding_function = embedding_function self.content_payload_key = content_payload_key or self.CONTENT_KEY self.metadata_payload_key = metadata_payload...
ERROR: type should be string, got "https://langchain.readthedocs.io\\en\\latest\\_modules\\langchain\\vectorstores\\qdrant.html"
7fbe5ab172b7-2
Args: query: Text to look up documents similar to. k: Number of Documents to return. Defaults to 4. filter: Filter by metadata. Defaults to None. Returns: List of Documents most similar to the query. """ results = self.similarity_search_with_score(...
ERROR: type should be string, got "https://langchain.readthedocs.io\\en\\latest\\_modules\\langchain\\vectorstores\\qdrant.html"
7fbe5ab172b7-3
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. Returns: List of Documents selected by maximal marginal relevance....
ERROR: type should be string, got "https://langchain.readthedocs.io\\en\\latest\\_modules\\langchain\\vectorstores\\qdrant.html"
7fbe5ab172b7-4
) -> "Qdrant": return cast( Qdrant, super().from_documents( documents, embedding, url=url, port=port, grpc_port=grpc_port, prefer_grpc=prefer_grpc, https=https, ...
ERROR: type should be string, got "https://langchain.readthedocs.io\\en\\latest\\_modules\\langchain\\vectorstores\\qdrant.html"
7fbe5ab172b7-5
metadatas: An optional list of metadata. If provided it has to be of the same length as a list of texts. url: either host or str of "Optional[scheme], host, Optional[port], Optional[prefix]". Default: `None` port: Port of the REST API interface. De...
ERROR: type should be string, got "https://langchain.readthedocs.io\\en\\latest\\_modules\\langchain\\vectorstores\\qdrant.html"
7fbe5ab172b7-6
**kwargs: Additional arguments passed directly into REST client initialization This is a user friendly interface that: 1. Embeds documents. 2. Creates an in memory docstore 3. Initializes the Qdrant database This is intended to be a quick way to get st...
ERROR: type should be string, got "https://langchain.readthedocs.io\\en\\latest\\_modules\\langchain\\vectorstores\\qdrant.html"
7fbe5ab172b7-7
), ) # Now generate the embeddings for all the texts embeddings = embedding.embed_documents(texts) client.upsert( collection_name=collection_name, points=rest.Batch( ids=[uuid.uuid4().hex for _ in texts], vectors=embeddings, ...
ERROR: type should be string, got "https://langchain.readthedocs.io\\en\\latest\\_modules\\langchain\\vectorstores\\qdrant.html"
7fbe5ab172b7-8
return Document( page_content=scored_point.payload.get(content_payload_key), metadata=scored_point.payload.get(metadata_payload_key) or {}, ) def _qdrant_filter_from_dict(self, filter: Optional[MetadataFilter]) -> Any: if filter is None or 0 == len(filter): return...
ERROR: type should be string, got "https://langchain.readthedocs.io\\en\\latest\\_modules\\langchain\\vectorstores\\qdrant.html"
bb80b371022f-0
Source code for langchain.vectorstores.weaviate """Wrapper around weaviate vector database.""" from __future__ import annotations from typing import Any, Dict, Iterable, List, Optional from uuid import uuid4 from langchain.docstore.document import Document from langchain.embeddings.base import Embeddings from langchain...
ERROR: type should be string, got "https://langchain.readthedocs.io\\en\\latest\\_modules\\langchain\\vectorstores\\weaviate.html"
bb80b371022f-1
[docs] def add_texts( self, texts: Iterable[str], metadatas: Optional[List[dict]] = None, **kwargs: Any, ) -> List[str]: """Upload texts with metadata (properties) to Weaviate.""" from weaviate.util import get_valid_uuid with self._client.batch as batch: ...
ERROR: type should be string, got "https://langchain.readthedocs.io\\en\\latest\\_modules\\langchain\\vectorstores\\weaviate.html"
bb80b371022f-2
cls, texts: List[str], embedding: Embeddings, metadatas: Optional[List[dict]] = None, **kwargs: Any, ) -> VectorStore: """Not implemented for Weaviate yet.""" raise NotImplementedError("weaviate does not currently support `from_texts`.") By Harrison Chase ©...
ERROR: type should be string, got "https://langchain.readthedocs.io\\en\\latest\\_modules\\langchain\\vectorstores\\weaviate.html"