id
stringlengths
14
16
text
stringlengths
44
2.73k
source
stringlengths
49
114
1d550228d9cb-53
similarity_search_by_vector_with_relevance_scores(query: List[float], k: int) β†’ List[Tuple[langchain.schema.Document, float]][source]# similarity_search_with_relevance_scores(query: str, k: int = 4, **kwargs: Any) β†’ List[Tuple[langchain.schema.Document, float]][source]# Return docs and relevance scores in the range [0,...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1d550228d9cb-54
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. async classmethod afrom_documents(documents: List[langchain.schema.Document], embed...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1d550228d9cb-55
Return docs most similar to embedding vector. classmethod from_documents(documents: List[langchain.schema.Document], embedding: langchain.embeddings.base.Embeddings, **kwargs: Any) β†’ langchain.vectorstores.base.VST[source]# Return VectorStore initialized from documents and embeddings. abstract classmethod from_texts(te...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1d550228d9cb-56
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
1d550228d9cb-57
Example import weaviate from langchain.vectorstores import Weaviate client = weaviate.Client(url=os.environ["WEAVIATE_URL"], ...) weaviate = Weaviate(client, index_name, text_key) add_texts(texts: Iterable[str], metadatas: Optional[List[dict]] = None, **kwargs: Any) β†’ List[str][source]# Upload texts with metadata (prop...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1d550228d9cb-58
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 corresponding to maximum diversity and 1 to minimum diversity. Defaults to 0.5. Returns List of Documen...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1d550228d9cb-59
Look up similar documents by embedding vector in Weaviate. class langchain.vectorstores.Zilliz(embedding_function: Embeddings, collection_name: str = 'LangChainCollection', connection_args: Optional[dict[str, Any]] = None, consistency_level: str = 'Session', index_params: Optional[dict] = None, search_params: Optional[...
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
1d550228d9cb-60
that name if it exists. Defaults to False. Returns Zilliz Vector Store Return type Zilliz previous Document Loaders next Retrievers By Harrison Chase Β© Copyright 2023, Harrison Chase. Last updated on Apr 25, 2023.
https://python.langchain.com/en/latest/reference/modules/vectorstores.html
344d4fcd0c02-0
.rst .pdf Document Transformers Document Transformers# Transform documents pydantic model langchain.document_transformers.EmbeddingsRedundantFilter[source]# Filter that drops redundant documents by comparing their embeddings. field embeddings: langchain.embeddings.base.Embeddings [Required]# Embeddings to use for embed...
https://python.langchain.com/en/latest/reference/modules/document_transformers.html
a7ec43df6555-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
1cdbd44aab38-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...
https://python.langchain.com/en/latest/reference/modules/serpapi.html
1bfa6302a19e-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
90c140cc379b-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...
https://python.langchain.com/en/latest/reference/modules/document_compressors.html
90c140cc379b-1
Filter down documents. compress_documents(documents: Sequence[langchain.schema.Document], query: str) β†’ Sequence[langchain.schema.Document][source]# Filter documents based on similarity of their embeddings to the query. pydantic model langchain.retrievers.document_compressors.LLMChainExtractor[source]# field get_input:...
https://python.langchain.com/en/latest/reference/modules/document_compressors.html
90c140cc379b-2
The chain prompt is expected to have a BooleanOutputParser. async acompress_documents(documents: Sequence[langchain.schema.Document], query: str) β†’ Sequence[langchain.schema.Document][source]# Filter down documents. compress_documents(documents: Sequence[langchain.schema.Document], query: str) β†’ Sequence[langchain.sche...
https://python.langchain.com/en/latest/reference/modules/document_compressors.html
cb353a23b337-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
cb353a23b337-1
field retry_chain: langchain.chains.llm.LLMChain [Required]# 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']...
https://python.langchain.com/en/latest/reference/modules/output_parsers.html
cb353a23b337-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
cb353a23b337-3
field retry_chain: langchain.chains.llm.LLMChain [Required]# 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_pars...
https://python.langchain.com/en/latest/reference/modules/output_parsers.html
cb353a23b337-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
cb353a23b337-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
8e1552b28254-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
8e1552b28254-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>)[source]# Interface for splitting text into chunks. async atransform_documents(documents: Sequence[langchain.schema.D...
https://python.langchain.com/en/latest/reference/modules/text_splitter.html
8e1552b28254-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
830fb548d03c-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...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
830fb548d03c-1
Parameters texts – The list of texts to embed. Returns List of embeddings, one for each text. embed_query(text: str) β†’ List[float][source]# Call out to Aleph Alpha’s asymmetric, query embedding endpoint :param text: The text to embed. Returns Embeddings for the text. pydantic model langchain.embeddings.AlephAlphaSymmet...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
830fb548d03c-2
embed_documents(texts: List[str]) β†’ List[List[float]][source]# Call out to Cohere’s embedding endpoint. Parameters texts – The list of texts to embed. Returns List of embeddings, one for each text. embed_query(text: str) β†’ List[float][source]# Call out to Cohere’s embedding endpoint. Parameters text – The text to embed...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
830fb548d03c-3
embed_query(text: str) β†’ List[float][source]# Compute query embeddings using a HuggingFace transformer model. Parameters 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 hav...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
830fb548d03c-4
Wrapper around sentence_transformers embedding models. To use, you should have the sentence_transformers and InstructorEmbedding python package installed. Example from langchain.embeddings import HuggingFaceInstructEmbeddings model_name = "hkunlp/instructor-large" model_kwargs = {'device': 'cpu'} hf = HuggingFaceInstru...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
830fb548d03c-5
Example from langchain.embeddings import LlamaCppEmbeddings llama = LlamaCppEmbeddings(model_path="/path/to/model.bin") field f16_kv: bool = False# Use half-precision for key/value cache. field logits_all: bool = False# Return logits for all tokens, not just the last token. field n_batch: Optional[int] = 8# Number of t...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
830fb548d03c-6
environment variable OPENAI_API_KEY set with your API key or pass it as a named parameter to the constructor. Example from langchain.embeddings import OpenAIEmbeddings openai = OpenAIEmbeddings(openai_api_key="my-api-key") In order to use the library with Microsoft Azure endpoints, you need to set the OPENAI_API_TYPE, ...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
830fb548d03c-7
embed_query(text: str) β†’ List[float][source]# Call out to OpenAI’s embedding endpoint for embedding query text. 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 m...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
830fb548d03c-8
function. See `boto3`_. docs for more info. .. _boto3: <https://boto3.amazonaws.com/v1/documentation/api/latest/index.html> field endpoint_name: str = ''# The name of the endpoint from the deployed Sagemaker model. Must be unique within an AWS Region. field model_kwargs: Optional[Dict] = None# Key word arguments to pas...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
830fb548d03c-9
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline import runhouse as rh gpu = rh.cluster(name="rh-a10x", instance_type="A100:1") def get_pipeline(): model_id = "facebook/bart-large" tokenizer = AutoTokenizer.from_pretrained(model_id) model = AutoModelForCausalLM.from_pretrained(model_id...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
830fb548d03c-10
Returns List of embeddings, one for each text. embed_query(text: str) β†’ List[float][source]# Compute query embeddings using a HuggingFace transformer model. Parameters text – The text to embed. Returns Embeddings for the text. pydantic model langchain.embeddings.SelfHostedHuggingFaceEmbeddings[source]# Runs sentence_tr...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
830fb548d03c-11
Requirements to install on hardware to inference the model. pydantic model langchain.embeddings.SelfHostedHuggingFaceInstructEmbeddings[source]# Runs InstructorEmbedding embedding models on self-hosted remote hardware. Supported hardware includes auto-launched instances on AWS, GCP, Azure, and Lambda, as well as server...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
830fb548d03c-12
Compute query embeddings using a HuggingFace instruct model. Parameters text – The text to embed. Returns Embeddings for the text. pydantic model langchain.embeddings.TensorflowHubEmbeddings[source]# Wrapper around tensorflow_hub embedding models. To use, you should have the tensorflow_text python package installed. Ex...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
36dcd3af717a-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
36dcd3af717a-1
field callback_manager: langchain.callbacks.base.BaseCallbackManager [Optional]# field verbose: bool [Optional]# Whether to print out response text. pydantic model langchain.chat_models.ChatOpenAI[source]# Wrapper around OpenAI Chat large language models. To use, you should have the openai python package installed, and...
https://python.langchain.com/en/latest/reference/modules/chat_models.html
36dcd3af717a-2
get_num_tokens(text: str) β†’ int[source]# Calculate num tokens with tiktoken package. get_num_tokens_from_messages(messages: List[langchain.schema.BaseMessage]) β†’ int[source]# Calculate num tokens for gpt-3.5-turbo and gpt-4 with tiktoken package. Official documentation: openai/openai-cookbook main/examples/How_to_forma...
https://python.langchain.com/en/latest/reference/modules/chat_models.html
0cf8b0630207-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...
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
0cf8b0630207-1
Instantiate the toolkit from an OpenAPI Spec URL classmethod from_llm_and_spec(llm: langchain.llms.base.BaseLLM, spec: langchain.tools.openapi.utils.openapi_utils.OpenAPISpec, requests: Optional[langchain.requests.Requests] = None, verbose: bool = False, **kwargs: Any) β†’ langchain.agents.agent_toolkits.nla.toolkit.NLAT...
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
0cf8b0630207-2
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 [Required]# field powerbi: langchain.utilities.powerbi.PowerBIDataset [Required]# get_tools() β†’ List[la...
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
0cf8b0630207-3
field llm: langchain.llms.base.BaseLLM [Optional]# field vectorstore_info: 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.agent_toolkits.ZapierToolkit[source]# Zapier...
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
0cf8b0630207-4
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 ...
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
0cf8b0630207-5
you cannot use it.\nYou should only add one key at a time to the path. You cannot add multiple keys at once.\nIf you encounter a "KeyError", go back to the previous key, look at the available keys, and try again.\n\nIf the question does not seem to be related to the JSON, just return "I don\'t know" as the answer.\nAlw...
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
0cf8b0630207-6
str = 'Begin!"\n\nQuestion: {input}\nThought: I should look at the keys that exist in data to see what I have access to\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 ta...
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
0cf8b0630207-7
Construct a json agent from an LLM and tools.
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
0cf8b0630207-8
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...
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
0cf8b0630207-9
by checking which parameters are required. For parameters with a fixed set of values, please use the spec to look at which values are allowed.\n\nUse the exact parameter names as listed in the spec, do not make up any names or abbreviate the names of parameters.\nIf you get a not found error, ensure that you are using ...
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
0cf8b0630207-10
= None, max_iterations: Optional[int] = 15, max_execution_time: Optional[float] = None, early_stopping_method: str = 'force', verbose: bool = False, return_intermediate_steps: bool = False, **kwargs: Any) β†’ langchain.agents.agent.AgentExecutor[source]#
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
0cf8b0630207-11
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...
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
0cf8b0630207-12
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...
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
0cf8b0630207-13
Usually I should first ask which tables I have, then how each table is defined and then ask the question to query tool to create a query for me and then I should ask the query tool to execute it, finally create a nice sentence that answers the question. If you receive an error back that mentions that the query was wron...
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
0cf8b0630207-14
always think about what to do\nAction: the action to take, should be one of [{tool_names}]\nAction Input: the input to the action\nObservation: the result of the action\n... (this Thought/Action/Action Input/Observation can repeat N times)\nThought: I now know the final answer\nFinal Answer: the final answer to the ori...
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
0cf8b0630207-15
Construct a pbi agent from an LLM and tools.
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
0cf8b0630207-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...
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
0cf8b0630207-17
wide range of questions. Additionally, Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics. \n\nGiven an input question, create a syntactically correct DAX query to run, then look at the resul...
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
0cf8b0630207-18
to query tool to create a query for me and then I should ask the query tool to execute it, finally create a complete sentence that answers the question. If you receive an error back that mentions that the query was wrong try to phrase the question differently and get a new query from the question to query tool.\n', suf...
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
0cf8b0630207-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...
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
0cf8b0630207-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...
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
0cf8b0630207-21
a query, rewrite the query and try again.\n\nDO NOT make any DML statements (INSERT, UPDATE, DELETE, DROP etc.) to the database.\n\nIf the question does not seem related to the database, just return "I don\'t know" as the answer.\n', suffix: str = 'Begin!\n\nQuestion: {input}\nThought: I should look at the tables in th...
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
0cf8b0630207-22
early_stopping_method: str = 'force', verbose: bool = False, **kwargs: Any) β†’ langchain.agents.agent.AgentExecutor[source]#
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
0cf8b0630207-23
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...
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
0cf8b0630207-24
Utilities By Harrison Chase Β© Copyright 2023, Harrison Chase. Last updated on Apr 25, 2023.
https://python.langchain.com/en/latest/reference/modules/agent_toolkits.html
3ef26d49b528-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
3ef26d49b528-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
3ef26d49b528-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
3ef26d49b528-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
3ef26d49b528-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
3ef26d49b528-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
864c1cc0f6bd-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 ...
https://python.langchain.com/en/latest/reference/modules/experimental.html
864c1cc0f6bd-1
property output_keys: List[str]# Output keys this chain expects. prioritize_tasks(this_task_id: int, objective: str) β†’ List[Dict][source]# Prioritize tasks. class langchain.experimental.AutoGPT(ai_name: str, memory: langchain.vectorstores.base.VectorStoreRetriever, chain: langchain.chains.llm.LLMChain, output_parser: l...
https://python.langchain.com/en/latest/reference/modules/experimental.html
864c1cc0f6bd-2
React to a given observation. get_full_header(force_refresh: bool = False) β†’ str[source]# 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...
https://python.langchain.com/en/latest/reference/modules/experimental.html
864c1cc0f6bd-3
field traits: str = 'N/A'# 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[f...
https://python.langchain.com/en/latest/reference/modules/experimental.html
864c1cc0f6bd-4
Return key-value pairs given the text input to the chain. field memory_retriever: langchain.retrievers.time_weighted_retriever.TimeWeightedVectorStoreRetriever [Required]# The retriever to fetch related memories. property memory_variables: List[str]# Input keys this memory class will load dynamically. pause_to_reflect(...
https://python.langchain.com/en/latest/reference/modules/experimental.html
50d30b3886c4-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
50d30b3886c4-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
50d30b3886c4-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
50d30b3886c4-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
50d30b3886c4-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
50d30b3886c4-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
50d30b3886c4-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.WeaviateHybridSearchRetriev...
https://python.langchain.com/en/latest/reference/modules/retrievers.html
f088712952a0-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...
https://python.langchain.com/en/latest/ecosystem/llamacpp.html
5fe84fdb4788-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 ...
https://python.langchain.com/en/latest/ecosystem/pinecone.html
8c473ad83dc0-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...
https://python.langchain.com/en/latest/ecosystem/huggingface.html
8c473ad83dc0-1
from langchain.embeddings import HuggingFaceHubEmbeddings For a more detailed walkthrough of this, see this notebook Tokenizer# There are several places you can use tokenizers available through the transformers package. By default, it is used to count tokens for all LLMs. You can also use it to count tokens when splitt...
https://python.langchain.com/en/latest/ecosystem/huggingface.html
c75e431f90d9-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...
https://python.langchain.com/en/latest/ecosystem/comet_tracking.html
c75e431f90d9-1
) manager = CallbackManager([StdOutCallbackHandler(), comet_callback]) llm = OpenAI(temperature=0.9, callback_manager=manager, verbose=True) llm_result = llm.generate(["Tell me a joke", "Tell me a poem", "Tell me a fact"] * 3) print("LLM result", llm_result) comet_callback.flush_tracker(llm, finish=True) Scenario 2: Us...
https://python.langchain.com/en/latest/ecosystem/comet_tracking.html
c75e431f90d9-2
from langchain.callbacks import CometCallbackHandler, StdOutCallbackHandler from langchain.callbacks.base import CallbackManager from langchain.llms import OpenAI comet_callback = CometCallbackHandler( project_name="comet-example-langchain", complexity_metrics=True, stream_logs=True, tags=["agent"], ) m...
https://python.langchain.com/en/latest/ecosystem/comet_tracking.html
c75e431f90d9-3
def compute_metric(self, generation, prompt_idx, gen_idx): prediction = generation.text results = self.scorer.score(target=self.reference, prediction=prediction) return { "rougeLsum_score": results["rougeLsum"].fmeasure, "reference": self.reference, } reference = ...
https://python.langchain.com/en/latest/ecosystem/comet_tracking.html
c75e431f90d9-4
an 81-storey building, and the tallest structure in Paris. Its base is square, 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, ...
https://python.langchain.com/en/latest/ecosystem/comet_tracking.html
45faa7c3229d-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...
https://python.langchain.com/en/latest/ecosystem/zilliz.html
53c4565636da-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...
https://python.langchain.com/en/latest/ecosystem/google_serper.html
53c4565636da-1
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 from? Intermediate answer: El Palmar, Spain So the final answer is: El Palmar, Spain > Finished chain. 'El Palmar, Spain' For a more detail...
https://python.langchain.com/en/latest/ecosystem/google_serper.html
4cde1a477f2e-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...
https://python.langchain.com/en/latest/ecosystem/qdrant.html
fa26aab6488a-0
.md .pdf Prediction Guard Contents Installation and Setup LLM Wrapper Example usage Prediction Guard# This page covers how to use the Prediction Guard ecosystem within LangChain. It is broken into two parts: installation and setup, and then references to specific Prediction Guard wrappers. Installation and Setup# Ins...
https://python.langchain.com/en/latest/ecosystem/predictionguard.html
fa26aab6488a-1
llm_chain.predict(question=question) previous Pinecone next PromptLayer Contents Installation and Setup LLM Wrapper Example usage By Harrison Chase Β© Copyright 2023, Harrison Chase. Last updated on Apr 25, 2023.
https://python.langchain.com/en/latest/ecosystem/predictionguard.html
b01aa6548ae2-0
.md .pdf Writer Contents Installation and Setup Wrappers LLM Writer# This page covers how to use the Writer ecosystem within LangChain. It is broken into two parts: installation and setup, and then references to specific Writer wrappers. Installation and Setup# Get an Writer api key and set it as an environment varia...
https://python.langchain.com/en/latest/ecosystem/writer.html
488b33dc9c33-0
.md .pdf Chroma Contents Installation and Setup Wrappers VectorStore Chroma# This page covers how to use the Chroma ecosystem within LangChain. It is broken into two parts: installation and setup, and then references to specific Chroma wrappers. Installation and Setup# Install the Python package with pip install chro...
https://python.langchain.com/en/latest/ecosystem/chroma.html