id
stringlengths
14
16
text
stringlengths
31
3.14k
source
stringlengths
58
124
281c3974db09-0
.rst .pdf SerpAPI SerpAPI# For backwards compatiblity. pydantic model langchain.serpapi.SerpAPIWrapper[source]# Wrapper around SerpAPI. 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 param...
/content/https://python.langchain.com/en/latest/reference/modules/serpapi.html
b784a0b2f8ab-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...
/content/https://python.langchain.com/en/latest/reference/modules/docstore.html
a34233c6d0ce-0
.rst .pdf Document Compressors Document Compressors# pydantic model langchain.retrievers.document_compressors.DocumentCompressorPipeline[source]# Document compressor that uses a pipeline of transformers. field transformers: List[Union[langchain.schema.BaseDocumentTransformer, langchain.retrievers.document_compressors.b...
/content/https://python.langchain.com/en/latest/reference/modules/document_compressors.html
a34233c6d0ce-1
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 similarity_threshold: Optional[float] = None# Threshold for determining when two documents are similar enough to be consid...
/content/https://python.langchain.com/en/latest/reference/modules/document_compressors.html
a34233c6d0ce-2
Compress retrieved documents given the query context. compress_documents(documents: Sequence[langchain.schema.Document], query: str) → Sequence[langchain.schema.Document][source]# Compress page content of raw documents. classmethod from_llm(llm: langchain.schema.BaseLanguageModel, prompt: Optional[langchain.prompts.pro...
/content/https://python.langchain.com/en/latest/reference/modules/document_compressors.html
a34233c6d0ce-3
Filter down documents. compress_documents(documents: Sequence[langchain.schema.Document], query: str) → Sequence[langchain.schema.Document][source]# Filter down documents based on their relevance to the query. classmethod from_llm(llm: langchain.schema.BaseLanguageModel, prompt: Optional[langchain.prompts.base.BaseProm...
/content/https://python.langchain.com/en/latest/reference/modules/document_compressors.html
f9e722af2602-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...
/content/https://python.langchain.com/en/latest/reference/modules/output_parsers.html
f9e722af2602-1
Parse the output of an LLM call. pydantic model langchain.output_parsers.OutputFixingParser[source]# Wraps a parser and tries to fix parsing errors. field parser: langchain.schema.BaseOutputParser[langchain.output_parsers.fix.T] [Required]# field retry_chain: langchain.chains.llm.LLMChain [Required]#
/content/https://python.langchain.com/en/latest/reference/modules/output_parsers.html
f9e722af2602-2
classmethod from_llm(llm: langchain.schema.BaseLanguageModel, parser: langchain.schema.BaseOutputParser[langchain.output_parsers.fix.T], prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['completion', 'error', 'instructions'], output_parser=None, partial_variables={}, template='Instruc...
/content/https://python.langchain.com/en/latest/reference/modules/output_parsers.html
f9e722af2602-3
and parses it into some structure. Parameters text – output of language model Returns structured output pydantic model langchain.output_parsers.PydanticOutputParser[source]# field pydantic_object: Type[langchain.output_parsers.pydantic.T] [Required]# get_format_instructions() → str[source]# Instructions on how the LLM ...
/content/https://python.langchain.com/en/latest/reference/modules/output_parsers.html
f9e722af2602-4
field regex: str [Required]# parse(text: str) → Dict[str, str][source]# Parse the output of an LLM call. pydantic model langchain.output_parsers.ResponseSchema[source]# field description: str [Required]# field name: str [Required]# pydantic model langchain.output_parsers.RetryOutputParser[source]# Wraps a parser and tr...
/content/https://python.langchain.com/en/latest/reference/modules/output_parsers.html
f9e722af2602-5
classmethod from_llm(llm: langchain.schema.BaseLanguageModel, parser: langchain.schema.BaseOutputParser[langchain.output_parsers.retry.T], prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['completion', 'prompt'], output_parser=None, partial_variables={}, template='Prompt:\n{prompt}\nC...
/content/https://python.langchain.com/en/latest/reference/modules/output_parsers.html
f9e722af2602-6
Optional method to parse the output of an LLM call with a prompt. 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 py...
/content/https://python.langchain.com/en/latest/reference/modules/output_parsers.html
f9e722af2602-7
classmethod from_llm(llm: langchain.schema.BaseLanguageModel, parser: langchain.schema.BaseOutputParser[langchain.output_parsers.retry.T], prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['completion', 'error', 'prompt'], output_parser=None, partial_variables={}, template='Prompt:\n{p...
/content/https://python.langchain.com/en/latest/reference/modules/output_parsers.html
f9e722af2602-8
Parameters text – output of language model Returns structured output parse_with_prompt(completion: str, prompt_value: langchain.schema.PromptValue) → langchain.output_parsers.retry.T[source]# Optional method to parse the output of an LLM call with a prompt. The prompt is largely provided in the event the OutputParser w...
/content/https://python.langchain.com/en/latest/reference/modules/output_parsers.html
a6412d66a7f3-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...
/content/https://python.langchain.com/en/latest/reference/modules/text_splitter.html
a6412d66a7f3-1
Recursively tries to split by different characters to find one that works. split_text(text: str) → List[str][source]# Split incoming text and return chunks. class langchain.text_splitter.SpacyTextSplitter(separator: str = '\n\n', pipeline: str = 'en_core_web_sm', **kwargs: Any)[source]# Implementation of splitting text...
/content/https://python.langchain.com/en/latest/reference/modules/text_splitter.html
a6412d66a7f3-2
Text splitter that uses HuggingFace tokenizer to count length. classmethod from_tiktoken_encoder(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) → langchain.te...
/content/https://python.langchain.com/en/latest/reference/modules/text_splitter.html
a6412d66a7f3-3
split_text(text: str) → List[str][source]# Split incoming text and return chunks. previous Docstore next Document Loaders By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 26, 2023.
/content/https://python.langchain.com/en/latest/reference/modules/text_splitter.html
a68d7de27bc2-0
.rst .pdf Embeddings Embeddings# Wrappers around embedding modules. pydantic model langchain.embeddings.AlephAlphaAsymmetricSemanticEmbedding[source]# Wrapper for Aleph Alpha’s Asymmetric Embeddings AA provides you with an endpoint to embed a document and a query. The models were optimized to make the embeddings of doc...
/content/https://python.langchain.com/en/latest/reference/modules/embeddings.html
a68d7de27bc2-1
Optional parameter that specifies which datacenters may process the request. field model: Optional[str] = 'luminous-base'# Model name to use. field normalize: Optional[bool] = True# Should returned embeddings be normalized embed_documents(texts: List[str]) → List[List[float]][source]# Call out to Aleph Alpha’s asymmetr...
/content/https://python.langchain.com/en/latest/reference/modules/embeddings.html
a68d7de27bc2-2
Returns Embeddings for the text. pydantic model langchain.embeddings.CohereEmbeddings[source]# Wrapper around Cohere embedding models. To use, you should have the cohere python package installed, and the environment variable COHERE_API_KEY set with your API key or pass it as a named parameter to the constructor. Exampl...
/content/https://python.langchain.com/en/latest/reference/modules/embeddings.html
a68d7de27bc2-3
Embed query text. pydantic model langchain.embeddings.HuggingFaceEmbeddings[source]# Wrapper around sentence_transformers embedding models. To use, you should have the sentence_transformers python package installed. Example from langchain.embeddings import HuggingFaceEmbeddings model_name = "sentence-transformers/all-m...
/content/https://python.langchain.com/en/latest/reference/modules/embeddings.html
a68d7de27bc2-4
text – The text to embed. Returns Embeddings for the text. pydantic model langchain.embeddings.HuggingFaceHubEmbeddings[source]# Wrapper around HuggingFaceHub embedding models. To use, you should have the huggingface_hub python package installed, and the environment variable HUGGINGFACEHUB_API_TOKEN set with your API t...
/content/https://python.langchain.com/en/latest/reference/modules/embeddings.html
a68d7de27bc2-5
Parameters text – The text to embed. Returns Embeddings for the text. pydantic model langchain.embeddings.HuggingFaceInstructEmbeddings[source]# Wrapper around sentence_transformers embedding models. To use, you should have the sentence_transformers and InstructorEmbedding python package installed. Example from langcha...
/content/https://python.langchain.com/en/latest/reference/modules/embeddings.html
a68d7de27bc2-6
Parameters texts – The list of texts to embed. Returns List of embeddings, one for each text. embed_query(text: str) → List[float][source]# Compute query embeddings using a HuggingFace instruct model. Parameters text – The text to embed. Returns Embeddings for the text. pydantic model langchain.embeddings.LlamaCppEmbed...
/content/https://python.langchain.com/en/latest/reference/modules/embeddings.html
a68d7de27bc2-7
of threads is automatically determined. field seed: int = -1# Seed. If -1, a random seed is used. field use_mlock: bool = False# Force system to keep model in RAM. field vocab_only: bool = False# Only load the vocabulary, no weights. embed_documents(texts: List[str]) → List[List[float]][source]# Embed a list of documen...
/content/https://python.langchain.com/en/latest/reference/modules/embeddings.html
a68d7de27bc2-8
the properties of your endpoint. In addition, the deployment name must be passed as the model parameter. Example import os os.environ["OPENAI_API_TYPE"] = "azure" os.environ["OPENAI_API_BASE"] = "https://<your-endpoint.openai.azure.com/" os.environ["OPENAI_API_KEY"] = "your AzureOpenAI key" from langchain.embeddings.op...
/content/https://python.langchain.com/en/latest/reference/modules/embeddings.html
a68d7de27bc2-9
Parameters text – The text to embed. Returns Embedding for the text. pydantic model langchain.embeddings.SagemakerEndpointEmbeddings[source]# Wrapper around custom Sagemaker Inference Endpoints. To use, you must supply the endpoint name from your deployed Sagemaker model & the region where it is deployed. To authentica...
/content/https://python.langchain.com/en/latest/reference/modules/embeddings.html
a68d7de27bc2-10
credentials from IMDS will be used. See: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html field endpoint_kwargs: Optional[Dict] = None# Optional attributes passed to the invoke_endpoint function. See `boto3`_. docs for more info. .. _boto3: <https://boto3.amazonaws.com/v1/documentation/api...
/content/https://python.langchain.com/en/latest/reference/modules/embeddings.html
a68d7de27bc2-11
text – The text to embed. Returns Embeddings for the text. pydantic model langchain.embeddings.SelfHostedEmbeddings[source]# Runs custom embedding models on self-hosted remote hardware. Supported hardware includes auto-launched instances on AWS, GCP, Azure, and Lambda, as well as servers specified by IP address and SSH...
/content/https://python.langchain.com/en/latest/reference/modules/embeddings.html
a68d7de27bc2-12
import runhouse as rh from transformers import pipeline gpu = rh.cluster(name="rh-a10x", instance_type="A100:1") pipeline = pipeline(model="bert-base-uncased", task="feature-extraction") rh.blob(pickle.dumps(pipeline), path="models/pipeline.pkl").save().to(gpu, path="models") embeddings = SelfHostedHFEmbeddings.fro...
/content/https://python.langchain.com/en/latest/reference/modules/embeddings.html
a68d7de27bc2-13
text – The text to embed. Returns Embeddings for the text. pydantic model langchain.embeddings.SelfHostedHuggingFaceEmbeddings[source]# Runs sentence_transformers embedding models on self-hosted remote hardware. Supported hardware includes auto-launched instances on AWS, GCP, Azure, and Lambda, as well as servers speci...
/content/https://python.langchain.com/en/latest/reference/modules/embeddings.html
a68d7de27bc2-14
field model_load_fn: Callable = <function load_embedding_model># Function to load the model remotely on the server. field model_reqs: List[str] = ['./', 'sentence_transformers', 'torch']# Requirements to install on hardware to inference the model. pydantic model langchain.embeddings.SelfHostedHuggingFaceInstructEmbeddi...
/content/https://python.langchain.com/en/latest/reference/modules/embeddings.html
a68d7de27bc2-15
Model name to use. field model_reqs: List[str] = ['./', 'InstructorEmbedding', 'torch']# Requirements to install on hardware to inference the model. field query_instruction: str = 'Represent the question for retrieving supporting documents: '# Instruction to use for embedding query. embed_documents(texts: List[str]) → ...
/content/https://python.langchain.com/en/latest/reference/modules/embeddings.html
a68d7de27bc2-16
tf = TensorflowHubEmbeddings(model_url=url) field model_url: str = 'https://tfhub.dev/google/universal-sentence-encoder-multilingual/3'# Model name to use. embed_documents(texts: List[str]) → List[List[float]][source]# Compute doc embeddings using a TensorflowHub embedding model. Parameters texts – The list of texts to...
/content/https://python.langchain.com/en/latest/reference/modules/embeddings.html
74fa2602e439-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...
/content/https://python.langchain.com/en/latest/reference/modules/chat_models.html
74fa2602e439-1
Wrapper around Anthropic’s large language model. To use, you should have the anthropic python package installed, and the environment variable ANTHROPIC_API_KEY set with your API key, or pass it as a named parameter to the constructor. Example Validators set_callback_manager » callback_manager validate_environment » all...
/content/https://python.langchain.com/en/latest/reference/modules/chat_models.html
74fa2602e439-2
Model name to use. field n: int = 1# Number of chat completions to generate for each prompt. field openai_api_key: Optional[str] = None# field openai_organization: Optional[str] = None# field request_timeout: int = 60# Timeout in seconds for the OpenAPI request. field streaming: bool = False# Whether to stream the resu...
/content/https://python.langchain.com/en/latest/reference/modules/chat_models.html
74fa2602e439-3
All parameters that can be passed to the OpenAI LLM can also be passed here. The PromptLayerChatOpenAI adds to optional :param pl_tags: List of strings to tag the request with. :param return_pl_id: If True, the PromptLayer request ID will be returned in the generation_info field of the Generation object. Example from l...
/content/https://python.langchain.com/en/latest/reference/modules/chat_models.html
49b61cd47e96-0
.rst .pdf Agent Toolkits Agent Toolkits# Agent toolkits. pydantic model langchain.agents.agent_toolkits.JiraToolkit[source]# Jira Toolkit. field tools: List[langchain.tools.base.BaseTool] = []# classmethod from_jira_api_wrapper(jira_api_wrapper: langchain.utilities.jira.JiraAPIWrapper) → langchain.agents.agent_toolkits...
/content/https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
49b61cd47e96-1
List of API Endpoint Tools. classmethod from_llm_and_ai_plugin(llm: langchain.llms.base.BaseLLM, ai_plugin: langchain.tools.plugin.AIPlugin, requests: Optional[langchain.requests.Requests] = None, verbose: bool = False, **kwargs: Any) → langchain.agents.agent_toolkits.nla.toolkit.NLAToolkit[source]# Instantiate the too...
/content/https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
49b61cd47e96-2
Instantiate the toolkit by creating tools for each operation. classmethod from_llm_and_url(llm: langchain.llms.base.BaseLLM, open_api_url: str, requests: Optional[langchain.requests.Requests] = None, verbose: bool = False, **kwargs: Any) → langchain.agents.agent_toolkits.nla.toolkit.NLAToolkit[source]# Instantiate the ...
/content/https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
49b61cd47e96-3
Get the tools in the toolkit. pydantic model langchain.agents.agent_toolkits.PowerBIToolkit[source]# Toolkit for interacting with PowerBI dataset. field callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None# field examples: Optional[str] = None# field llm: langchain.schema.BaseLanguageModel [R...
/content/https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
49b61cd47e96-4
Toolkit for routing between vectorstores. field llm: langchain.llms.base.BaseLLM [Optional]# field vectorstores: List[langchain.agents.agent_toolkits.vectorstore.toolkit.VectorStoreInfo] [Required]# get_tools() → List[langchain.tools.base.BaseTool][source]# Get the tools in the toolkit. pydantic model langchain.agents....
/content/https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
49b61cd47e96-5
Get the tools in the toolkit. langchain.agents.agent_toolkits.create_csv_agent(llm: langchain.llms.base.BaseLLM, path: str, pandas_kwargs: Optional[dict] = None, **kwargs: Any) → langchain.agents.agent.AgentExecutor[source]# Create csv agent by loading to a dataframe and using pandas agent.
/content/https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
49b61cd47e96-6
langchain.agents.agent_toolkits.create_json_agent(llm: langchain.llms.base.BaseLLM, toolkit: langchain.agents.agent_toolkits.json.toolkit.JsonToolkit, callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, prefix: str = 'You are an agent designed to interact with JSON.\nYour goal is to return ...
/content/https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
49b61cd47e96-7
don\'t know" as the answer.\nAlways begin your interaction with the `json_spec_list_keys` tool with input "data" to see what keys exist in the JSON.\n\nNote that sometimes the value at a given path is large. In this case, you will get an error "Value is a large dictionary, should explore its keys directly".\nIn this ca...
/content/https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
49b61cd47e96-8
None, verbose: bool = False, **kwargs: Any) → langchain.agents.agent.AgentExecutor[source]#
/content/https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
49b61cd47e96-9
Construct a json agent from an LLM and tools.
/content/https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
49b61cd47e96-10
langchain.agents.agent_toolkits.create_openapi_agent(llm: langchain.llms.base.BaseLLM, toolkit: langchain.agents.agent_toolkits.openapi.toolkit.OpenAPIToolkit, callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, prefix: str = "You are an agent designed to answer questions by making web requ...
/content/https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
49b61cd47e96-11
are using a path that actually exists in the spec.\n", suffix: str = 'Begin!\n\nQuestion: {input}\nThought: I should explore the spec to find the base url for the API.\n{agent_scratchpad}', format_instructions: str = 'Use the following format:\n\nQuestion: the input question you must answer\nThought: you should always ...
/content/https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
49b61cd47e96-12
Construct a json agent from an LLM and tools. langchain.agents.agent_toolkits.create_pandas_dataframe_agent(llm: langchain.llms.base.BaseLLM, df: Any, callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, prefix: str = '\nYou are working with a pandas dataframe in Python. The name of the data...
/content/https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
49b61cd47e96-13
langchain.agents.agent_toolkits.create_pbi_agent(llm: langchain.llms.base.BaseLLM, toolkit: Optional[langchain.agents.agent_toolkits.powerbi.toolkit.PowerBIToolkit], powerbi: Optional[langchain.utilities.powerbi.PowerBIDataset] = None, callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, pre...
/content/https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
49b61cd47e96-14
wrong try to phrase the question differently and get a new query from the question to query tool.\n\nIf the question does not seem related to the dataset, just return "I don\'t know" as the answer.\n', suffix: str = 'Begin!\n\nQuestion: {input}\nThought: I should first ask which tables I have, then how each table is de...
/content/https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
49b61cd47e96-15
Construct a pbi agent from an LLM and tools.
/content/https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
49b61cd47e96-16
langchain.agents.agent_toolkits.create_pbi_chat_agent(llm: langchain.chat_models.base.BaseChatModel, toolkit: Optional[langchain.agents.agent_toolkits.powerbi.toolkit.PowerBIToolkit], powerbi: Optional[langchain.utilities.powerbi.PowerBIDataset] = None, callback_manager: Optional[langchain.callbacks.base.BaseCallbackMa...
/content/https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
49b61cd47e96-17
and return the answer. Unless the user specifies a specific number of examples they wish to obtain, always limit your query to at most {top_k} results. You can order the results by a relevant column to return the most interesting examples in the database.\n\nOverall, Assistant is a powerful system that can help with a ...
/content/https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
49b61cd47e96-18
input_variables: Optional[List[str]] = None, memory: Optional[langchain.memory.chat_memory.BaseChatMemory] = None, top_k: int = 10, verbose: bool = False, agent_kwargs: Optional[Dict[str, Any]] = None, **kwargs: Dict[str, Any]) → langchain.agents.agent.AgentExecutor[source]#
/content/https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
49b61cd47e96-19
Construct a pbi agent from an Chat LLM and tools. If you supply only a toolkit and no powerbi dataset, the same LLM is used for both. langchain.agents.agent_toolkits.create_python_agent(llm: langchain.llms.base.BaseLLM, tool: langchain.tools.python.tool.PythonREPLTool, callback_manager: Optional[langchain.callbacks.bas...
/content/https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
49b61cd47e96-20
langchain.agents.agent_toolkits.create_sql_agent(llm: langchain.llms.base.BaseLLM, toolkit: langchain.agents.agent_toolkits.sql.toolkit.SQLDatabaseToolkit, callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, prefix: str = 'You are an agent designed to interact with a SQL database.\nGiven an...
/content/https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
49b61cd47e96-21
{input}\nThought: I should look at the tables in the database to see what I can query.\n{agent_scratchpad}', format_instructions: str = 'Use the following format:\n\nQuestion: the input question you must answer\nThought: you should always think about what to do\nAction: the action to take, should be one of [{tool_names...
/content/https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
49b61cd47e96-22
Construct a sql agent from an LLM and tools. langchain.agents.agent_toolkits.create_vectorstore_agent(llm: langchain.llms.base.BaseLLM, toolkit: langchain.agents.agent_toolkits.vectorstore.toolkit.VectorStoreToolkit, callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, prefix: str = 'You are...
/content/https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
49b61cd47e96-23
Construct a vectorstore agent from an LLM and tools. langchain.agents.agent_toolkits.create_vectorstore_router_agent(llm: langchain.llms.base.BaseLLM, toolkit: langchain.agents.agent_toolkits.vectorstore.toolkit.VectorStoreRouterToolkit, callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, p...
/content/https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
ddf8cd975bdf-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....
/content/https://python.langchain.com/en/latest/reference/modules/prompts.html
ddf8cd975bdf-1
A formatted string. Example: prompt.format(variable1="foo") abstract format_prompt(**kwargs: Any) → langchain.schema.PromptValue[source]# Create Chat Messages. partial(**kwargs: Union[str, Callable[[], str]]) → langchain.prompts.base.BasePromptTemplate[source]# Return a partial of the prompt template. save(file_path: U...
/content/https://python.langchain.com/en/latest/reference/modules/prompts.html
ddf8cd975bdf-2
Parameters file_path – Path to directory to save prompt to. Example: .. code-block:: python prompt.save(file_path=”path/prompt.yaml”) pydantic model langchain.prompts.FewShotPromptTemplate[source]# Prompt template that contains few shot examples. field example_prompt: langchain.prompts.prompt.PromptTemplate [Required]#...
/content/https://python.langchain.com/en/latest/reference/modules/prompts.html
ddf8cd975bdf-3
dict(**kwargs: Any) → Dict[source]# Return a dictionary of the prompt. 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.format(variable1="foo") pydantic model langchain.prompts.FewSh...
/content/https://python.langchain.com/en/latest/reference/modules/prompts.html
ddf8cd975bdf-4
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(**kwargs: Any) → Dict[source]# Return a dictionary of the prompt. format(**...
/content/https://python.langchain.com/en/latest/reference/modules/prompts.html
ddf8cd975bdf-5
field template: str [Required]# The prompt template. 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. format(**kwargs: Any) → str[source]# Format the prompt with the inputs....
/content/https://python.langchain.com/en/latest/reference/modules/prompts.html
ddf8cd975bdf-6
examples. Default to an empty string. Returns The final prompt generated. classmethod from_file(template_file: Union[str, pathlib.Path], input_variables: List[str], **kwargs: Any) → langchain.prompts.prompt.PromptTemplate[source]# Load a prompt from a file. Parameters template_file – The path to the file containing the...
/content/https://python.langchain.com/en/latest/reference/modules/prompts.html
61c95a6bea55-0
.rst .pdf Experimental Modules Contents Autonomous Agents Generative Agents Experimental Modules# This module contains experimental modules and reproductions of existing work using LangChain primitives. Autonomous Agents# Here, we document the BabyAGI and AutoGPT classes from the langchain.experimental module. class ...
/content/https://python.langchain.com/en/latest/reference/modules/experimental.html
61c95a6bea55-1
Execute a task. classmethod from_llm(llm: langchain.schema.BaseLanguageModel, vectorstore: langchain.vectorstores.base.VectorStore, verbose: bool = False, task_execution_chain: Optional[langchain.chains.base.Chain] = None, **kwargs: Dict[str, Any]) → langchain.experimental.autonomous_agents.baby_agi.baby_agi.BabyAGI[so...
/content/https://python.langchain.com/en/latest/reference/modules/experimental.html
61c95a6bea55-2
Agent class for interacting with Auto-GPT. Generative Agents# Here, we document the GenerativeAgent and GenerativeAgentMemory classes from the langchain.experimental module. class langchain.experimental.GenerativeAgent(*, name: str, age: Optional[int] = None, traits: str = 'N/A', status: str, memory: langchain.experime...
/content/https://python.langchain.com/en/latest/reference/modules/experimental.html
61c95a6bea55-3
Return a full header of the agent’s status, summary, and current time. get_summary(force_refresh: bool = False) → str[source]# Return a descriptive summary of the agent. field last_refreshed: datetime.datetime [Optional]# The last time the character’s summary was regenerated. field llm: langchain.schema.BaseLanguageMod...
/content/https://python.langchain.com/en/latest/reference/modules/experimental.html
61c95a6bea55-4
Permanent traits to ascribe to the character. class langchain.experimental.GenerativeAgentMemory(*, llm: langchain.schema.BaseLanguageModel, memory_retriever: langchain.retrievers.time_weighted_retriever.TimeWeightedVectorStoreRetriever, verbose: bool = False, reflection_threshold: Optional[float] = None, current_plan:...
/content/https://python.langchain.com/en/latest/reference/modules/experimental.html
61c95a6bea55-5
Fetch related memories. field importance_weight: float = 0.15# How much weight to assign the memory importance. field llm: langchain.schema.BaseLanguageModel [Required]# The core language model. load_memory_variables(inputs: Dict[str, Any]) → Dict[str, str][source]# Return key-value pairs given the text input to the ch...
/content/https://python.langchain.com/en/latest/reference/modules/experimental.html
3a6668428edb-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...
/content/https://python.langchain.com/en/latest/reference/modules/retrievers.html
3a6668428edb-1
Parameters query – string to find relevant documents for Returns List of relevant documents 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 Sequence of relevant documents class langchain.re...
/content/https://python.langchain.com/en/latest/reference/modules/retrievers.html
3a6668428edb-2
elasticsearch_url. You can obtain your Elastic Cloud URL and login credentials by logging in to the Elastic Cloud console at https://cloud.elastic.co, selecting your deployment, and navigating to the “Deployments” page. To obtain your Elastic Cloud password for the default “elastic” user: Log in to the Elastic Cloud co...
/content/https://python.langchain.com/en/latest/reference/modules/retrievers.html
3a6668428edb-3
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 class langchain.retrievers.MetalRetriever(client: Any, params: Optional[dict] = None)[source]# async aget_relevant...
/content/https://python.langchain.com/en/latest/reference/modules/retrievers.html
3a6668428edb-4
Get documents relevant for a query. Parameters query – string to find relevant documents for Returns List of relevant documents pydantic model langchain.retrievers.RemoteLangChainRetriever[source]# field headers: Optional[dict] = None# field input_key: str = 'message'# field metadata_key: str = 'metadata'# field page_c...
/content/https://python.langchain.com/en/latest/reference/modules/retrievers.html
3a6668428edb-5
Parameters query – string to find relevant documents for Returns List of relevant documents classmethod from_texts(texts: List[str], embeddings: langchain.embeddings.base.Embeddings, **kwargs: Any) → langchain.retrievers.svm.SVMRetriever[source]# get_relevant_documents(query: str) → List[langchain.schema.Document][sour...
/content/https://python.langchain.com/en/latest/reference/modules/retrievers.html
3a6668428edb-6
Parameters query – string to find relevant documents for Returns List of relevant documents pydantic model langchain.retrievers.TimeWeightedVectorStoreRetriever[source]# Retriever combining embededing similarity with recency. field decay_rate: float = 0.01# The exponential decay factor used as (1.0-decay_rate)**(hrs_pa...
/content/https://python.langchain.com/en/latest/reference/modules/retrievers.html
3a6668428edb-7
Add documents to vectorstore. async aget_relevant_documents(query: str) → List[langchain.schema.Document][source]# Return documents that are relevant to the query. get_relevant_documents(query: str) → List[langchain.schema.Document][source]# Return documents that are relevant to the query. get_salient_docs(query: str) ...
/content/https://python.langchain.com/en/latest/reference/modules/retrievers.html
3a6668428edb-8
Look up similar documents in Weaviate. previous Vector Stores next Document Compressors By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 26, 2023.
/content/https://python.langchain.com/en/latest/reference/modules/retrievers.html
eeda90637871-0
.md .pdf Llama.cpp Contents Installation and Setup Wrappers LLM Embeddings Llama.cpp# This page covers how to use llama.cpp within LangChain. It is broken into two parts: installation and setup, and then references to specific Llama-cpp wrappers. Installation and Setup# Install the Python package with pip install lla...
/content/https://python.langchain.com/en/latest/ecosystem/llamacpp.html
74e12f0eb073-0
.md .pdf Pinecone Contents Installation and Setup Wrappers VectorStore Pinecone# This page covers how to use the Pinecone ecosystem within LangChain. It is broken into two parts: installation and setup, and then references to specific Pinecone wrappers. Installation and Setup# Install the Python SDK with pip install ...
/content/https://python.langchain.com/en/latest/ecosystem/pinecone.html
e85cb5755044-0
.md .pdf Hugging Face Contents Installation and Setup Wrappers LLM Embeddings Tokenizer Datasets Hugging Face# This page covers how to use the Hugging Face ecosystem (including the Hugging Face Hub) within LangChain. It is broken into two parts: installation and setup, and then references to specific Hugging Face wra...
/content/https://python.langchain.com/en/latest/ecosystem/huggingface.html
e85cb5755044-1
To use the local pipeline wrapper: from langchain.embeddings import HuggingFaceEmbeddings To use a the wrapper for a model hosted on Hugging Face Hub: from langchain.embeddings import HuggingFaceHubEmbeddings For a more detailed walkthrough of this, see this notebook Tokenizer# There are several places you can use toke...
/content/https://python.langchain.com/en/latest/ecosystem/huggingface.html
47f33361edbc-0
.ipynb .pdf Comet Contents Install Comet and Dependencies Initialize Comet and Set your Credentials Set OpenAI and SerpAPI credentials Scenario 1: Using just an LLM Scenario 2: Using an LLM in a Chain Scenario 3: Using An Agent with Tools Scenario 4: Using Custom Evaluation Metrics Comet# In this guide we will demons...
/content/https://python.langchain.com/en/latest/ecosystem/comet_tracking.html
47f33361edbc-1
from langchain.llms import OpenAI comet_callback = CometCallbackHandler( project_name="comet-example-langchain", complexity_metrics=True, stream_logs=True, tags=["llm"], visualizations=["dep"], ) manager = CallbackManager([StdOutCallbackHandler(), comet_callback]) llm = OpenAI(temperature=0.9, callb...
/content/https://python.langchain.com/en/latest/ecosystem/comet_tracking.html
47f33361edbc-2
template = """You are a playwright. Given the title of play, it is your job to write a synopsis for that title. Title: {title} Playwright: This is a synopsis for the above play:""" prompt_template = PromptTemplate(input_variables=["title"], template=template) synopsis_chain = LLMChain(llm=llm, prompt=prompt_template, c...
/content/https://python.langchain.com/en/latest/ecosystem/comet_tracking.html
47f33361edbc-3
agent = initialize_agent( tools, llm, agent="zero-shot-react-description", callback_manager=manager, verbose=True, ) agent.run( "Who is Leo DiCaprio's girlfriend? What is her current age raised to the 0.43 power?" ) comet_callback.flush_tracker(agent, finish=True) Scenario 4: Using Custom Evalua...
/content/https://python.langchain.com/en/latest/ecosystem/comet_tracking.html
47f33361edbc-4
"reference": self.reference, } reference = """ The tower is 324 metres (1,063 ft) tall, about the same height as an 81-storey building. It was the first structure to reach a height of 300 metres. It is now taller than the Chrysler Building in New York City by 5.2 metres (17 ft) Excluding transmitters, the Eiffe...
/content/https://python.langchain.com/en/latest/ecosystem/comet_tracking.html
47f33361edbc-5
measuring 125 metres (410 ft) on each side. During its construction, the Eiffel Tower surpassed the Washington Monument to become the tallest man-made structure in the world, a title it held for 41 years until the Chrysler Building in New York City was...
/content/https://python.langchain.com/en/latest/ecosystem/comet_tracking.html
94a318b4dfc7-0
.md .pdf Zilliz Contents Installation and Setup Wrappers VectorStore Zilliz# This page covers how to use the Zilliz Cloud ecosystem within LangChain. Zilliz uses the Milvus integration. It is broken into two parts: installation and setup, and then references to specific Milvus wrappers. Installation and Setup# Instal...
/content/https://python.langchain.com/en/latest/ecosystem/zilliz.html
fbcb799e3586-0
.md .pdf Google Serper Wrapper Contents Setup Wrappers Utility Output Tool Google Serper Wrapper# This page covers how to use the Serper Google Search API within LangChain. Serper is a low-cost Google Search API that can be used to add answer box, knowledge graph, and organic results data from Google Search. It is br...
/content/https://python.langchain.com/en/latest/ecosystem/google_serper.html
fbcb799e3586-1
self_ask_with_search.run("What is the hometown of the reigning men's U.S. Open champion?") Output# Entering new AgentExecutor chain... Yes. Follow up: Who is the reigning men's U.S. Open champion? Intermediate answer: Current champions Carlos Alcaraz, 2022 men's singles champion. Follow up: Where is Carlos Alcaraz fro...
/content/https://python.langchain.com/en/latest/ecosystem/google_serper.html
7030d5237eb3-0
.md .pdf Qdrant Contents Installation and Setup Wrappers VectorStore Qdrant# This page covers how to use the Qdrant ecosystem within LangChain. It is broken into two parts: installation and setup, and then references to specific Qdrant wrappers. Installation and Setup# Install the Python SDK with pip install qdrant-c...
/content/https://python.langchain.com/en/latest/ecosystem/qdrant.html