id stringlengths 14 16 | text stringlengths 29 2.73k | source stringlengths 50 116 |
|---|---|---|
7806f23fb40c-6 | A list of dictionaries with the following keys
run(query: str) β str[source]#
Run query through GoogleSearch and parse result.
pydantic model langchain.utilities.GoogleSerperAPIWrapper[source]#
Wrapper around the Serper.dev Google Search API.
You can create a free API key at https://serper.dev.
To use, you should have ... | https:///python.langchain.com/en/latest/reference/modules/utilities.html |
7806f23fb40c-7 | field owm: Any = None#
run(location: str) β str[source]#
Get the current weather information for a specified location.
pydantic model langchain.utilities.PowerBIDataset[source]#
Create PowerBI engine from dataset ID and credential or token.
Use either the credential or a supplied token to authenticate.
If both are supp... | https:///python.langchain.com/en/latest/reference/modules/utilities.html |
7806f23fb40c-8 | property headers: Dict[str, str]#
Get the token.
property request_url: str#
Get the request url.
property table_info: str#
Information about all tables in the database.
pydantic model langchain.utilities.PythonREPL[source]#
Simulates a standalone Python REPL.
field globals: Optional[Dict] [Optional] (alias '_globals')#... | https:///python.langchain.com/en/latest/reference/modules/utilities.html |
7806f23fb40c-9 | field headers: Optional[dict] = None#
field k: int = 10#
field params: dict [Optional]#
field query_suffix: Optional[str] = ''#
field searx_host: str = ''#
field unsecure: bool = False#
async aresults(query: str, num_results: int, engines: Optional[List[str]] = None, query_suffix: Optional[str] = '', **kwargs: Any) β L... | https:///python.langchain.com/en/latest/reference/modules/utilities.html |
7806f23fb40c-10 | }
Return type
Dict with the following keys
run(query: str, engines: Optional[List[str]] = None, categories: Optional[List[str]] = None, query_suffix: Optional[str] = '', **kwargs: Any) β str[source]#
Run query through Searx API and parse results.
You can pass any other params to the searx query API.
Parameters
query β ... | https:///python.langchain.com/en/latest/reference/modules/utilities.html |
7806f23fb40c-11 | field aiosession: Optional[aiohttp.client.ClientSession] = None#
field params: dict = {'engine': 'google', 'gl': 'us', 'google_domain': 'google.com', 'hl': 'en'}#
field serpapi_api_key: Optional[str] = None#
async aresults(query: str) β dict[source]#
Use aiohttp to run query through SerpAPI and return the results async... | https:///python.langchain.com/en/latest/reference/modules/utilities.html |
7806f23fb40c-12 | POST to the URL and return the text asynchronously.
async aput(url: str, data: Dict[str, Any], **kwargs: Any) β str[source]#
PUT the URL and return the text asynchronously.
delete(url: str, **kwargs: Any) β str[source]#
DELETE the URL and return the text.
get(url: str, **kwargs: Any) β str[source]#
GET the URL and retu... | https:///python.langchain.com/en/latest/reference/modules/utilities.html |
7806f23fb40c-13 | Save your APP ID into WOLFRAM_ALPHA_APPID env variable
pip install wolframalpha
field wolfram_alpha_appid: Optional[str] = None#
run(query: str) β str[source]#
Run query through WolframAlpha and parse result.
previous
Agent Toolkits
next
Experimental Modules
By Harrison Chase
Β© Copyright 2023, Harrison Chase... | https:///python.langchain.com/en/latest/reference/modules/utilities.html |
eb42dd31186b-0 | .rst
.pdf
Vector Stores
Vector Stores#
Wrappers on top of vector stores.
class langchain.vectorstores.AnalyticDB(connection_string: str, embedding_function: langchain.embeddings.base.Embeddings, collection_name: str = 'langchain', collection_metadata: Optional[dict] = None, pre_delete_collection: bool = False, logger: ... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-1 | Return connection string from database parameters.
create_collection() β None[source]#
create_tables_if_not_exists() β None[source]#
delete_collection() β None[source]#
drop_tables() β None[source]#
classmethod from_documents(documents: List[langchain.schema.Document], embedding: langchain.embeddings.base.Embeddings, c... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-2 | k (int) β Number of results to return. Defaults to 4.
filter (Optional[Dict[str, str]]) β Filter by metadata. Defaults to None.
Returns
List of Documents most similar to the query.
similarity_search_by_vector(embedding: List[float], k: int = 4, filter: Optional[dict] = None, **kwargs: Any) β List[langchain.schema.Docum... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-3 | Example
from langchain import Annoy
db = Annoy(embedding_function, index, docstore, index_to_docstore_id)
add_texts(texts: Iterable[str], metadatas: Optional[List[dict]] = None, **kwargs: Any) β List[str][source]#
Run more texts through the embeddings and add to the vectorstore.
Parameters
texts β Iterable of strings t... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-4 | text_embedding_pairs = list(zip(texts, text_embeddings))
db = Annoy.from_embeddings(text_embedding_pairs, embeddings)
classmethod from_texts(texts: List[str], embedding: langchain.embeddings.base.Embeddings, metadatas: Optional[List[dict]] = None, metric: str = 'angular', trees: int = 100, n_jobs: int = - 1, **kwargs: ... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-5 | and index_to_docstore_id from.
embeddings β Embeddings to use when generating queries.
max_marginal_relevance_search(query: str, k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, **kwargs: Any) β List[langchain.schema.Document][source]#
Return docs selected using the maximal marginal relevance.
Maximal marginal ... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-6 | Defaults to 0.5.
Returns
List of Documents selected by maximal marginal relevance.
process_index_results(idxs: List[int], dists: List[float]) β List[Tuple[langchain.schema.Document, float]][source]#
Turns annoy results into a list of documents and scores.
Parameters
idxs β List of indices of the documents in the index.... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-7 | to n_trees * n if not provided
Returns
List of Documents most similar to the embedding.
similarity_search_by_vector(embedding: List[float], k: int = 4, search_k: int = - 1, **kwargs: Any) β List[langchain.schema.Document][source]#
Return docs most similar to embedding vector.
Parameters
embedding β Embedding to look up... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-8 | Returns
List of Documents most similar to the query and score for each
similarity_search_with_score_by_vector(embedding: List[float], k: int = 4, search_k: int = - 1) β List[Tuple[langchain.schema.Document, float]][source]#
Return docs most similar to query.
Parameters
query β Text to look up documents similar to.
k β ... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-9 | ids (Optional[List[str]]) β An optional list of ids.
refresh (bool) β Whether or not to refresh indices with the updated data.
Default True.
Returns
List of IDs of the added texts.
Return type
List[str]
create_index(**kwargs: Any) β Any[source]#
Creates an index in your project.
See
https://docs.nomic.ai/atlas_api.html... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-10 | index_kwargs (Optional[dict]) β Dict of kwargs for index creation.
See https://docs.nomic.ai/atlas_api.html
Returns
Nomicβs neural database and finest rhizomatic instrument
Return type
AtlasDB
classmethod from_texts(texts: List[str], embedding: Optional[langchain.embeddings.base.Embeddings] = None, metadatas: Optional[... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-11 | Returns
Nomicβs neural database and finest rhizomatic instrument
Return type
AtlasDB
similarity_search(query: str, k: int = 4, **kwargs: Any) β List[langchain.schema.Document][source]#
Run similarity search with AtlasDB
Parameters
query (str) β Query text to search for.
k (int) β Number of results to return. Defaults t... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-12 | Return type
List[str]
delete_collection() β None[source]#
Delete the collection.
classmethod from_documents(documents: List[Document], embedding: Optional[Embeddings] = None, ids: Optional[List[str]] = None, collection_name: str = 'langchain', persist_directory: Optional[str] = None, client_settings: Optional[chromadb.... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-13 | Otherwise, the data will be ephemeral in-memory.
Parameters
texts (List[str]) β List of texts to add to the collection.
collection_name (str) β Name of the collection to create.
persist_directory (Optional[str]) β Directory to persist the collection.
embedding (Optional[Embeddings]) β Embedding function. Defaults to No... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-14 | Returns
List of Documents selected by maximal marginal relevance.
max_marginal_relevance_search_by_vector(embedding: List[float], k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, filter: Optional[Dict[str, str]] = None, **kwargs: Any) β List[langchain.schema.Document][source]#
Return docs selected using the max... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-15 | Returns
List of documents most similar to the query text.
Return type
List[Document]
similarity_search_by_vector(embedding: List[float], k: int = 4, filter: Optional[Dict[str, str]] = None, **kwargs: Any) β List[langchain.schema.Document][source]#
Return docs most similar to embedding vector.
:param embedding: Embeddin... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-16 | Wrapper around Deep Lake, a data lake for deep learning applications.
We implement naive similarity search and filtering for fast prototyping,
but it can be extended with Tensor Query Language (TQL) for production use cases
over billion rows.
Why Deep Lake?
Not only stores embeddings, but also the original data with ve... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-17 | ids (Optional[List[str]], optional) β The document_ids to delete.
Defaults to None.
filter (Optional[Dict[str, str]], optional) β The filter to delete by.
Defaults to None.
delete_all (Optional[bool], optional) β Whether to drop the dataset.
Defaults to None.
delete_dataset() β None[source]#
Delete the collection.
clas... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-18 | Should be used only for testing as it does not persist.
documents (List[Document]) β List of documents to add.
embedding (Optional[Embeddings]) β Embedding function. Defaults to None.
metadatas (Optional[List[dict]]) β List of metadatas. Defaults to None.
ids (Optional[List[str]]) β List of document IDs. Defaults to No... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-19 | :param k: Number of Documents to return. Defaults to 4.
:param fetch_k: Number of Documents to fetch to pass to MMR algorithm.
:param 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.
Defaults to 0.5.
Retur... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-20 | Parameters
embedding β Embedding to look up documents similar to.
k β Number of Documents to return. Defaults to 4.
Returns
List of Documents most similar to the query vector.
similarity_search_with_score(query: str, distance_metric: str = 'L2', k: int = 4, filter: Optional[Dict[str, str]] = None) β List[Tuple[langchai... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-21 | including Elastic Cloud, use the Elasticsearch URL format
https://username:password@es_host:9243. For example, to connect to Elastic
Cloud, create the Elasticsearch URL with the required authentication details and
pass it to the ElasticVectorSearch constructor as the named parameter
elasticsearch_url.
You can obtain yo... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-22 | Raises
ValueError β If the elasticsearch python package is not installed.
add_texts(texts: Iterable[str], metadatas: Optional[List[dict]] = None, refresh_indices: bool = True, **kwargs: Any) β List[str][source]#
Run more texts through the embeddings and add to the vectorstore.
Parameters
texts β Iterable of strings to ... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-23 | Returns
List of Documents most similar to the query.
similarity_search_with_score(query: str, k: int = 4, filter: Optional[dict] = None, **kwargs: Any) β List[Tuple[langchain.schema.Document, float]][source]#
Return docs most similar to query.
:param query: Text to look up documents similar to.
:param k: Number of Docu... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-24 | Parameters
texts β Iterable of strings to add to the vectorstore.
metadatas β Optional list of metadatas associated with the texts.
Returns
List of ids from adding the texts into the vectorstore.
classmethod from_embeddings(text_embeddings: List[Tuple[str, List[float]]], embedding: langchain.embeddings.base.Embeddings,... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-25 | Load FAISS index, docstore, and index_to_docstore_id to disk.
Parameters
folder_path β folder path to load index, docstore,
and index_to_docstore_id from.
embeddings β Embeddings to use when generating queries
index_name β for saving with a specific index file name
max_marginal_relevance_search(query: str, k: int = 4, ... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-26 | 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.
merge_from(target: langchain.vectorstores.faiss.FAISS) β None[source]#
Merge another FAISS object with the current one.
Add the target F... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-27 | Return docs most similar to query.
Parameters
query β Text to look up documents similar to.
k β Number of Documents to return. Defaults to 4.
Returns
List of Documents most similar to the query and score for each
similarity_search_with_score_by_vector(embedding: List[float], k: int = 4) β List[Tuple[langchain.schema.Do... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-28 | Returns
List of ids of the added texts.
classmethod from_texts(texts: List[str], embedding: langchain.embeddings.base.Embeddings, metadatas: Optional[List[dict]] = None, connection: Optional[Any] = None, vector_key: Optional[str] = 'vector', id_key: Optional[str] = 'id', text_key: Optional[str] = 'text', **kwargs: Any)... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-29 | embedding and the columns are decided by the first metadata dict.
Metada keys will need to be present for all inserted values. At
the moment there is no None equivalent in Milvus.
Parameters
texts (Iterable[str]) β The texts to embed, it is assumed
that they all fit in memory.
metadatas (Optional[List[dict]]) β Metadat... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-30 | to DEFAULT_MILVUS_CONNECTION.
consistency_level (str, optional) β Which consistency level to use. Defaults
to βSessionβ.
index_params (Optional[dict], optional) β Which index_params to use. Defaults
to None.
search_params (Optional[dict], optional) β Which search params to use.
Defaults to None.
drop_old (Optional[bool... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-31 | Returns
Document results for search.
Return type
List[Document]
max_marginal_relevance_search_by_vector(embedding: list[float], k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, param: Optional[dict] = None, expr: Optional[str] = None, timeout: Optional[int] = None, **kwargs: Any) β List[Document][source]#
Perfo... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-32 | 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. Defaults to None.
timeout (int, optional) β How long to wait before timeout error.
Defaults to None.
kwargs β Collection.search() k... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-33 | documentation found here:
https://milvus.io/api-reference/pymilvus/v2.2.6/Collection/search().md
Parameters
query (str) β The text being searched.
k (int, optional) β The amount of results ot return. Defaults to 4.
param (dict) β The search params for the specified index.
Defaults to None.
expr (str, optional) β Filter... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-34 | Returns
Result doc and score.
Return type
List[Tuple[Document, float]]
class langchain.vectorstores.MyScale(embedding: langchain.embeddings.base.Embeddings, config: Optional[langchain.vectorstores.myscale.MyScaleSettings] = None, **kwargs: Any)[source]#
Wrapper around MyScale vector database
You need a clickhouse-conne... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-35 | Create Myscale wrapper with existing texts
Parameters
embedding_function (Embeddings) β Function to extract text embedding
texts (Iterable[str]) β List or tuple of strings to be added
config (MyScaleSettings, Optional) β Myscale configuration
text_ids (Optional[Iterable], optional) β IDs for the texts.
Defaults to None... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-36 | Perform a similarity search with MyScale by vectors
Parameters
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 always be aware
of SQL injection. W... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-37 | password (str) : Password to login. Defaults to None.
index_type (str): index type string.
index_param (dict): index build parameter.
database (str) : Database name to find the table. Defaults to βdefaultβ.
table (str) : Table name to operate on.
Defaults to βvector_tableβ.
metric (str)Metric to compute distance,suppor... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-38 | Defaults to identity map.
Show JSON schema{
"title": "MyScaleSettings",
"description": "MyScale Client Configuration\n\nAttribute:\n myscale_host (str) : An URL to connect to MyScale backend.\n Defaults to 'localhost'.\n myscale_port (int) : URL port to connect with HTTP. Defaults to... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-39 | },
"port": {
"title": "Port",
"default": 8443,
"env_names": "{'myscale_port'}",
"type": "integer"
},
"username": {
"title": "Username",
"env_names": "{'myscale_username'}",
"type": "string"
},
"password": {
"title": "P... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-40 | },
"table": {
"title": "Table",
"default": "langchain",
"env_names": "{'myscale_table'}",
"type": "string"
},
"metric": {
"title": "Metric",
"default": "cosine",
"env_names": "{'myscale_metric'}",
"type": "string"
}
},
... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-41 | Wrapper around OpenSearch as a vector database.
Example
from langchain import OpenSearchVectorSearch
opensearch_vector_search = OpenSearchVectorSearch(
"http://localhost:9200",
"embeddings",
embedding_function
)
add_texts(texts: Iterable[str], metadatas: Optional[List[dict]] = None, bulk_size: int = 500, **... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-42 | search through Script Scoring and Painless Scripting.
Optional Args:vector_field: Document field embeddings are stored in. Defaults to
βvector_fieldβ.
text_field: Document field the text of the document is stored in. Defaults
to βtextβ.
Optional Keyword Args for Approximate Search:engine: βnmslibβ, βfaissβ, βluceneβ; d... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-43 | metadata_field: Document field that metadata is stored in. Defaults to
βmetadataβ.
Can be set to a special value β*β to include the entire document.
Optional Args for Approximate Search:search_type: βapproximate_searchβ; default: βapproximate_searchβ
size: number of results the query actually returns; default: 4
boolea... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-44 | from langchain.embeddings.openai import OpenAIEmbeddings
import pinecone
# The environment should be the one specified next to the API key
# in your Pinecone console
pinecone.init(api_key="***", environment="...")
index = pinecone.Index("langchain-demo")
embeddings = OpenAIEmbeddings()
vectorstore = Pinecone(index, emb... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-45 | Construct Pinecone wrapper from raw documents.
This is a user friendly interface that:
Embeds documents.
Adds the documents to a provided Pinecone index
This is intended to be a quick way to get started.
Example
from langchain import Pinecone
from langchain.embeddings import OpenAIEmbeddings
import pinecone
# The envir... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-46 | namespace β Namespace to search in. Default will search in ββ namespace.
Returns
List of Documents most similar to the query and score for each
class langchain.vectorstores.Qdrant(client: Any, collection_name: str, embedding_function: Callable, content_payload_key: str = 'page_content', metadata_payload_key: str = 'met... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-47 | Returns
List of ids from adding the texts into the vectorstore.
classmethod from_texts(texts: List[str], embedding: langchain.embeddings.base.Embeddings, metadatas: Optional[List[dict]] = None, location: Optional[str] = None, url: Optional[str] = None, port: Optional[int] = 6333, grpc_port: int = 6334, prefer_grpc: boo... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-48 | Default: False
https β If true - use HTTPS(SSL) protocol. Default: None
api_key β API key for authentication in Qdrant Cloud. Default: None
prefix β If not None - add prefix to the REST URL path.
Example: service/v1 will result in
http://localhost:6333/service/v1/{qdrant-endpoint} for REST API.
Default: None
timeout β ... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-49 | qdrant = Qdrant.from_texts(texts, embeddings, "localhost")
max_marginal_relevance_search(query: str, k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, **kwargs: Any) β List[langchain.schema.Document][source]#
Return docs selected using the maximal marginal relevance.
Maximal marginal relevance optimizes for simi... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-50 | 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 and score for each.
class langchain.vectorstores.Redis(redis_url: str, index_name: str, embedding_function: typing.Callable, content_key: str = 'content', metadata_key: st... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-51 | Returns
List of ids added to the vectorstore
Return type
List[str]
as_retriever(**kwargs: Any) β langchain.schema.BaseRetriever[source]#
static drop_index(index_name: str, delete_documents: bool, **kwargs: Any) β bool[source]#
Drop a Redis search index.
Parameters
index_name (str) β Name of the index to drop.
delete_do... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-52 | Parameters
query (str) β The query text for which to find similar documents.
k (int) β The number of documents to return. Default is 4.
Returns
A list of documents that are most similar to the query text.
Return type
List[Document]
similarity_search_limit_score(query: str, k: int = 4, score_threshold: float = 0.2, **kw... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-53 | Returns
List of Documents most similar to the query and score for each
class langchain.vectorstores.SupabaseVectorStore(client: supabase.client.Client, embedding: Embeddings, table_name: str, query_name: Union[str, None] = None)[source]#
VectorStore for a Supabase postgres database. Assumes you have the pgvector
extens... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-54 | Return VectorStore initialized from texts and embeddings.
max_marginal_relevance_search(query: str, k: int = 4, fetch_k: int = 20, lambda_mult: float = 0.5, **kwargs: Any) β List[langchain.schema.Document][source]#
Return docs selected using the maximal marginal relevance.
Maximal marginal relevance optimizes for simil... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-55 | Return docs selected using the maximal marginal relevance.
Maximal marginal relevance optimizes for similarity to query AND diversity
among selected documents.
Parameters
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 pa... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-56 | 0 is dissimilar, 1 is most similar.
table_name: str#
class langchain.vectorstores.Tair(embedding_function: langchain.embeddings.base.Embeddings, url: str, index_name: str, content_key: str = 'content', metadata_key: str = 'metadata', search_params: Optional[dict] = None, **kwargs: Any)[source]#
add_texts(texts: Iterabl... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-57 | Connect to an existing Tair index.
classmethod from_texts(texts: List[str], embedding: langchain.embeddings.base.Embeddings, metadatas: Optional[List[dict]] = None, index_name: str = 'langchain', content_key: str = 'content', metadata_key: str = 'metadata', **kwargs: Any) β langchain.vectorstores.tair.Tair[source]#
Ret... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-58 | Parameters
(List[Document] (documents) β Documents to add to the vectorstore.
Returns
List of IDs of the added texts.
Return type
List[str]
abstract add_texts(texts: Iterable[str], metadatas: Optional[List[dict]] = None, **kwargs: Any) β List[str][source]#
Run more texts through the embeddings and add to the vectorstor... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-59 | Return docs selected using the maximal marginal relevance.
as_retriever(**kwargs: Any) β langchain.schema.BaseRetriever[source]#
async asearch(query: str, search_type: str, **kwargs: Any) β List[langchain.schema.Document][source]#
Return docs most similar to query using specified search type.
async asimilarity_search(q... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-60 | 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.
Defaults to 0.5.
Returns
List of Documents selected by maximal marginal relevance.
max_mar... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-61 | Parameters
embedding β Embedding to look up documents similar to.
k β Number of Documents to return. Defaults to 4.
Returns
List of Documents most similar to the query vector.
similarity_search_with_relevance_scores(query: str, k: int = 4, **kwargs: Any) β List[Tuple[langchain.schema.Document, float]][source]#
Return d... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-62 | Embeds documents.
Creates a new index for the embeddings in the Weaviate instance.
Adds the documents to the newly created Weaviate index.
This is intended to be a quick way to get started.
Example
from langchain.vectorstores.weaviate import Weaviate
from langchain.embeddings import OpenAIEmbeddings
embeddings = OpenAI... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-63 | among selected documents.
Parameters
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 among the results with 0 correspondi... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
eb42dd31186b-64 | classmethod from_texts(texts: List[str], embedding: Embeddings, metadatas: Optional[List[dict]] = None, collection_name: str = 'LangChainCollection', connection_args: dict[str, Any] = {}, consistency_level: str = 'Session', index_params: Optional[dict] = None, search_params: Optional[dict] = None, drop_old: bool = Fals... | https:///python.langchain.com/en/latest/reference/modules/vectorstores.html |
bc4bfbe0a852-0 | .rst
.pdf
Document Compressors
Document Compressors#
pydantic model langchain.retrievers.document_compressors.CohereRerank[source]#
field client: Client [Required]#
field model: str = 'rerank-english-v2.0'#
field top_n: int = 3#
async acompress_documents(documents: Sequence[langchain.schema.Document], query: str) β Seq... | https:///python.langchain.com/en/latest/reference/modules/document_compressors.html |
bc4bfbe0a852-1 | similarity_threshold must be specified. Defaults to 20.
field similarity_fn: Callable = <function cosine_similarity>#
Similarity function for comparing documents. Function expected to take as input
two matrices (List[List[float]]) and return a matrix of scores where higher values
indicate greater similarity.
field simi... | https:///python.langchain.com/en/latest/reference/modules/document_compressors.html |
bc4bfbe0a852-2 | Compress page content of raw documents.
classmethod from_llm(llm: langchain.base_language.BaseLanguageModel, prompt: Optional[langchain.prompts.prompt.PromptTemplate] = None, get_input: Optional[Callable[[str, langchain.schema.Document], str]] = None, llm_chain_kwargs: Optional[dict] = None) β langchain.retrievers.docu... | https:///python.langchain.com/en/latest/reference/modules/document_compressors.html |
4269b2e34a3c-0 | .rst
.pdf
Retrievers
Retrievers#
pydantic model langchain.retrievers.ChatGPTPluginRetriever[source]#
field aiosession: Optional[aiohttp.client.ClientSession] = None#
field bearer_token: str [Required]#
field filter: Optional[dict] = None#
field top_k: int = 3#
field url: str [Required]#
async aget_relevant_documents(qu... | https:///python.langchain.com/en/latest/reference/modules/retrievers.html |
4269b2e34a3c-1 | Parameters
query β string to find relevant documents for
Returns
Sequence of relevant documents
class langchain.retrievers.DataberryRetriever(datastore_url: str, top_k: Optional[int] = None, api_key: Optional[str] = None)[source]#
async aget_relevant_documents(query: str) β List[langchain.schema.Document][source]#
Get ... | https:///python.langchain.com/en/latest/reference/modules/retrievers.html |
4269b2e34a3c-2 | Click βReset passwordβ
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.
add_texts(texts: Iterable[str], refresh_indices: bool = True) β List[str][source]#
Run more texts through the embeddings and add to the retriver.
Para... | https:///python.langchain.com/en/latest/reference/modules/retrievers.html |
4269b2e34a3c-3 | Parameters
query β string to find relevant documents for
Returns
List of relevant documents
pydantic model langchain.retrievers.PineconeHybridSearchRetriever[source]#
field alpha: float = 0.5#
field embeddings: langchain.embeddings.base.Embeddings [Required]#
field index: Any = None#
field sparse_encoder: Any = None#
f... | https:///python.langchain.com/en/latest/reference/modules/retrievers.html |
4269b2e34a3c-4 | Parameters
query β string to find relevant documents for
Returns
List of relevant documents
pydantic model langchain.retrievers.SVMRetriever[source]#
field embeddings: langchain.embeddings.base.Embeddings [Required]#
field index: Any = None#
field k: int = 4#
field relevancy_threshold: Optional[float] = None#
field tex... | https:///python.langchain.com/en/latest/reference/modules/retrievers.html |
4269b2e34a3c-5 | get_relevant_documents(query: str) β List[langchain.schema.Document][source]#
Get documents relevant for a query.
Parameters
query β string to find relevant documents for
Returns
List of relevant documents
pydantic model langchain.retrievers.TimeWeightedVectorStoreRetriever[source]#
Retriever combining embededing simil... | https:///python.langchain.com/en/latest/reference/modules/retrievers.html |
4269b2e34a3c-6 | get_relevant_documents(query: str) β List[langchain.schema.Document][source]#
Return documents that are relevant to the query.
get_salient_docs(query: str) β Dict[int, Tuple[langchain.schema.Document, float]][source]#
Return documents that are salient to the query.
class langchain.retrievers.VespaRetriever(app: Vespa, ... | https:///python.langchain.com/en/latest/reference/modules/retrievers.html |
4269b2e34a3c-7 | Look up similar documents in Weaviate.
previous
Vector Stores
next
Document Compressors
By Harrison Chase
Β© Copyright 2023, Harrison Chase.
Last updated on May 02, 2023. | https:///python.langchain.com/en/latest/reference/modules/retrievers.html |
a131a69f8eae-0 | .rst
.pdf
Docstore
Docstore#
Wrappers on top of docstores.
class langchain.docstore.InMemoryDocstore(_dict: Dict[str, langchain.schema.Document])[source]#
Simple in memory docstore in the form of a dict.
add(texts: Dict[str, langchain.schema.Document]) β None[source]#
Add texts to in memory dictionary.
search(search: s... | https:///python.langchain.com/en/latest/reference/modules/docstore.html |
8da18af31df3-0 | .rst
.pdf
PromptTemplates
PromptTemplates#
Prompt template classes.
pydantic model langchain.prompts.BaseChatPromptTemplate[source]#
format(**kwargs: Any) β str[source]#
Format the prompt with the inputs.
Parameters
kwargs β Any arguments to be passed to the prompt template.
Returns
A formatted string.
Example:
prompt.... | https:///python.langchain.com/en/latest/reference/modules/prompts.html |
8da18af31df3-1 | file_path β Path to directory to save prompt to.
Example:
.. code-block:: python
prompt.save(file_path=βpath/prompt.yamlβ)
pydantic model langchain.prompts.ChatPromptTemplate[source]#
format(**kwargs: Any) β str[source]#
Format the prompt with the inputs.
Parameters
kwargs β Any arguments to be passed to the prompt tem... | https:///python.langchain.com/en/latest/reference/modules/prompts.html |
8da18af31df3-2 | A list of the names of the variables the prompt template expects.
field prefix: str = ''#
A prompt template string to put before the examples.
field suffix: str [Required]#
A prompt template string to put after the examples.
field template_format: str = 'f-string'#
The format of the prompt template. Options are: βf-str... | https:///python.langchain.com/en/latest/reference/modules/prompts.html |
8da18af31df3-3 | field suffix: langchain.prompts.base.StringPromptTemplate [Required]#
A PromptTemplate to put after the examples.
field template_format: str = 'f-string'#
The format of the prompt template. Options are: βf-stringβ, βjinja2β.
field validate_template: bool = True#
Whether or not to try validating the template.
dict(**kwa... | https:///python.langchain.com/en/latest/reference/modules/prompts.html |
8da18af31df3-4 | Format the prompt with the inputs.
Parameters
kwargs β Any arguments to be passed to the prompt template.
Returns
A formatted string.
Example:
prompt.format(variable1="foo")
classmethod from_examples(examples: List[str], suffix: str, input_variables: List[str], example_separator: str = '\n\n', prefix: str = '', **kwarg... | https:///python.langchain.com/en/latest/reference/modules/prompts.html |
8da18af31df3-5 | Create Chat Messages.
langchain.prompts.load_prompt(path: Union[str, pathlib.Path]) β langchain.prompts.base.BasePromptTemplate[source]#
Unified method for loading a prompt from LangChainHub or local fs.
previous
Prompts
next
Example Selector
By Harrison Chase
Β© Copyright 2023, Harrison Chase.
Last ... | https:///python.langchain.com/en/latest/reference/modules/prompts.html |
d47b5f9b3c60-0 | .rst
.pdf
Output Parsers
Output Parsers#
pydantic model langchain.output_parsers.CommaSeparatedListOutputParser[source]#
Parse out comma separated lists.
get_format_instructions() β str[source]#
Instructions on how the LLM output should be formatted.
parse(text: str) β List[str][source]#
Parse the output of an LLM call... | https:///python.langchain.com/en/latest/reference/modules/output_parsers.html |
d47b5f9b3c60-1 | field retry_chain: langchain.chains.llm.LLMChain [Required]#
classmethod from_llm(llm: langchain.base_language.BaseLanguageModel, parser: langchain.schema.BaseOutputParser[langchain.output_parsers.fix.T], prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['completion', 'error', 'instruc... | https:///python.langchain.com/en/latest/reference/modules/output_parsers.html |
d47b5f9b3c60-2 | and parses it into some structure.
Parameters
text β output of language model
Returns
structured output
pydantic model langchain.output_parsers.RegexDictParser[source]#
Class to parse the output into a dictionary.
field no_update_value: Optional[str] = None#
field output_key_to_format: Dict[str, str] [Required]#
field ... | https:///python.langchain.com/en/latest/reference/modules/output_parsers.html |
d47b5f9b3c60-3 | field retry_chain: langchain.chains.llm.LLMChain [Required]#
classmethod from_llm(llm: langchain.base_language.BaseLanguageModel, parser: langchain.schema.BaseOutputParser[langchain.output_parsers.retry.T], prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['completion', 'prompt'], outp... | https:///python.langchain.com/en/latest/reference/modules/output_parsers.html |
d47b5f9b3c60-4 | that was raised to another language and telling it that the completion
did not work, and raised the given error. Differs from RetryOutputParser
in that this implementation provides the error that was raised back to the
LLM, which in theory should give it more information on how to fix it.
field parser: langchain.schema... | https:///python.langchain.com/en/latest/reference/modules/output_parsers.html |
d47b5f9b3c60-5 | The prompt is largely provided in the event the OutputParser wants
to retry or fix the output in some way, and needs information from
the prompt to do so.
Parameters
completion β output of language model
prompt β prompt value
Returns
structured output
pydantic model langchain.output_parsers.StructuredOutputParser[sourc... | https:///python.langchain.com/en/latest/reference/modules/output_parsers.html |
9da2ed2dc386-0 | .rst
.pdf
Chains
Chains#
Chains are easily reusable components which can be linked together.
pydantic model langchain.chains.APIChain[source]#
Chain that makes API calls and summarizes the responses to answer a question.
Validators
raise_deprecation Β» all fields
set_verbose Β» verbose
validate_api_answer_prompt Β» all fi... | https:///python.langchain.com/en/latest/reference/modules/chains.html |
9da2ed2dc386-1 | field requests_wrapper: TextRequestsWrapper [Required]#
classmethod from_llm_and_api_docs(llm: langchain.base_language.BaseLanguageModel, api_docs: str, headers: Optional[dict] = None, api_url_prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['api_docs', 'question'], output_parser=None... | https:///python.langchain.com/en/latest/reference/modules/chains.html |
9da2ed2dc386-2 | pydantic model langchain.chains.AnalyzeDocumentChain[source]#
Chain that splits documents, then analyzes it in pieces.
Validators
raise_deprecation Β» all fields
set_verbose Β» verbose
field combine_docs_chain: langchain.chains.combine_documents.base.BaseCombineDocumentsChain [Required]#
field text_splitter: langchain.te... | https:///python.langchain.com/en/latest/reference/modules/chains.html |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.