id
stringlengths
14
16
text
stringlengths
29
2.73k
source
stringlengths
49
117
2cbd4a2024d3-0
Source code for langchain.agents.conversational.base """An agent designed to hold a conversation in addition to using tools.""" from __future__ import annotations from typing import Any, List, Optional, Sequence from pydantic import Field from langchain.agents.agent import Agent, AgentOutputParser from langchain.agents...
https://python.langchain.com/en/latest/_modules/langchain/agents/conversational/base.html
2cbd4a2024d3-1
[docs] @classmethod def create_prompt( cls, tools: Sequence[BaseTool], prefix: str = PREFIX, suffix: str = SUFFIX, format_instructions: str = FORMAT_INSTRUCTIONS, ai_prefix: str = "AI", human_prefix: str = "Human", input_variables: Optional[List[str...
https://python.langchain.com/en/latest/_modules/langchain/agents/conversational/base.html
2cbd4a2024d3-2
validate_tools_single_input(cls.__name__, tools) [docs] @classmethod def from_llm_and_tools( cls, llm: BaseLanguageModel, tools: Sequence[BaseTool], callback_manager: Optional[BaseCallbackManager] = None, output_parser: Optional[AgentOutputParser] = None, prefix: s...
https://python.langchain.com/en/latest/_modules/langchain/agents/conversational/base.html
f2ce45d778cf-0
.md .pdf Tutorials Contents DeepLearning.AI course Handbook Tutorials Tutorials# ⛓ icon marks a new addition [last update 2023-05-15] DeepLearning.AI course# ⛓LangChain for LLM Application Development by Harrison Chase presented by Andrew Ng Handbook# LangChain AI Handbook By James Briggs and Francisco Ingham Tutoria...
https://python.langchain.com/en/latest/getting_started/tutorials.html
f2ce45d778cf-1
OpenAI + Wolfram Alpha Ask Questions On Your Custom (or Private) Files Connect Google Drive Files To OpenAI YouTube Transcripts + OpenAI Question A 300 Page Book (w/ OpenAI + Pinecone) Workaround OpenAI's Token Limit With Chain Types Build Your Own OpenAI + LangChain Web App in 23 Minutes Working With The New ChatGPT A...
https://python.langchain.com/en/latest/getting_started/tutorials.html
f2ce45d778cf-2
Improve your BabyAGI with LangChain ⛓ Master PDF Chat with LangChain - Your essential guide to queries on documents ⛓ Using LangChain with DuckDuckGO Wikipedia & PythonREPL Tools ⛓ Building Custom Tools and Agents with LangChain (gpt-3.5-turbo) ⛓ LangChain Retrieval QA Over Multiple Files with ChromaDB ⛓ LangChain Retr...
https://python.langchain.com/en/latest/getting_started/tutorials.html
f2ce45d778cf-3
LangChain Chains: Use ChatGPT to Build Conversational Agents, Summaries and Q&A on Text With LLMs Analyze Custom CSV Data with GPT-4 using Langchain ⛓ Build ChatGPT Chatbots with LangChain Memory: Understanding and Implementing Memory in Conversations ⛓ icon marks a new addition [last update 2023-05-15] previous Concep...
https://python.langchain.com/en/latest/getting_started/tutorials.html
6817701f1177-0
.md .pdf Concepts Contents Chain of Thought Action Plan Generation ReAct Self-ask Prompt Chaining Memetic Proxy Self Consistency Inception MemPrompt Concepts# These are concepts and terminology commonly used when developing LLM applications. It contains reference to external papers or sources where the concept was fi...
https://python.langchain.com/en/latest/getting_started/concepts.html
6817701f1177-1
to respond in a certain way framing the discussion in a context that the model knows of and that will result in that type of response. For example, as a conversation between a student and a teacher. Paper Self Consistency# Self Consistency is a decoding strategy that samples a diverse set of reasoning paths and then se...
https://python.langchain.com/en/latest/getting_started/concepts.html
6139d3f8e5ca-0
.md .pdf Quickstart Guide Contents Installation Environment Setup Building a Language Model Application: LLMs LLMs: Get predictions from a language model Prompt Templates: Manage prompts for LLMs Chains: Combine LLMs and prompts in multi-step workflows Agents: Dynamically Call Chains Based on User Input Memory: Add S...
https://python.langchain.com/en/latest/getting_started/getting_started.html
6139d3f8e5ca-1
LangChain provides many modules that can be used to build language model applications. Modules can be combined to create more complex applications, or be used individually for simple applications. LLMs: Get predictions from a language model# The most basic building block of LangChain is calling an LLM on some input. Le...
https://python.langchain.com/en/latest/getting_started/getting_started.html
6139d3f8e5ca-2
This is easy to do with LangChain! First lets define the prompt template: from langchain.prompts import PromptTemplate prompt = PromptTemplate( input_variables=["product"], template="What is a good name for a company that makes {product}?", ) Let’s now see how this works! We can call the .format method to forma...
https://python.langchain.com/en/latest/getting_started/getting_started.html
6139d3f8e5ca-3
Now we can run that chain only specifying the product! chain.run("colorful socks") # -> '\n\nSocktastic!' There we go! There’s the first chain - an LLM Chain. This is one of the simpler types of chains, but understanding how it works will set you up well for working with more complex chains. For more details, check out...
https://python.langchain.com/en/latest/getting_started/getting_started.html
6139d3f8e5ca-4
pip install google-search-results And set the appropriate environment variables. import os os.environ["SERPAPI_API_KEY"] = "..." Now we can get started! from langchain.agents import load_tools from langchain.agents import initialize_agent from langchain.agents import AgentType from langchain.llms import OpenAI # First,...
https://python.langchain.com/en/latest/getting_started/getting_started.html
6139d3f8e5ca-5
Thought: I now know the final answer Final Answer: The high temperature in SF yesterday in Fahrenheit raised to the .023 power is 1.0974509573251117. > Finished chain. Memory: Add State to Chains and Agents# So far, all the chains and agents we’ve gone through have been stateless. But often, you may want a chain or age...
https://python.langchain.com/en/latest/getting_started/getting_started.html
6139d3f8e5ca-6
Current conversation: Human: Hi there! AI: > Finished chain. ' Hello! How are you today?' output = conversation.predict(input="I'm doing well! Just having a conversation with an AI.") print(output) > Entering new chain... Prompt after formatting: The following is a friendly conversation between a human and an AI. The A...
https://python.langchain.com/en/latest/getting_started/getting_started.html
6139d3f8e5ca-7
AIMessage, HumanMessage, SystemMessage ) chat = ChatOpenAI(temperature=0) You can get completions by passing in a single message. chat([HumanMessage(content="Translate this sentence from English to French. I love programming.")]) # -> AIMessage(content="J'aime programmer.", additional_kwargs={}) You can also pa...
https://python.langchain.com/en/latest/getting_started/getting_started.html
6139d3f8e5ca-8
You can recover things like token usage from this LLMResult: result.llm_output['token_usage'] # -> {'prompt_tokens': 57, 'completion_tokens': 20, 'total_tokens': 77} Chat Prompt Templates# Similar to LLMs, you can make use of templating by using a MessagePromptTemplate. You can build a ChatPromptTemplate from one or mo...
https://python.langchain.com/en/latest/getting_started/getting_started.html
6139d3f8e5ca-9
from langchain import LLMChain from langchain.prompts.chat import ( ChatPromptTemplate, SystemMessagePromptTemplate, HumanMessagePromptTemplate, ) chat = ChatOpenAI(temperature=0) template = "You are a helpful assistant that translates {input_language} to {output_language}." system_message_prompt = SystemMe...
https://python.langchain.com/en/latest/getting_started/getting_started.html
6139d3f8e5ca-10
agent = initialize_agent(tools, chat, agent=AgentType.CHAT_ZERO_SHOT_REACT_DESCRIPTION, verbose=True) # Now let's test it out! agent.run("Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?") > Entering new AgentExecutor chain... Thought: I need to use a search engine to find Olivia Wilde...
https://python.langchain.com/en/latest/getting_started/getting_started.html
6139d3f8e5ca-11
'2.169459462491557' Memory: Add State to Chains and Agents# You can use Memory with chains and agents initialized with chat models. The main difference between this and Memory for LLMs is that rather than trying to condense all previous messages into a string, we can keep them as their own unique memory object. from la...
https://python.langchain.com/en/latest/getting_started/getting_started.html
6139d3f8e5ca-12
conversation.predict(input="Tell me about yourself.") # -> "Sure! I am an AI language model created by OpenAI. I was trained on a large dataset of text from the internet, which allows me to understand and generate human-like language. I can answer questions, provide information, and even have conversations like this on...
https://python.langchain.com/en/latest/getting_started/getting_started.html
51620c98e82c-0
.md .pdf Locally Hosted Setup Contents Installation Environment Setup Locally Hosted Setup# This page contains instructions for installing and then setting up the environment to use the locally hosted version of tracing. Installation# Ensure you have Docker installed (see Get Docker) and that it’s running. Install th...
https://python.langchain.com/en/latest/tracing/local_installation.html
51620c98e82c-1
By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/tracing/local_installation.html
2dcf8e6918fc-0
.ipynb .pdf Tracing Walkthrough Contents [Beta] Tracing V2 Tracing Walkthrough# There are two recommended ways to trace your LangChains: Setting the LANGCHAIN_TRACING environment variable to “true”. Using a context manager with tracing_enabled() to trace a particular block of code. Note if the environment variable is...
https://python.langchain.com/en/latest/tracing/agent_with_tracing.html
2dcf8e6918fc-1
> Entering new AgentExecutor chain... I need to use a calculator to solve this. Action: Calculator Action Input: 2^.123243 Observation: Answer: 1.0891804557407723 Thought: I now know the final answer. Final Answer: 1.0891804557407723 > Finished chain. '1.0891804557407723' # Agent run with tracing using a chat model ag...
https://python.langchain.com/en/latest/tracing/agent_with_tracing.html
2dcf8e6918fc-2
I need to use a calculator to solve this. Action: Calculator Action Input: 5 ^ .123243 Observation: Answer: 1.2193914912400514 Thought:I now know the answer to the question. Final Answer: 1.2193914912400514 > Finished chain. # Now, we unset the environment variable and use a context manager. if "LANGCHAIN_TRACING" in ...
https://python.langchain.com/en/latest/tracing/agent_with_tracing.html
2dcf8e6918fc-3
del os.environ["LANGCHAIN_TRACING"] questions = [f"What is {i} raised to .123 power?" for i in range(1,4)] # start a background task task = asyncio.create_task(agent.arun(questions[0])) # this should not be traced with tracing_enabled() as session: assert session tasks = [agent.arun(q) for q in questions[...
https://python.langchain.com/en/latest/tracing/agent_with_tracing.html
2dcf8e6918fc-4
pip install --upgrade langchain langchain plus start Option 2 (Hosted): After making an account an grabbing a LangChainPlus API Key, set the LANGCHAIN_ENDPOINT and LANGCHAIN_API_KEY environment variables import os os.environ["LANGCHAIN_TRACING_V2"] = "true" # os.environ["LANGCHAIN_ENDPOINT"] = "https://api.langchain.pl...
https://python.langchain.com/en/latest/tracing/agent_with_tracing.html
2dcf8e6918fc-5
By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/tracing/agent_with_tracing.html
7f039621dd1e-0
.md .pdf Cloud Hosted Setup Contents Installation Environment Setup Cloud Hosted Setup# We offer a hosted version of tracing at langchainplus.vercel.app. You can use this to view traces from your run without having to run the server locally. Note: we are currently only offering this to a limited number of users. The ...
https://python.langchain.com/en/latest/tracing/hosted_installation.html
7f039621dd1e-1
os.environ["LANGCHAIN_API_KEY"] = "my_api_key" # Don't commit this to your repo! Better to set it in your terminal. Contents Installation Environment Setup By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/tracing/hosted_installation.html
90d5b0731ef8-0
.rst .pdf Indexes Indexes# Indexes refer to ways to structure documents so that LLMs can best interact with them. LangChain has a number of modules that help you load, structure, store, and retrieve documents. Docstore Text Splitter Document Loaders Vector Stores Retrievers Document Compressors Document Transformers pr...
https://python.langchain.com/en/latest/reference/indexes.html
65ae70732f2f-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
ae09a6326614-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 Jun 02, 2023.
https://python.langchain.com/en/latest/reference/models.html
c9d91913631d-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 Jun 02, 2023.
https://python.langchain.com/en/latest/reference/agents.html
68c499df93b8-0
.rst .pdf Prompts Prompts# The reference guides here all relate to objects for working with Prompts. PromptTemplates Example Selector Output Parsers previous How to serialize prompts next PromptTemplates By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/reference/prompts.html
3db2f09db17c-0
.rst .pdf Tools Tools# Core toolkit implementations. pydantic model langchain.tools.AIPluginTool[source]# field api_spec: str [Required]# field args_schema: Type[AIPluginToolSchema] = <class 'langchain.tools.plugin.AIPluginToolSchema'># Pydantic model class to validate and parse the tool’s input arguments. field plugin...
https://python.langchain.com/en/latest/reference/modules/tools.html
3db2f09db17c-1
to_typescript() → str[source]# Get typescript string representation of the operation. static ts_type_from_python(type_: Union[str, Type, tuple, None, enum.Enum]) → str[source]# property body_params: List[str]# property path_params: List[str]# property query_params: List[str]# pydantic model langchain.tools.AzureCogsFor...
https://python.langchain.com/en/latest/reference/modules/tools.html
3db2f09db17c-2
Interface LangChain tools must implement. field args_schema: Optional[Type[pydantic.main.BaseModel]] = None# Pydantic model class to validate and parse the tool’s input arguments. field callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None# Deprecated. Please use callbacks instead. field callb...
https://python.langchain.com/en/latest/reference/modules/tools.html
3db2f09db17c-3
Run the tool asynchronously. run(tool_input: Union[str, Dict], verbose: Optional[bool] = None, start_color: Optional[str] = 'green', color: Optional[str] = 'green', callbacks: Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]] = None, **kwargs: Any) → Any[s...
https://python.langchain.com/en/latest/reference/modules/tools.html
3db2f09db17c-4
field name: str = 'click_element'# The unique name of the tool that clearly communicates its purpose. field playwright_strict: bool = False# Whether to employ Playwright’s strict mode when clicking on elements. field playwright_timeout: float = 1000# Timeout (in ms) for Playwright to wait for element to be ready. field...
https://python.langchain.com/en/latest/reference/modules/tools.html
3db2f09db17c-5
Pydantic model class to validate and parse the tool’s input arguments. field description: str = 'Delete a file'# Used to tell the model how/when/why to use the tool. You can provide few-shot examples as a part of the description. field name: str = 'file_delete'# The unique name of the tool that clearly communicates its...
https://python.langchain.com/en/latest/reference/modules/tools.html
3db2f09db17c-6
pydantic model langchain.tools.ExtractTextTool[source]# field args_schema: Type[BaseModel] = <class 'pydantic.main.BaseModel'># Pydantic model class to validate and parse the tool’s input arguments. field description: str = 'Extract all the text on the current webpage'# Used to tell the model how/when/why to use the to...
https://python.langchain.com/en/latest/reference/modules/tools.html
3db2f09db17c-7
The unique name of the tool that clearly communicates its purpose. pydantic model langchain.tools.GmailCreateDraft[source]# field args_schema: Type[langchain.tools.gmail.create_draft.CreateDraftSchema] = <class 'langchain.tools.gmail.create_draft.CreateDraftSchema'># Pydantic model class to validate and parse the tool’...
https://python.langchain.com/en/latest/reference/modules/tools.html
3db2f09db17c-8
Pydantic model class to validate and parse the tool’s input arguments. field description: str = 'Use this tool to search for email messages. The input must be a valid Gmail query. The output is a JSON list of messages.'# Used to tell the model how/when/why to use the tool. You can provide few-shot examples as a part of...
https://python.langchain.com/en/latest/reference/modules/tools.html
3db2f09db17c-9
field api_wrapper: langchain.utilities.google_places_api.GooglePlacesAPIWrapper [Optional]# pydantic model langchain.tools.GoogleSearchResults[source]# Tool that has capability to query the Google Search API and get back json. field api_wrapper: langchain.utilities.google_search.GoogleSearchAPIWrapper [Required]# field...
https://python.langchain.com/en/latest/reference/modules/tools.html
3db2f09db17c-10
pydantic model langchain.tools.ListDirectoryTool[source]# field args_schema: Type[pydantic.main.BaseModel] = <class 'langchain.tools.file_management.list_dir.DirectoryListingInput'># Pydantic model class to validate and parse the tool’s input arguments. field description: str = 'List files and directories in a specifie...
https://python.langchain.com/en/latest/reference/modules/tools.html
3db2f09db17c-11
Navigate back to the previous page in the browser history. field args_schema: Type[BaseModel] = <class 'pydantic.main.BaseModel'># Pydantic model class to validate and parse the tool’s input arguments. field description: str = 'Navigate back to the previous page in the browser history'# Used to tell the model how/when/...
https://python.langchain.com/en/latest/reference/modules/tools.html
3db2f09db17c-12
Get an OpenAPI spec from a text. classmethod from_url(url: str) → langchain.tools.openapi.utils.openapi_utils.OpenAPISpec[source]# Get an OpenAPI spec from a URL. static get_cleaned_operation_id(operation: openapi_schema_pydantic.v3.v3_1_0.operation.Operation, path: str, method: str) → str[source]# Get a cleaned operat...
https://python.langchain.com/en/latest/reference/modules/tools.html
3db2f09db17c-13
pydantic model langchain.tools.OpenWeatherMapQueryRun[source]# Tool that adds the capability to query using the OpenWeatherMap API. field api_wrapper: langchain.utilities.openweathermap.OpenWeatherMapAPIWrapper [Optional]# pydantic model langchain.tools.QueryPowerBITool[source]# Tool for querying a Power BI Dataset. Va...
https://python.langchain.com/en/latest/reference/modules/tools.html
3db2f09db17c-14
field template: Optional[str] = '\nAnswer the question below with a DAX query that can be sent to Power BI. DAX queries have a simple syntax comprised of just one required keyword, EVALUATE, and several optional keywords: ORDER BY, START AT, DEFINE, MEASURE, VAR, TABLE, and COLUMN. Each keyword defines a statement used...
https://python.langchain.com/en/latest/reference/modules/tools.html
3db2f09db17c-15
ORDER BY <expression> ASC or DESC START AT <value> or <parameter> - The optional START AT keyword is used inside an ORDER BY clause. It defines the value at which the query results begin.\nDEFINE MEASURE | VAR; EVALUATE <table> - The optional DEFINE keyword introduces one or more calculated entity definitions that exis...
https://python.langchain.com/en/latest/reference/modules/tools.html
3db2f09db17c-16
you nest the DISTINCT function within a formula, to get a list of distinct values that can be passed to another function and then counted, summed, or used for other operations.\nDISTINCT(<table>) - Returns a table by removing duplicate rows from another table or expression.\n\nAggregation functions, names with a A in i...
https://python.langchain.com/en/latest/reference/modules/tools.html
3db2f09db17c-17
date2, <interval>) - Returns the difference between two date values, in the specified interval, that can be SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, QUARTER, YEAR.\nDATEVALUE(<date_text>) - Returns a date value that represents the specified date.\nYEAR(<date>), QUARTER(<date>), MONTH(<date>), DAY(<date>), HOUR(<date>), ...
https://python.langchain.com/en/latest/reference/modules/tools.html
3db2f09db17c-18
pydantic model langchain.tools.ReadFileTool[source]# field args_schema: Type[pydantic.main.BaseModel] = <class 'langchain.tools.file_management.read.ReadFileInput'># Pydantic model class to validate and parse the tool’s input arguments. field description: str = 'Read file from disk'# Used to tell the model how/when/why...
https://python.langchain.com/en/latest/reference/modules/tools.html
3db2f09db17c-19
The input arguments’ schema. The tool schema. field coroutine: Optional[Callable[[...], Awaitable[Any]]] = None# The asynchronous version of the function. field description: str = ''# Used to tell the model how/when/why to use the tool. You can provide few-shot examples as a part of the description. field func: Callabl...
https://python.langchain.com/en/latest/reference/modules/tools.html
3db2f09db17c-20
The function to run when the tool is called. field handle_tool_error: Optional[Union[bool, str, Callable[[langchain.tools.base.ToolException], str]]] = False# Handle the content of the ToolException thrown. field name: str [Required]# The unique name of the tool that clearly communicates its purpose. field return_direc...
https://python.langchain.com/en/latest/reference/modules/tools.html
3db2f09db17c-21
pydantic model langchain.tools.WriteFileTool[source]# field args_schema: Type[pydantic.main.BaseModel] = <class 'langchain.tools.file_management.write.WriteFileInput'># Pydantic model class to validate and parse the tool’s input arguments. field description: str = 'Write file to disk'# Used to tell the model how/when/w...
https://python.langchain.com/en/latest/reference/modules/tools.html
3db2f09db17c-22
your exposed actions here: https://nla.zapier.com/demo/start/ The return JSON is guaranteed to be less than ~500 words (350 tokens) making it safe to inject into the prompt of another LLM call. Parameters action_id – a specific action ID (from list actions) of the action to execute (the set api_key must be associated w...
https://python.langchain.com/en/latest/reference/modules/tools.html
3db2f09db17c-23
field base_prompt: str = 'A wrapper around Zapier NLA actions. The input to this tool is a natural language instruction, for example "get the latest email from my bank" or "send a slack message to the #general channel". Each tool will have params associated with it that are specified as a list. You MUST take into accou...
https://python.langchain.com/en/latest/reference/modules/tools.html
3db2f09db17c-24
infer_schema – Whether to infer the schema of the arguments from the function’s signature. This also makes the resultant tool accept a dictionary input to its run() function. Requires: Function must be of type (str) -> str Function must have a docstring Examples @tool def search_api(query: str) -> str: # Searches t...
https://python.langchain.com/en/latest/reference/modules/tools.html
f9707e242160-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
f9707e242160-1
embed_documents(texts: List[str]) → List[List[float]][source]# Call out to Aleph Alpha’s asymmetric Document 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 Aleph Alpha’s asymmetric, query embedding endpoin...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
f9707e242160-2
If a specific credential profile should be used, you must pass the name of the profile from the ~/.aws/credentials file that is to be used. Make sure the credentials / roles used have the required policies to access the Bedrock service. field credentials_profile_name: Optional[str] = None# The name of the profile in th...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
f9707e242160-3
Parameters text – The text to embed. 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...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
f9707e242160-4
- https://www.elastic.co/guide/en/elasticsearch/reference/current/infer-trained-model.html - https://www.elastic.co/guide/en/machine-learning/current/ml-nlp-deploy-models.html embed_documents(texts: List[str]) → List[List[float]][source]# Generate embeddings for a list of documents. Parameters texts (List[str]) – A lis...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
f9707e242160-5
input_field = "your_input_field" # Credentials can be passed in two ways. Either set the env vars # ES_CLOUD_ID, ES_USER, ES_PASSWORD and they will be automatically # pulled in, or pass them in directly as kwargs. embeddings = ElasticsearchEmbeddings.from_credentials( model_id, input_field=input_field, # es...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
f9707e242160-6
input_field = "your_input_field" # Create Elasticsearch connection es_connection = Elasticsearch( hosts=["localhost:9200"], http_auth=("user", "password") ) # Instantiate ElasticsearchEmbeddings using the existing connection embeddings = ElasticsearchEmbeddings.from_es_connection( model_id, es_connection, ...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
f9707e242160-7
field model_name: str = 'sentence-transformers/all-mpnet-base-v2'# Model name to use. embed_documents(texts: List[str]) → List[List[float]][source]# Compute doc embeddings using a HuggingFace transformer model. Parameters texts – The list of texts to embed. Returns List of embeddings, one for each text. embed_query(tex...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
f9707e242160-8
Returns List of embeddings, one for each text. embed_query(text: str) → List[float][source]# Call out to HuggingFaceHub’s embedding endpoint for embedding query text. Parameters text – The text to embed. Returns Embeddings for the text. pydantic model langchain.embeddings.HuggingFaceInstructEmbeddings[source]# Wrapper ...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
f9707e242160-9
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.LlamaCppEmbeddings[source]# Wrapper around llama.cpp embeddi...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
f9707e242160-10
field vocab_only: bool = False# Only load the vocabulary, no weights. embed_documents(texts: List[str]) → List[List[float]][source]# Embed a list of documents using the Llama model. Parameters texts – The list of texts to embed. Returns List of embeddings, one for each text. embed_query(text: str) → List[float][source]...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
f9707e242160-11
Embed documents using a MiniMax 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]# Embed a query using a MiniMax embedding endpoint. Parameters text – The text to embed. Returns Embeddings for the text. pydantic...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
f9707e242160-12
) mosaic_llm = MosaicMLInstructorEmbeddings( endpoint_url=endpoint_url, mosaicml_api_token="my-api-key" ) field embed_instruction: str = 'Represent the document for retrieval: '# Instruction used to embed documents. field endpoint_url: str = 'https://models.hosted-on.mosaicml.hosting/instructor-large/v1/predict...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
f9707e242160-13
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" os.environ["OPENAI_API_VERSI...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
f9707e242160-14
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 must supply the endpoint name from your deploye...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
f9707e242160-15
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 pass to the model. field region_name: str = ''# The aws region where the Sagemaker model is deployed, eg. us-west-2. embed_docu...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
f9707e242160-16
def get_pipeline(): model_id = "facebook/bart-large" tokenizer = AutoTokenizer.from_pretrained(model_id) model = AutoModelForCausalLM.from_pretrained(model_id) return pipeline("feature-extraction", model=model, tokenizer=tokenizer) embeddings = SelfHostedEmbeddings( model_load_fn=get_pipeline, h...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
f9707e242160-17
Parameters 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 se...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
f9707e242160-18
Runs InstructorEmbedding 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 credentials (such as on-prem, or another cloud like Paperspace, Coreweave, etc.). To use, you should have the r...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
f9707e242160-19
Returns Embeddings for the text. langchain.embeddings.SentenceTransformerEmbeddings# alias of langchain.embeddings.huggingface.HuggingFaceEmbeddings pydantic model langchain.embeddings.TensorflowHubEmbeddings[source]# Wrapper around tensorflow_hub embedding models. To use, you should have the tensorflow_text python pac...
https://python.langchain.com/en/latest/reference/modules/embeddings.html
cefa9e8e82a4-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
13345dd3c47d-0
.rst .pdf Retrievers Retrievers# pydantic model langchain.retrievers.ArxivRetriever[source]# It is effectively a wrapper for ArxivAPIWrapper. It wraps load() to get_relevant_documents(). It uses all ArxivAPIWrapper arguments without any change. async aget_relevant_documents(query: str) → List[langchain.schema.Document]...
https://python.langchain.com/en/latest/reference/modules/retrievers.html
13345dd3c47d-1
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.ChatGPTPluginRetriever[source]# field aiosession: Optional[aiohttp.client.Clie...
https://python.langchain.com/en/latest/reference/modules/retrievers.html
13345dd3c47d-2
Get documents relevant for a query. 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[lang...
https://python.langchain.com/en/latest/reference/modules/retrievers.html
13345dd3c47d-3
Locate the “elastic” user and click “Edit” 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 t...
https://python.langchain.com/en/latest/reference/modules/retrievers.html
13345dd3c47d-4
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.knn.KNNRetriever[source]# get_relevant_documents(query: str) → List[langchain.schema.Document][sour...
https://python.langchain.com/en/latest/reference/modules/retrievers.html
13345dd3c47d-5
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 List of relevant documents pydantic model langcha...
https://python.langchain.com/en/latest/reference/modules/retrievers.html
13345dd3c47d-6
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...
https://python.langchain.com/en/latest/reference/modules/retrievers.html
13345dd3c47d-7
Parameters query – string to find relevant documents for Returns List of relevant documents classmethod from_llm(llm: langchain.base_language.BaseLanguageModel, vectorstore: langchain.vectorstores.base.VectorStore, document_contents: str, metadata_field_info: List[langchain.chains.query_constructor.schema.AttributeInfo...
https://python.langchain.com/en/latest/reference/modules/retrievers.html
13345dd3c47d-8
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 embedding simila...
https://python.langchain.com/en/latest/reference/modules/retrievers.html
13345dd3c47d-9
get_relevant_documents(query: str) → List[langchain.schema.Document][source]# Return documents that are relevant to the query. get_salient_docs(query: str) → Dict[int, Tuple[langchain.schema.Document, float]][source]# Return documents that are salient to the query. class langchain.retrievers.VespaRetriever(app: Vespa, ...
https://python.langchain.com/en/latest/reference/modules/retrievers.html
13345dd3c47d-10
yql (Optional[str]) – Full YQL query to be used. Should not be specified if _filter or sources are specified. Defaults to None. kwargs (Any) – Keyword arguments added to query body. get_relevant_documents(query: str) → List[langchain.schema.Document][source]# Get documents relevant for a query. Parameters query – strin...
https://python.langchain.com/en/latest/reference/modules/retrievers.html
13345dd3c47d-11
It wraps load() to get_relevant_documents(). It uses all WikipediaAPIWrapper arguments without any change. async aget_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 ...
https://python.langchain.com/en/latest/reference/modules/retrievers.html
13345dd3c47d-12
By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/reference/modules/retrievers.html
5641e0c3fcb0-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
5641e0c3fcb0-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
5641e0c3fcb0-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
5641e0c3fcb0-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