id stringlengths 14 16 | text stringlengths 29 2.73k | source stringlengths 49 117 |
|---|---|---|
8638e59a7ff7-0 | .rst
.pdf
Agents
Agents#
Reference guide for Agents and associated abstractions.
Agents
Tools
Agent Toolkits
previous
Memory
next
Agents
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on May 29, 2023. | https://python.langchain.com/en/latest/reference/agents.html |
ef4a57912db1-0 | .md
.pdf
Installation
Contents
Official Releases
Installing from source
Installation#
Official Releases#
LangChain is available on PyPi, so to it is easily installable with:
pip install langchain
That will install the bare minimum requirements of LangChain.
A lot of the value of LangChain comes when integrating it wi... | https://python.langchain.com/en/latest/reference/installation.html |
2917dc0c0005-0 | .rst
.pdf
Models
Models#
LangChain provides interfaces and integrations for a number of different types of models.
LLMs
Chat Models
Embeddings
previous
API References
next
Chat Models
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on May 29, 2023. | https://python.langchain.com/en/latest/reference/models.html |
04fcbd298122-0 | .rst
.pdf
Chat Models
Chat Models#
pydantic model langchain.chat_models.AzureChatOpenAI[source]#
Wrapper around Azure OpenAI Chat Completion API. To use this class you
must have a deployed model on Azure OpenAI. Use deployment_name in the
constructor to refer to the “Model deployment name” in the Azure portal.
In addit... | https://python.langchain.com/en/latest/reference/modules/chat_models.html |
04fcbd298122-1 | Example
get_num_tokens(text: str) → int[source]#
Calculate number of tokens.
pydantic model langchain.chat_models.ChatGooglePalm[source]#
Wrapper around Google’s PaLM Chat API.
To use you must have the google.generativeai Python package installed and
either:
The GOOGLE_API_KEY` environment varaible set with your API ke... | https://python.langchain.com/en/latest/reference/modules/chat_models.html |
04fcbd298122-2 | in, even if not explicitly saved on this class.
Example
from langchain.chat_models import ChatOpenAI
openai = ChatOpenAI(model_name="gpt-3.5-turbo")
field max_retries: int = 6#
Maximum number of retries to make when generating.
field max_tokens: Optional[int] = None#
Maximum number of tokens to generate.
field model_kw... | https://python.langchain.com/en/latest/reference/modules/chat_models.html |
04fcbd298122-3 | main/examples/How_to_format_inputs_to_ChatGPT_models.ipynb
get_token_ids(text: str) → List[int][source]#
Get the tokens present in the text with tiktoken package.
pydantic model langchain.chat_models.ChatVertexAI[source]#
Wrapper around Vertex AI large language models.
field model_name: str = 'chat-bison'#
Model name t... | https://python.langchain.com/en/latest/reference/modules/chat_models.html |
172929e6f6ba-0 | .rst
.pdf
Python REPL
Python REPL#
For backwards compatibility.
pydantic model langchain.python.PythonREPL[source]#
Simulates a standalone Python REPL.
field globals: Optional[Dict] [Optional] (alias '_globals')#
field locals: Optional[Dict] [Optional] (alias '_locals')#
run(command: str) → str[source]#
Run command wit... | https://python.langchain.com/en/latest/reference/modules/python.html |
3024c969b97e-0 | .rst
.pdf
Example Selector
Example Selector#
Logic for selecting examples to include in prompts.
pydantic model langchain.prompts.example_selector.LengthBasedExampleSelector[source]#
Select examples based on length.
Validators
calculate_example_text_lengths » example_text_lengths
field example_prompt: langchain.prompts... | https://python.langchain.com/en/latest/reference/modules/example_selector.html |
3024c969b97e-1 | Create k-shot example selector using example list and embeddings.
Reshuffles examples dynamically based on query similarity.
Parameters
examples – List of examples to use in the prompt.
embeddings – An iniialized embedding API interface, e.g. OpenAIEmbeddings().
vectorstore_cls – A vector store DB interface class, e.g.... | https://python.langchain.com/en/latest/reference/modules/example_selector.html |
3024c969b97e-2 | Create k-shot example selector using example list and embeddings.
Reshuffles examples dynamically based on query similarity.
Parameters
examples – List of examples to use in the prompt.
embeddings – An initialized embedding API interface, e.g. OpenAIEmbeddings().
vectorstore_cls – A vector store DB interface class, e.g... | https://python.langchain.com/en/latest/reference/modules/example_selector.html |
3c81d7efa455-0 | .rst
.pdf
Text Splitter
Text Splitter#
Functionality for splitting text.
class langchain.text_splitter.CharacterTextSplitter(separator: str = '\n\n', **kwargs: Any)[source]#
Implementation of splitting text that looks at characters.
split_text(text: str) → List[str][source]#
Split incoming text and return chunks.
class... | https://python.langchain.com/en/latest/reference/modules/text_splitter.html |
3c81d7efa455-1 | Split incoming text and return chunks.
class langchain.text_splitter.TextSplitter(chunk_size: int = 4000, chunk_overlap: int = 200, length_function: typing.Callable[[str], int] = <built-in function len>, keep_separator: bool = False)[source]#
Interface for splitting text into chunks.
async atransform_documents(document... | https://python.langchain.com/en/latest/reference/modules/text_splitter.html |
3c81d7efa455-2 | Transform sequence of documents by splitting them.
class langchain.text_splitter.TokenTextSplitter(encoding_name: str = 'gpt2', model_name: Optional[str] = None, allowed_special: Union[Literal['all'], AbstractSet[str]] = {}, disallowed_special: Union[Literal['all'], Collection[str]] = 'all', **kwargs: Any)[source]#
Imp... | https://python.langchain.com/en/latest/reference/modules/text_splitter.html |
e5765e2c5438-0 | .rst
.pdf
SearxNG Search
Contents
Quick Start
Searching
Engine Parameters
Search Tips
SearxNG Search#
Utility for using SearxNG meta search API.
SearxNG is a privacy-friendly free metasearch engine that aggregates results from
multiple search engines and databases and
supports the OpenSearch
specification.
More detai... | https://python.langchain.com/en/latest/reference/modules/searx_search.html |
e5765e2c5438-1 | # assuming the searx host is set as above or exported as an env variable
s = SearxSearchWrapper(engines=['google', 'bing'],
language='es')
Search Tips#
Searx offers a special
search syntax
that can also be used instead of passing engine parameters.
For example the following query:
s = SearxSearchWra... | https://python.langchain.com/en/latest/reference/modules/searx_search.html |
e5765e2c5438-2 | use a self hosted instance and disable the rate limiter.
If you are self-hosting an instance you can customize the rate limiter for your
own network as described here.
For a list of public SearxNG instances see https://searx.space/
class langchain.utilities.searx_search.SearxResults(data: str)[source]#
Dict like wrappe... | https://python.langchain.com/en/latest/reference/modules/searx_search.html |
e5765e2c5438-3 | 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) → List[Dict][source]#
Asynchronously query with json results... | https://python.langchain.com/en/latest/reference/modules/searx_search.html |
e5765e2c5438-4 | Run query through Searx API and parse results.
You can pass any other params to the searx query API.
Parameters
query – The query to search for.
query_suffix – Extra suffix appended to the query.
engines – List of engines to use for the query.
categories – List of categories to use for the query.
**kwargs – extra param... | https://python.langchain.com/en/latest/reference/modules/searx_search.html |
874aca72d048-0 | .rst
.pdf
Utilities
Utilities#
General utilities.
pydantic model langchain.utilities.ApifyWrapper[source]#
Wrapper around Apify.
To use, you should have the apify-client python package installed,
and the environment variable APIFY_API_TOKEN set with your API key, or pass
apify_api_token as a named parameter to the cons... | https://python.langchain.com/en/latest/reference/modules/utilities.html |
874aca72d048-1 | Return type
ApifyDatasetLoader
call_actor(actor_id: str, run_input: Dict, dataset_mapping_function: Callable[[Dict], langchain.schema.Document], *, build: Optional[str] = None, memory_mbytes: Optional[int] = None, timeout_secs: Optional[int] = None) → langchain.document_loaders.apify_dataset.ApifyDatasetLoader[source]#... | https://python.langchain.com/en/latest/reference/modules/utilities.html |
874aca72d048-2 | Parameters
top_k_results – number of the top-scored document used for the arxiv tool
ARXIV_MAX_QUERY_LENGTH – the cut limit on the query used for the arxiv tool.
load_max_docs – a limit to the number of loaded documents
load_all_available_meta –
if True: the metadata of the loaded Documents gets all available meta inf... | https://python.langchain.com/en/latest/reference/modules/utilities.html |
874aca72d048-3 | pydantic model langchain.utilities.BingSearchAPIWrapper[source]#
Wrapper for Bing Search API.
In order to set this up, follow instructions at:
https://levelup.gitconnected.com/api-tutorial-how-to-use-bing-web-search-api-in-python-4165d5592a7e
field bing_search_url: str [Required]#
field bing_subscription_key: str [Requ... | https://python.langchain.com/en/latest/reference/modules/utilities.html |
874aca72d048-4 | Returns
snippet - The description of the result.
title - The title of the result.
link - The link to the result.
Return type
A list of dictionaries with the following keys
run(query: str) → str[source]#
pydantic model langchain.utilities.GooglePlacesAPIWrapper[source]#
Wrapper around Google Places API.
To use, you shou... | https://python.langchain.com/en/latest/reference/modules/utilities.html |
874aca72d048-5 | - Install the library using pip install google-api-python-client
The current version of the library is 2.70.0 at this time
2. To create an API key:
- Navigate to the APIs & Services→Credentials panel in Cloud Console.
- Select Create credentials, then select API key from the drop-down menu.
- The API key created dialog... | https://python.langchain.com/en/latest/reference/modules/utilities.html |
874aca72d048-6 | title - The title of the result.
link - The link to the result.
Return type
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.
Y... | https://python.langchain.com/en/latest/reference/modules/utilities.html |
874aca72d048-7 | This wrapper will use the GraphQL API to conduct queries.
field custom_headers: Optional[Dict[str, str]] = None#
field graphql_endpoint: str [Required]#
run(query: str) → str[source]#
Run a GraphQL query and get the results.
pydantic model langchain.utilities.LambdaWrapper[source]#
Wrapper for AWS Lambda SDK.
Docs for ... | https://python.langchain.com/en/latest/reference/modules/utilities.html |
874aca72d048-8 | Wrapper for OpenWeatherMap API using PyOWM.
Docs for using:
Go to OpenWeatherMap and sign up for an API key
Save your API KEY into OPENWEATHERMAP_API_KEY env variable
pip install pyowm
field openweathermap_api_key: Optional[str] = None#
field owm: Any = None#
run(location: str) → str[source]#
Get the current weather in... | https://python.langchain.com/en/latest/reference/modules/utilities.html |
874aca72d048-9 | get_schemas() → str[source]#
Get the available schema’s.
get_table_info(table_names: Optional[Union[List[str], str]] = None) → str[source]#
Get information about specified tables.
get_table_names() → Iterable[str][source]#
Get names of tables available.
run(command: str) → Any[source]#
Execute a DAX command and return ... | https://python.langchain.com/en/latest/reference/modules/utilities.html |
874aca72d048-10 | # note the unsecure parameter is not needed if you pass the url scheme as
# http
searx = SearxSearchWrapper(searx_host="http://localhost:8888",
unsecure=True)
Validators
disable_ssl_warnings » unsecure
validate_params » all fields
field aiosession: Optional[Any] = None#
field cat... | https://python.langchain.com/en/latest/reference/modules/utilities.html |
874aca72d048-11 | **kwargs – extra parameters to pass to the searx API.
Returns
{snippet: The description of the result.
title: The title of the result.
link: The link to the result.
engines: The engines used for the result.
category: Searx category of the result.
}
Return type
Dict with the following keys
run(query: str, engines: Opt... | https://python.langchain.com/en/latest/reference/modules/utilities.html |
874aca72d048-12 | To use, you should have the google-search-results python package installed,
and the environment variable SERPAPI_API_KEY set with your API key, or pass
serpapi_api_key as a named parameter to the constructor.
Example
from langchain import SerpAPIWrapper
serpapi = SerpAPIWrapper()
field aiosession: Optional[aiohttp.clie... | https://python.langchain.com/en/latest/reference/modules/utilities.html |
874aca72d048-13 | For example: SparkSQL.from_uri(“sc://localhost:15002”)
get_table_info(table_names: Optional[List[str]] = None) → str[source]#
get_table_info_no_throw(table_names: Optional[List[str]] = None) → str[source]#
Get information about specified tables.
Follows best practices as specified in: Rajkumar et al, 2022
(https://arxi... | https://python.langchain.com/en/latest/reference/modules/utilities.html |
874aca72d048-14 | PATCH the URL and return the text asynchronously.
async apost(url: str, data: Dict[str, Any], **kwargs: Any) → str[source]#
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, **kwar... | https://python.langchain.com/en/latest/reference/modules/utilities.html |
874aca72d048-15 | field account_sid: Optional[str] = None#
Twilio account string identifier.
field auth_token: Optional[str] = None#
Twilio auth token.
field from_number: Optional[str] = None#
A Twilio phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164)
format, an
[alphanumeric sender ID](https://www.twilio.com/docs/... | https://python.langchain.com/en/latest/reference/modules/utilities.html |
874aca72d048-16 | fetch page summaries. By default, it will return the page summaries
of the top-k results.
It limits the Document content by doc_content_chars_max.
field doc_content_chars_max: int = 4000#
field lang: str = 'en'#
field load_all_available_meta: bool = False#
field top_k_results: int = 3#
load(query: str) → List[langchain... | https://python.langchain.com/en/latest/reference/modules/utilities.html |
49e6530c07c2-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 |
49e6530c07c2-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 |
49e6530c07c2-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 |
49e6530c07c2-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 |
49e6530c07c2-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 |
49e6530c07c2-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 |
49e6530c07c2-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 |
49e6530c07c2-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 |
49e6530c07c2-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 |
49e6530c07c2-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 |
49e6530c07c2-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 |
49e6530c07c2-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 |
49e6530c07c2-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 |
49e6530c07c2-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 |
49e6530c07c2-14 | filter (Optional[Dict[str, str]]) – Filter by metadata. Defaults to None.
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) → L... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
49e6530c07c2-15 | filter (Optional[Dict[str, str]]) – Filter by metadata. Defaults to None.
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]... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
49e6530c07c2-16 | document (Document) – Document to update.
class langchain.vectorstores.DeepLake(dataset_path: str = './deeplake/', token: Optional[str] = None, embedding_function: Optional[langchain.embeddings.base.Embeddings] = None, read_only: Optional[bool] = False, ingestion_batch_size: int = 1024, num_workers: int = 0, verbose: b... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
49e6530c07c2-17 | Returns
List of IDs of the added texts.
Return type
List[str]
delete(ids: Any[List[str], None] = None, filter: Any[Dict[str, str], None] = None, delete_all: Any[bool, None] = None) → bool[source]#
Delete the entities in the dataset
Parameters
ids (Optional[List[str]], optional) – The document_ids to delete.
Defaults to... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
49e6530c07c2-18 | in either the environment
Local file system path of the form ./path/to/dataset or~/path/to/dataset or path/to/dataset.
In-memory path of the form mem://path/to/dataset which doesn’tsave the dataset, but keeps it in memory instead.
Should be used only for testing as it does not persist.
documents (List[Document]) – List... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
49e6530c07c2-19 | Return docs selected using the maximal marginal relevance.
Maximal marginal relevance optimizes for similarity to query AND diversity
among selected documents.
:param embedding: Embedding to look up documents similar to.
:param k: Number of Documents to return. Defaults to 4.
:param fetch_k: Number of Documents to fetc... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
49e6530c07c2-20 | Returns
List of Documents most similar to the query vector.
similarity_search_by_vector(embedding: List[float], k: int = 4, **kwargs: Any) → List[langchain.schema.Document][source]#
Return docs most similar to embedding vector.
Parameters
embedding – Embedding to look up documents similar to.
k – Number of Documents to... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
49e6530c07c2-21 | You can install it with pip install “langchain[docarray]”.
classmethod from_params(embedding: langchain.embeddings.base.Embeddings, work_dir: str, n_dim: int, dist_metric: Literal['cosine', 'ip', 'l2'] = 'cosine', max_elements: int = 1024, index: bool = True, ef_construction: int = 200, ef: int = 10, M: int = 16, allow... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
49e6530c07c2-22 | num_threads (int) – Sets the number of cpu threads to use. Defaults to 1.
**kwargs – Other keyword arguments to be passed to the get_doc_cls method.
classmethod from_texts(texts: List[str], embedding: langchain.embeddings.base.Embeddings, metadatas: Optional[List[dict]] = None, work_dir: Optional[str] = None, n_dim: Op... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
49e6530c07c2-23 | Parameters
embedding (Embeddings) – Embedding function.
metric (str) – metric for exact nearest-neighbor search.
Can be one of: “cosine_sim”, “euclidean_dist” and “sqeuclidean_dist”.
Defaults to “cosine_sim”.
**kwargs – Other keyword arguments to be passed to the get_doc_cls method.
classmethod from_texts(texts: List[s... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
49e6530c07c2-24 | elasticsearch_url="http://localhost:9200",
index_name="test_index",
embedding=embedding
)
To connect to an Elasticsearch instance that requires login credentials,
including Elastic Cloud, use the Elasticsearch URL format
https://username:password@es_host:9243. For example, to connect to Elastic
Cloud, create th... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
49e6530c07c2-25 | embedding (Embeddings) – An object that provides the ability to embed text.
It should be an instance of a class that subclasses the Embeddings
abstract base class, such as OpenAIEmbeddings()
Raises
ValueError – If the elasticsearch python package is not installed.
add_texts(texts: Iterable[str], metadatas: Optional[Lis... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
49e6530c07c2-26 | embeddings,
elasticsearch_url="http://localhost:9200"
)
similarity_search(query: str, k: int = 4, filter: Optional[dict] = None, **kwargs: Any) → List[langchain.schema.Document][source]#
Return docs most similar to query.
Parameters
query – Text to look up documents similar to.
k – Number of Documents to return. De... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
49e6530c07c2-27 | Run more texts through the embeddings and add to the vectorstore.
Parameters
text_embeddings – Iterable pairs of string and embedding to
add to the vectorstore.
metadatas – Optional list of metadatas associated with the texts.
ids – Optional list of unique IDs.
Returns
List of ids from adding the texts into the vectors... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
49e6530c07c2-28 | faiss = FAISS.from_embeddings(text_embedding_pairs, embeddings)
classmethod from_texts(texts: List[str], embedding: langchain.embeddings.base.Embeddings, metadatas: Optional[List[dict]] = None, ids: Optional[List[str]] = None, **kwargs: Any) → langchain.vectorstores.faiss.FAISS[source]#
Construct FAISS wrapper from raw... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
49e6530c07c2-29 | 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 |
49e6530c07c2-30 | and index_to_docstore_id to.
index_name – for saving with a specific index file name
similarity_search(query: str, k: int = 4, **kwargs: Any) → List[langchain.schema.Document][source]#
Return docs most similar to query.
Parameters
query – Text to look up documents similar to.
k – Number of Documents to return. Defaults... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
49e6530c07c2-31 | Returns
List of Documents most similar to the query and score for each
class langchain.vectorstores.LanceDB(connection: Any, embedding: langchain.embeddings.base.Embeddings, vector_key: Optional[str] = 'vector', id_key: Optional[str] = 'id', text_key: Optional[str] = 'text')[source]#
Wrapper around LanceDB vector datab... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
49e6530c07c2-32 | Return documents most similar to the query
Parameters
query – String to query the vectorstore with.
k – Number of documents to return.
Returns
List of documents most similar to the query.
class langchain.vectorstores.Milvus(embedding_function: langchain.embeddings.base.Embeddings, collection_name: str = 'LangChainColle... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
49e6530c07c2-33 | Returns
The resulting keys for each inserted element.
Return type
List[str]
classmethod from_texts(texts: List[str], embedding: langchain.embeddings.base.Embeddings, metadatas: Optional[List[dict]] = None, collection_name: str = 'LangChainCollection', connection_args: dict[str, Any] = {'host': 'localhost', 'password': ... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
49e6530c07c2-34 | Returns
Milvus Vector Store
Return type
Milvus
max_marginal_relevance_search(query: str, 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[langchain.schema.Document][source]#
Perform a search and return... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
49e6530c07c2-35 | Parameters
embedding (str) – The embedding vector being searched.
k (int, optional) – How many results to give. Defaults to 4.
fetch_k (int, optional) – Total results to select k from.
Defaults to 20.
lambda_mult – Number between 0 and 1 that determines the degree
of diversity among the results with 0 corresponding
to ... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
49e6530c07c2-36 | Returns
Document results for search.
Return type
List[Document]
similarity_search_by_vector(embedding: List[float], k: int = 4, param: Optional[dict] = None, expr: Optional[str] = None, timeout: Optional[int] = None, **kwargs: Any) → List[langchain.schema.Document][source]#
Perform a similarity search against the query... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
49e6530c07c2-37 | 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() keyword arguments.
Return type
List[float], List[Tuple[Document, any, any]]
similarity_search_with_score_by_vector(embedding: L... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
49e6530c07c2-38 | to connect to MyScale.
MyScale can not only search with simple vector indexes,
it also supports complex query with multiple conditions,
constraints and even sub-queries.
For more information, please visit[myscale official site](https://docs.myscale.com/en/overview/)
add_texts(texts: Iterable[str], metadatas: Optional[L... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
49e6530c07c2-39 | Defaults to 32.
metadata (List[dict], optional) – metadata to texts. Defaults to None.
into (Other keyword arguments will pass) – [clickhouse-connect](https://clickhouse.com/docs/en/integrations/python#clickhouse-connect-driver-api)
Returns
MyScale Index
property metadata_column: str#
similarity_search(query: str, k: i... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
49e6530c07c2-40 | Returns
List of (Document, similarity)
Return type
List[Document]
similarity_search_with_relevance_scores(query: str, k: int = 4, where_str: Optional[str] = None, **kwargs: Any) → List[Tuple[langchain.schema.Document, float]][source]#
Perform a similarity search with MyScale
Parameters
query (str) – query string
k (int... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
49e6530c07c2-41 | must be same size to number of columns. For example:
.. code-block:: python
{
‘id’: ‘text_id’,
‘vector’: ‘text_embedding’,
‘text’: ‘text_plain’,
‘metadata’: ‘metadata_dictionary_in_json’,
}
Defaults to identity map.
Show JSON schema{
"title": "MyScaleSettings",
"description": "MyScale Client Configuration\n\nAttr... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
49e6530c07c2-42 | "type": "object",
"properties": {
"host": {
"title": "Host",
"default": "localhost",
"env_names": "{'myscale_host'}",
"type": "string"
},
"port": {
"title": "Port",
"default": 8443,
"env_names": "{'myscale_port'}",
"type": "int... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
49e6530c07c2-43 | "type": "string"
}
},
"database": {
"title": "Database",
"default": "default",
"env_names": "{'myscale_database'}",
"type": "string"
},
"table": {
"title": "Table",
"default": "langchain",
"env_names": "{'myscale_table'}",
... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
49e6530c07c2-44 | field table: str = 'langchain'#
field username: Optional[str] = None#
class langchain.vectorstores.OpenSearchVectorSearch(opensearch_url: str, index_name: str, embedding_function: langchain.embeddings.base.Embeddings, **kwargs: Any)[source]#
Wrapper around OpenSearch as a vector database.
Example
from langchain import ... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
49e6530c07c2-45 | texts,
embeddings,
opensearch_url="http://localhost:9200"
)
OpenSearch by default supports Approximate Search powered by nmslib, faiss
and lucene engines recommended for large datasets. Also supports brute force
search through Script Scoring and Painless Scripting.
Optional Args:vector_field: Document field emb... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
49e6530c07c2-46 | Returns
List of Documents most similar to the query.
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”.
metadata_field: Document field that metadata is stored in. Defaults to
“metadata”.
C... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
49e6530c07c2-47 | Return docs and it’s scores most similar to query.
By default supports Approximate Search.
Also supports Script Scoring and Painless Scripting.
Parameters
query – Text to look up documents similar to.
k – Number of Documents to return. Defaults to 4.
Returns
List of Documents along with its scores most similar to the q... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
49e6530c07c2-48 | Returns
List of ids from adding the texts into the vectorstore.
classmethod from_existing_index(index_name: str, embedding: langchain.embeddings.base.Embeddings, text_key: str = 'text', namespace: Optional[str] = None) → langchain.vectorstores.pinecone.Pinecone[source]#
Load pinecone vectorstore from index name.
classm... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
49e6530c07c2-49 | k – Number of Documents to return. Defaults to 4.
filter – Dictionary of argument(s) to filter on metadata
namespace – Namespace to search in. Default will search in ‘’ namespace.
Returns
List of Documents most similar to the query and score for each
similarity_search_with_score(query: str, k: int = 4, filter: Optional... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
49e6530c07c2-50 | Run more texts through the embeddings and add to the vectorstore.
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_texts(texts: List[str], embedding: langch... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
49e6530c07c2-51 | port – Port of the REST API interface. Default: 6333
grpc_port – Port of the gRPC interface. Default: 6334
prefer_grpc – If true - use gPRC interface whenever possible in custom methods.
Default: False
https – If true - use HTTPS(SSL) protocol. Default: None
api_key – API key for authentication in Qdrant Cloud. Default... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
49e6530c07c2-52 | This is intended to be a quick way to get started.
Example
from langchain import Qdrant
from langchain.embeddings import OpenAIEmbeddings
embeddings = OpenAIEmbeddings()
qdrant = Qdrant.from_texts(texts, embeddings, "localhost")
max_marginal_relevance_search(query: str, k: int = 4, fetch_k: int = 20, lambda_mult: float... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
49e6530c07c2-53 | Returns
List of Documents most similar to the query.
similarity_search_with_score(query: str, k: int = 4, filter: Optional[Dict[str, Union[str, int, bool, dict, list]]] = None) → List[Tuple[langchain.schema.Document, float]][source]#
Return docs most similar to query.
Parameters
query – Text to look up documents simila... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
49e6530c07c2-54 | Parameters
texts (Iterable[str]) – Iterable of strings/text to add to the vectorstore.
metadatas (Optional[List[dict]], optional) – Optional list of metadatas.
Defaults to None.
embeddings (Optional[List[List[float]]], optional) – Optional pre-generated
embeddings. Defaults to None.
keys (Optional[List[str]], optional)... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
49e6530c07c2-55 | Create a Redis vectorstore from raw documents.
This is a user-friendly interface that:
Embeds documents.
Creates a new index for the embeddings in Redis.
Adds the documents to the newly created Redis index.
This is intended to be a quick way to get started.
.. rubric:: Example
classmethod from_texts_return_keys(texts: ... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
49e6530c07c2-56 | Returns the most similar indexed documents to the query text within the
score_threshold range.
Parameters
query (str) – The query text for which to find similar documents.
k (int) – The number of documents to return. Default is 4.
score_threshold (float) – The minimum matching score required for a document
0.2. (to be ... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
49e6530c07c2-57 | Run more texts through the embeddings and add to the vectorstore.
Parameters
texts – Iterable of strings to add to the vectorstore.
metadatas – Optional list of metadatas associated with the texts.
kwargs – vectorstore specific parameters
Returns
List of ids from adding the texts into the vectorstore.
classmethod from_... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
49e6530c07c2-58 | If you’d like to use max_marginal_relevance_search, please review the instructions
below on modifying the match_documents function to return matched embeddings.
add_texts(texts: Iterable[str], metadatas: Optional[List[dict[Any, Any]]] = None, **kwargs: Any) → List[str][source]#
Run more texts through the embeddings and... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
49e6530c07c2-59 | 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_marginal_relevance_search requires that query_name returns matched
embeddings alongside the match documents. The following function ... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
49e6530c07c2-60 | Returns
List of Documents selected by maximal marginal relevance.
query_name: str#
similarity_search(query: str, k: int = 4, **kwargs: Any) → List[langchain.schema.Document][source]#
Return docs most similar to query.
similarity_search_by_vector(embedding: List[float], k: int = 4, **kwargs: Any) → List[langchain.schema... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
49e6530c07c2-61 | Returns
List of Tuples of (doc, similarity_score)
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(... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
49e6530c07c2-62 | 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 |
49e6530c07c2-63 | "connection_timeout_seconds": 2
}
)
typesense_collection_name = "langchain-memory"
embedding = OpenAIEmbeddings()
vectorstore = Typesense(
typesense_client,
typesense_collection_name,
embedding.embed_query,
"text",
)
add_texts(texts: Iterable[str], metadatas: Optional[List[dict]] = None, ids: Option... | https://python.langchain.com/en/latest/reference/modules/vectorstores.html |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.