id
stringlengths
14
15
text
stringlengths
101
5.26k
source
stringlengths
57
120
cb1ecfa06586-4
If the fact is false, explain why. > Finished chain. > Entering new LLMChain chain... Prompt after formatting: Below are some assertions that have been fact checked and are labeled as true of false. If the answer is false, a suggestion is given for a correction. Checked Assertions: """ - The Greenland Sea is an outlyi...
https://langchain.readthedocs.io/en/latest/modules/chains/examples/llm_summarization_checker.html
cb1ecfa06586-5
> Entering new SequentialChain chain... > Entering new LLMChain chain... Prompt after formatting: Given some text, extract a list of facts from the text. Format your output as a bulleted list. Text: """ The Greenland Sea is an outlying portion of the Arctic Ocean located between Iceland, Norway, the Svalbard archipelag...
https://langchain.readthedocs.io/en/latest/modules/chains/examples/llm_summarization_checker.html
cb1ecfa06586-6
""" Result: False === Checked Assertions:""" - The Greenland Sea is an outlying portion of the Arctic Ocean located between Iceland, Norway, the Svalbard archipelago and Greenland. True - It has an area of 465,000 square miles. True - It is an arm of the Arctic Ocean. True - It is covered almost entirely by water, some...
https://langchain.readthedocs.io/en/latest/modules/chains/examples/llm_summarization_checker.html
cb1ecfa06586-7
""" Original Summary: """ The Greenland Sea is an outlying portion of the Arctic Ocean located between Iceland, Norway, the Svalbard archipelago and Greenland. It has an area of 465,000 square miles and is an arm of the Arctic Ocean. It is covered almost entirely by water, some of which is frozen in the form of glacier...
https://langchain.readthedocs.io/en/latest/modules/chains/examples/llm_summarization_checker.html
cb1ecfa06586-8
- Birds can lay eggs - Birds are mammals """ For each fact, determine whether it is true or false about the subject. If you are unable to determine whether the fact is true or false, output "Undetermined". If the fact is false, explain why. > Finished chain. > Entering new LLMChain chain... Prompt after formatting: Bel...
https://langchain.readthedocs.io/en/latest/modules/chains/examples/llm_summarization_checker.html
cb1ecfa06586-9
Below are some assertions that have been fact checked and are labeled as true or false. If all of the assertions are true, return "True". If any of the assertions are false, return "False". Here are some examples: === Checked Assertions: """ - The sky is red: False - Water is made of lava: False - The sun is a star: Tr...
https://langchain.readthedocs.io/en/latest/modules/chains/examples/llm_summarization_checker.html
06c165ab987f-0
.ipynb .pdf Moderation Contents How to use the moderation chain How to append a Moderation chain to an LLMChain Moderation# This notebook walks through examples of how to use a moderation chain, and several common ways for doing so. Moderation chains are useful for detecting text that could be hateful, violent, etc. ...
https://langchain.readthedocs.io/en/latest/modules/chains/examples/moderation.html
06c165ab987f-1
if results["flagged"]: error_str = f"The following text was found that violates OpenAI's content policy: {text}" return error_str return text custom_moderation = CustomModeration() custom_moderation.run("This is okay") 'This is okay' custom_moderation.run("I will kill you") "The fol...
https://langchain.readthedocs.io/en/latest/modules/chains/examples/moderation.html
5f4c30e4fd45-0
.ipynb .pdf Summarization Contents Prepare Data Quickstart The stuff Chain The map_reduce Chain The custom MapReduceChain The refine Chain Summarization# This notebook walks through how to use LangChain for summarization over a list of documents. It covers three different chain types: stuff, map_reduce, and refine. F...
https://langchain.readthedocs.io/en/latest/modules/chains/index_examples/summarize.html
5f4c30e4fd45-1
chain.run(docs) " In response to Russia's aggression in Ukraine, the United States and its allies have imposed economic sanctions and are taking other measures to hold Putin accountable. The US is also providing economic and military assistance to Ukraine, protecting NATO countries, and releasing oil from its Strategic...
https://langchain.readthedocs.io/en/latest/modules/chains/index_examples/summarize.html
5f4c30e4fd45-2
"\n\nIl Presidente Biden ha lottato per passare l'American Rescue Plan per aiutare le persone che soffrivano a causa della pandemia. Il piano ha fornito sollievo economico immediato a milioni di americani, ha aiutato a mettere cibo sulla loro tavola, a mantenere un tetto sopra le loro teste e a ridurre il costo dell'as...
https://langchain.readthedocs.io/en/latest/modules/chains/index_examples/summarize.html
5f4c30e4fd45-3
while j >= gap and input_list[j - gap] > temp: input_list[j] = input_list[j - gap] j = j-gap input_list[j] = temp gap = gap//2 return input_list """ map_reduce.run(input_text=code, question="Which function has a better time complexity?") Created a chunk of size 247, which is longer than the spec...
https://langchain.readthedocs.io/en/latest/modules/chains/index_examples/summarize.html
5f4c30e4fd45-4
"\n\nIn response to Russia's aggression in Ukraine, the United States has united with other freedom-loving nations to impose economic sanctions and hold Putin accountable. The U.S. Department of Justice is also assembling a task force to go after the crimes of Russian oligarchs and seize their ill-gotten gains. We are ...
https://langchain.readthedocs.io/en/latest/modules/chains/index_examples/summarize.html
5f4c30e4fd45-5
"\n\nQuesta sera, ci incontriamo come democratici, repubblicani e indipendenti, ma soprattutto come americani. La Russia di Putin ha cercato di scuotere le fondamenta del mondo libero, ma ha sottovalutato la forza della gente ucraina. Insieme ai nostri alleati, stiamo imponendo sanzioni economiche, tagliando l'accesso ...
https://langchain.readthedocs.io/en/latest/modules/chains/index_examples/summarize.html
62e631e7e688-0
.ipynb .pdf Question Answering with Sources Contents Prepare Data Quickstart The stuff Chain The map_reduce Chain The refine Chain The map-rerank Chain Question Answering with Sources# This notebook walks through how to use LangChain for question answering with sources over a list of documents. It covers four differe...
https://langchain.readthedocs.io/en/latest/modules/chains/index_examples/qa_with_sources.html
62e631e7e688-1
Intermediate Steps We can also return the intermediate steps for map_reduce chains, should we want to inspect them. This is done with the return_intermediate_steps variable. chain = load_qa_with_sources_chain(OpenAI(temperature=0), chain_type="map_reduce", return_intermediate_steps=True) chain({"input_documents": docs,...
https://langchain.readthedocs.io/en/latest/modules/chains/index_examples/qa_with_sources.html
62e631e7e688-2
chain({"input_documents": docs, "question": query}, return_only_outputs=True) {'output_text': "\n\nThe president said that he was honoring Justice Breyer for his dedication to serving the country and that he was a retiring Justice of the United States Supreme Court. He also thanked him for his service and praised his c...
https://langchain.readthedocs.io/en/latest/modules/chains/index_examples/qa_with_sources.html
62e631e7e688-3
'\n\nThe president said that he was honoring Justice Breyer for his dedication to serving the country and that he was a retiring Justice of the United States Supreme Court. He also thanked Justice Breyer for his service, noting his background as a top litigator in private practice, a former federal public defender, and...
https://langchain.readthedocs.io/en/latest/modules/chains/index_examples/qa_with_sources.html
62e631e7e688-4
"\n\nIl presidente ha detto che Justice Breyer ha dedicato la sua vita al servizio di questo paese, ha onorato la sua carriera e ha contribuito a costruire un consenso. Ha ricevuto un ampio sostegno, dall'Ordine Fraterno della Polizia a ex giudici nominati da democratici e repubblicani. Inoltre, ha sottolineato l'impor...
https://langchain.readthedocs.io/en/latest/modules/chains/index_examples/qa_with_sources.html
62e631e7e688-5
result["output_text"] ' The President thanked Justice Breyer for his service and honored him for dedicating his life to serve the country.' result["intermediate_steps"] [{'answer': ' The President thanked Justice Breyer for his service and honored him for dedicating his life to serve the country.', 'score': '100'}, ...
https://langchain.readthedocs.io/en/latest/modules/chains/index_examples/qa_with_sources.html
b6d4ef9794e8-0
.ipynb .pdf Question Answering Contents Prepare Data Quickstart The stuff Chain The map_reduce Chain The refine Chain The map-rerank Chain Question Answering# This notebook walks through how to use LangChain for question answering over a list of documents. It covers four different types of chains: stuff, map_reduce, ...
https://langchain.readthedocs.io/en/latest/modules/chains/index_examples/question_answering.html
b6d4ef9794e8-1
chain({"input_documents": docs, "question": query}, return_only_outputs=True) {'intermediate_steps': [' "Tonight, I’d like to honor someone who has dedicated his life to serve this country: Justice Stephen Breyer—an Army veteran, Constitutional scholar, and retiring Justice of the United States Supreme Court. Justice B...
https://langchain.readthedocs.io/en/latest/modules/chains/index_examples/question_answering.html
b6d4ef9794e8-2
chain({"input_documents": docs, "question": query}, return_only_outputs=True) {'intermediate_steps': ['\nThe president said that he wanted to honor Justice Breyer for his dedication to serving the country and his legacy of excellence.', '\nThe president said that he wanted to honor Justice Breyer for his dedication t...
https://langchain.readthedocs.io/en/latest/modules/chains/index_examples/question_answering.html
b6d4ef9794e8-3
"\nIl presidente ha detto che Justice Breyer ha dedicato la sua vita al servizio di questo paese, ha reso omaggio al suo servizio e ha sostenuto la nomina di una top litigatrice in pratica privata, un ex difensore pubblico federale e una famiglia di insegnanti e agenti di polizia delle scuole pubbliche. Ha anche sottol...
https://langchain.readthedocs.io/en/latest/modules/chains/index_examples/question_answering.html
b6d4ef9794e8-4
Score: [score between 0 and 100] Begin! Context: --------- {context} --------- Question: {question} Helpful Answer In Italian:""" PROMPT = PromptTemplate( template=prompt_template, input_variables=["context", "question"], output_parser=output_parser, ) chain = load_qa_chain(OpenAI(temperature=0), chain_type...
https://langchain.readthedocs.io/en/latest/modules/chains/index_examples/question_answering.html
c12d869881a1-0
.ipynb .pdf Hypothetical Document Embeddings Contents Multiple generations Using our own prompts Using HyDE Hypothetical Document Embeddings# This notebook goes over how to use Hypothetical Document Embeddings (HyDE), as described in this paper. At a high level, HyDE is an embedding technique that takes queries, gene...
https://langchain.readthedocs.io/en/latest/modules/chains/index_examples/hyde.html
c12d869881a1-1
previous Graph QA next Question Answering with Sources Contents Multiple generations Using our own prompts Using HyDE By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 08, 2023.
https://langchain.readthedocs.io/en/latest/modules/chains/index_examples/hyde.html
20e420244fba-0
.ipynb .pdf Chat Over Documents with Chat History Contents Pass in chat history Using a different model for condensing the question Return Source Documents ConversationalRetrievalChain with search_distance ConversationalRetrievalChain with map_reduce ConversationalRetrievalChain with Question Answering with sources C...
https://langchain.readthedocs.io/en/latest/modules/chains/index_examples/chat_vector_db.html
20e420244fba-1
Using a different model for condensing the question# This chain has two steps. First, it condenses the current question and the chat history into a standalone question. This is neccessary to create a standanlone vector to use for retrieval. After that, it does retrieval and then answers the question using retrieval aug...
https://langchain.readthedocs.io/en/latest/modules/chains/index_examples/chat_vector_db.html
20e420244fba-2
result['answer'] " The president said that Ketanji Brown Jackson is one of the nation's top legal minds, a former top litigator in private practice, a former federal public defender, from a family of public school educators and police officers, a consensus builder, and has received a broad range of support from the Fra...
https://langchain.readthedocs.io/en/latest/modules/chains/index_examples/chat_vector_db.html
20e420244fba-3
result['answer'] " The president said that Ketanji Brown Jackson is one of the nation's top legal minds, a former top litigator in private practice, a former federal public defender, and from a family of public school educators and police officers. He also said that she is a consensus builder and has received a broad r...
https://langchain.readthedocs.io/en/latest/modules/chains/index_examples/chat_vector_db.html
4118f7b83d16-0
.ipynb .pdf Retrieval Question/Answering Contents Chain Type Custom Prompts Return Source Documents Retrieval Question/Answering# This example showcases question answering over an index. from langchain.embeddings.openai import OpenAIEmbeddings from langchain.vectorstores import Chroma from langchain.text_splitter imp...
https://langchain.readthedocs.io/en/latest/modules/chains/index_examples/vector_db_qa.html
4118f7b83d16-1
qa.run(query) " Il presidente ha detto che Ketanji Brown Jackson è una delle menti legali più importanti del paese, che continuerà l'eccellenza di Justice Breyer e che ha ricevuto un ampio sostegno, da Fraternal Order of Police a ex giudici nominati da democratici e repubblicani." Return Source Documents# Additionally,...
https://langchain.readthedocs.io/en/latest/modules/chains/index_examples/vector_db_qa.html
4118f7b83d16-2
Document(page_content='Tonight, I’m announcing a crackdown on these companies overcharging American businesses and consumers. \n\nAnd as Wall Street firms take over more nursing homes, quality in those homes has gone down and costs have gone up. \n\nThat ends on my watch. \n\nMedicare is going to set higher standards ...
https://langchain.readthedocs.io/en/latest/modules/chains/index_examples/vector_db_qa.html
eb8d4c0fcd60-0
.ipynb .pdf Graph QA Contents Create the graph Querying the graph Save the graph Graph QA# This notebook goes over how to do question answering over a graph data structure. Create the graph# In this section, we construct an example graph. At the moment, this works best for small pieces of text. from langchain.indexes...
https://langchain.readthedocs.io/en/latest/modules/chains/index_examples/graph_qa.html
f3ef3940b40f-0
.ipynb .pdf Vector DB Text Generation Contents Prepare Data Set Up Vector DB Set Up LLM Chain with Custom Prompt Generate Text Vector DB Text Generation# This notebook walks through how to use LangChain for text generation over a vector index. This is useful if we want to generate text that is able to draw from a lar...
https://langchain.readthedocs.io/en/latest/modules/chains/index_examples/vector_db_text_generation.html
f3ef3940b40f-1
print(chain.apply(inputs)) generate_blog_post("environment variables") [{'text': '\n\nEnvironment variables are a great way to store and access sensitive information in your Deno applications. Deno offers built-in support for environment variables with `Deno.env`, and you can also use a `.env` file to store and access ...
https://langchain.readthedocs.io/en/latest/modules/chains/index_examples/vector_db_text_generation.html
f3ef3940b40f-2
previous Retrieval Question Answering with Sources next API Chains Contents Prepare Data Set Up Vector DB Set Up LLM Chain with Custom Prompt Generate Text By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 08, 2023.
https://langchain.readthedocs.io/en/latest/modules/chains/index_examples/vector_db_text_generation.html
5c28abc9ab19-0
.ipynb .pdf Analyze Document Contents Summarize Question Answering Analyze Document# The AnalyzeDocumentChain is more of an end to chain. This chain takes in a single document, splits it up, and then runs it through a CombineDocumentsChain. This can be used as more of an end-to-end chain. with open("../../state_of_th...
https://langchain.readthedocs.io/en/latest/modules/chains/index_examples/analyze_document.html
383d5ab25b8c-0
.ipynb .pdf Retrieval Question Answering with Sources Contents Chain Type Retrieval Question Answering with Sources# This notebook goes over how to do question-answering with sources over an Index. It does this by using the RetrievalQAWithSourcesChain, which does the lookup of the documents from an Index. from langch...
https://langchain.readthedocs.io/en/latest/modules/chains/index_examples/vector_db_qa_with_sources.html
3e7ded4185d8-0
.ipynb .pdf Callbacks Contents Callbacks How to use callbacks When do you want to use each of these? Using an existing handler Creating a custom handler Async Callbacks Using multiple handlers, passing in handlers Tracing and Token Counting Tracing Token Counting Callbacks# LangChain provides a callbacks system that ...
https://langchain.readthedocs.io/en/latest/modules/callbacks/getting_started.html
3e7ded4185d8-1
Constructor callbacks: defined in the constructor, eg. LLMChain(callbacks=[handler]), which will be used for all calls made on that object, and will be scoped to that object only, eg. if you pass a handler to the LLMChain constructor, it will not be used by the Model attached to that chain. Request callbacks: defined i...
https://langchain.readthedocs.io/en/latest/modules/callbacks/getting_started.html
3e7ded4185d8-2
My custom handler, token: Because My custom handler, token: it My custom handler, token: saw My custom handler, token: the My custom handler, token: salad My custom handler, token: dressing My custom handler, token: ! My custom handler, token: AIMessage(content='Why did the tomato turn red? Because it saw the sa...
https://langchain.readthedocs.io/en/latest/modules/callbacks/getting_started.html
3e7ded4185d8-3
However, in many cases, it is advantageous to pass in handlers instead when running the object. When we pass through CallbackHandlers using the callbacks keyword arg when executing an run, those callbacks will be issued by all nested objects involved in the execution. For example, when a handler is passed through to an...
https://langchain.readthedocs.io/en/latest/modules/callbacks/getting_started.html
3e7ded4185d8-4
on_new_token ... on_new_token num on_new_token expr on_new_token . on_new_token evaluate on_new_token (" on_new_token 2 on_new_token ** on_new_token 0 on_new_token . on_new_token 235 on_new_token ") on_new_token ... on_new_token on_new_token on_chain_start LLMChain on_llm_start OpenAI on_llm_start (I'm the second han...
https://langchain.readthedocs.io/en/latest/modules/callbacks/getting_started.html
3e7ded4185d8-5
Action: Search Action Input: "Olivia Wilde boyfriend" Observation: Sudeikis and Wilde's relationship ended in November 2020. Wilde was publicly served with court documents regarding child custody while she was presenting Don't Worry Darling at CinemaCon 2022. In January 2021, Wilde began dating singer Harry Styles afte...
https://langchain.readthedocs.io/en/latest/modules/callbacks/getting_started.html
3e7ded4185d8-6
> Entering new AgentExecutor chain... > Entering new AgentExecutor chain... I need to find out who won the grand prix and then calculate their age raised to the 0.23 power. Action: Search Action Input: "Formula 1 Grand Prix Winner" I need to find out who won the US Open men's final in 2019 and then calculate his age r...
https://langchain.readthedocs.io/en/latest/modules/callbacks/getting_started.html
1425f7798b06-0
.rst .pdf Toolkits Toolkits# Note Conceptual Guide This section of documentation covers agents with toolkits - eg an agent applied to a particular use case. See below for a full list of agent toolkits Azure Cognitive Services Toolkit CSV Agent Gmail Toolkit Jira JSON Agent OpenAPI agents Natural Language APIs Pandas Da...
https://langchain.readthedocs.io/en/latest/modules/agents/toolkits.html
9b828695685b-0
.rst .pdf Agent Executors Agent Executors# Note Conceptual Guide Agent executors take an agent and tools and use the agent to decide which tools to call and in what order. In this part of the documentation we cover other related functionality to agent executors How to combine agents and vectorstores How to use the asyn...
https://langchain.readthedocs.io/en/latest/modules/agents/agent_executors.html
59b4052a0ce4-0
.ipynb .pdf Getting Started Getting Started# Agents use an LLM to determine which actions to take and in what order. An action can either be using a tool and observing its output, or returning to the user. When used correctly agents can be extremely powerful. The purpose of this notebook is to show you how to easily us...
https://langchain.readthedocs.io/en/latest/modules/agents/getting_started.html
1e1ebdc5bbc2-0
.ipynb .pdf Plan and Execute Contents Plan and Execute Imports Tools Planner, Executor, and Agent Run Example Plan and Execute# Plan and execute agents accomplish an objective by first planning what to do, then executing the sub tasks. This idea is largely inspired by BabyAGI and then the “Plan-and-Solve” paper. The ...
https://langchain.readthedocs.io/en/latest/modules/agents/plan_and_execute.html
1e1ebdc5bbc2-1
> Entering new AgentExecutor chain... Action: ``` { "action": "Calculator", "action_input": "28 ** 0.43" } ``` > Entering new LLMMathChain chain... 28 ** 0.43 ```text 28 ** 0.43 ``` ...numexpr.evaluate("28 ** 0.43")... Answer: 4.1906168361987195 > Finished chain. Observation: Answer: 4.1906168361987195 Thought:The ...
https://langchain.readthedocs.io/en/latest/modules/agents/plan_and_execute.html
241f7000ec40-0
.rst .pdf Agents Agents# Note Conceptual Guide In this part of the documentation we cover the different types of agents, disregarding which specific tools they are used with. For a high level overview of the different types of agents, see the below documentation. Agent Types For documentation on how to create a custom ...
https://langchain.readthedocs.io/en/latest/modules/agents/agents.html
fffec0c16796-0
.rst .pdf Tools Tools# Note Conceptual Guide Tools are ways that an agent can use to interact with the outside world. For an overview of what a tool is, how to use them, and a full list of examples, please see the getting started documentation Getting Started Next, we have some examples of customizing and generically w...
https://langchain.readthedocs.io/en/latest/modules/agents/tools.html
ec41ddb2cbb4-0
.ipynb .pdf Custom LLM Agent Contents Set up environment Set up tool Prompt Template Output Parser Set up LLM Define the stop sequence Set up the Agent Use the Agent Adding Memory Custom LLM Agent# This notebook goes through how to create your own custom LLM agent. An LLM agent consists of three parts: PromptTemplate...
https://langchain.readthedocs.io/en/latest/modules/agents/agents/custom_llm_agent.html
ec41ddb2cbb4-1
# Create a list of tool names for the tools provided kwargs["tool_names"] = ", ".join([tool.name for tool in self.tools]) return self.template.format(**kwargs) prompt = CustomPromptTemplate( template=template, tools=tools, # This omits the `agent_scratchpad`, `tools`, and `tool_names` variab...
https://langchain.readthedocs.io/en/latest/modules/agents/agents/custom_llm_agent.html
ec41ddb2cbb4-2
Action Input: the input to the action Observation: the result of the action ... (this Thought/Action/Action Input/Observation can repeat N times) Thought: I now know the final answer Final Answer: the final answer to the original input question Begin! Remember to speak as a pirate when giving your final answer. Use lot...
https://langchain.readthedocs.io/en/latest/modules/agents/agents/custom_llm_agent.html
469de9739106-0
.ipynb .pdf Custom LLM Agent (with a ChatModel) Contents Set up environment Set up tool Prompt Template Output Parser Set up LLM Define the stop sequence Set up the Agent Use the Agent Custom LLM Agent (with a ChatModel)# This notebook goes through how to create your own custom agent based on a chat model. An LLM cha...
https://langchain.readthedocs.io/en/latest/modules/agents/agents/custom_llm_chat_agent.html
469de9739106-1
# Set the agent_scratchpad variable to that value kwargs["agent_scratchpad"] = thoughts # Create a tools variable from the list of tools provided kwargs["tools"] = "\n".join([f"{tool.name}: {tool.description}" for tool in self.tools]) # Create a list of tool names for the tools provided ...
https://langchain.readthedocs.io/en/latest/modules/agents/agents/custom_llm_chat_agent.html
469de9739106-2
By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 08, 2023.
https://langchain.readthedocs.io/en/latest/modules/agents/agents/custom_llm_chat_agent.html
204e9ceeb356-0
.ipynb .pdf Custom MultiAction Agent Custom MultiAction Agent# This notebook goes through how to create your own custom agent. An agent consists of two parts: - Tools: The tools the agent has available to use. - The agent class itself: this decides which action to take. In this notebook we walk through how to create a ...
https://langchain.readthedocs.io/en/latest/modules/agents/agents/custom_multi_action_agent.html
d119d5b4129b-0
.ipynb .pdf Custom Agent with Tool Retrieval Contents Set up environment Set up tools Tool Retriever Prompt Template Output Parser Set up LLM, stop sequence, and the agent Use the Agent Custom Agent with Tool Retrieval# This notebook builds off of this notebook and assumes familiarity with how agents work. The novel ...
https://langchain.readthedocs.io/en/latest/modules/agents/agents/custom_agent_with_tool_retrieval.html
d119d5b4129b-1
get_tools("whats the number 13?") [Tool(name='foo-13', description='a silly function that you can use to get more information about the number 13', return_direct=False, verbose=False, callback_manager=<langchain.callbacks.shared.SharedCallbackManager object at 0x114b28a90>, func=<function fake_func at 0x15e5bd1f0>, cor...
https://langchain.readthedocs.io/en/latest/modules/agents/agents/custom_agent_with_tool_retrieval.html
d119d5b4129b-2
# Return values is generally always a dictionary with a single `output` key # It is not recommended to try anything else at the moment :) return_values={"output": llm_output.split("Final Answer:")[-1].strip()}, log=llm_output, ) # Parse out the action ...
https://langchain.readthedocs.io/en/latest/modules/agents/agents/custom_agent_with_tool_retrieval.html
eb41659584f1-0
.ipynb .pdf Custom MRKL Agent Contents Custom LLMChain Multiple inputs Custom MRKL Agent# This notebook goes through how to create your own custom MRKL agent. A MRKL agent consists of three parts: - Tools: The tools the agent has available to use. - LLMChain: The LLMChain that produces the text that is parsed in a ce...
https://langchain.readthedocs.io/en/latest/modules/agents/agents/custom_mrkl_agent.html
eb41659584f1-1
agent_executor.run("How many people live in canada as of 2023?") > Entering new AgentExecutor chain... Thought: I need to find out the population of Canada Action: Search Action Input: Population of Canada 2023 Observation: The current population of Canada is 38,661,927 as of Sunday, April 16, 2023, based on Worldomete...
https://langchain.readthedocs.io/en/latest/modules/agents/agents/custom_mrkl_agent.html
e2bf473c27bd-0
.ipynb .pdf Custom Agent Custom Agent# This notebook goes through how to create your own custom agent. An agent consists of two parts: - Tools: The tools the agent has available to use. - The agent class itself: this decides which action to take. In this notebook we walk through how to create a custom agent. from langc...
https://langchain.readthedocs.io/en/latest/modules/agents/agents/custom_agent.html
020d66a60fd5-0
.md .pdf Agent Types Contents zero-shot-react-description react-docstore self-ask-with-search conversational-react-description Agent Types# Agents use an LLM to determine which actions to take and in what order. An action can either be using a tool and observing its output, or returning a response to the user. Here a...
https://langchain.readthedocs.io/en/latest/modules/agents/agents/agent_types.html
94fdead7eb30-0
.ipynb .pdf Conversation Agent Conversation Agent# This notebook walks through using an agent optimized for conversation. Other agents are often optimized for using tools to figure out the best response, which is not ideal in a conversational setting where you may want the agent to be able to chat with the user as well...
https://langchain.readthedocs.io/en/latest/modules/agents/agents/examples/conversational_agent.html
3920e70f51d5-0
.ipynb .pdf Structured Tool Chat Agent Contents Initialize Tools Adding in memory Structured Tool Chat Agent# This notebook walks through using a chat agent capable of using multi-input tools. Older agents are configured to specify an action input as a single string, but this agent can use the provided tools’ args_sc...
https://langchain.readthedocs.io/en/latest/modules/agents/agents/examples/structured_chat.html
3920e70f51d5-1
TL;DR We recently open-sourced an auto-evaluator tool for grading LLM question-answer chains. We are now releasing an open source, free to use hosted app and API to expand usability. Below we discuss a few opportunities to further improve May 1, 2023 5 min read Callbacks Improvements TL;DR: We're announcing improvement...
https://langchain.readthedocs.io/en/latest/modules/agents/agents/examples/structured_chat.html
3920e70f51d5-2
The reason we like Supabase so much is that Apr 8, 2023 2 min read Announcing our $10M seed round led by Benchmark It was only six months ago that we released the first version of LangChain, but it seems like several years. When we launched, generative AI was starting to go mainstream: stable diffusion had just been re...
https://langchain.readthedocs.io/en/latest/modules/agents/agents/examples/structured_chat.html
3920e70f51d5-3
What does this mean? It means that all your favorite prompts, chains, and agents are all recreatable in TypeScript natively. Both the Python version and TypeScript version utilize the same serializable format, meaning that artifacts can seamlessly be shared between languages. As an Feb 17, 2023 2 min read Streaming Sup...
https://langchain.readthedocs.io/en/latest/modules/agents/agents/examples/structured_chat.html
7bbd873be40a-0
.ipynb .pdf Self Ask With Search Self Ask With Search# This notebook showcases the Self Ask With Search chain. from langchain import OpenAI, SerpAPIWrapper from langchain.agents import initialize_agent, Tool from langchain.agents import AgentType llm = OpenAI(temperature=0) search = SerpAPIWrapper() tools = [ Tool(...
https://langchain.readthedocs.io/en/latest/modules/agents/agents/examples/self_ask_with_search.html
82e6e73de4ae-0
.ipynb .pdf MRKL Chat MRKL Chat# This notebook showcases using an agent to replicate the MRKL chain using an agent optimized for chat models. This uses the example Chinook database. To set it up follow the instructions on https://database.guide/2-sample-databases-sqlite/, placing the .db file in a notebooks folder at t...
https://langchain.readthedocs.io/en/latest/modules/agents/agents/examples/mrkl_chat.html
82e6e73de4ae-1
} ``` Observation: Alanis Morissette Thought:Now that I know the artist's name, I can use the FooBar DB tool to find out if they are in the database and what albums of theirs are in it. Action: ``` { "action": "FooBar DB", "action_input": "What albums does Alanis Morissette have in the database?" } ``` > Entering n...
https://langchain.readthedocs.io/en/latest/modules/agents/agents/examples/mrkl_chat.html
423324c54048-0
.ipynb .pdf ReAct ReAct# This notebook showcases using an agent to implement the ReAct logic. from langchain import OpenAI, Wikipedia from langchain.agents import initialize_agent, Tool from langchain.agents import AgentType from langchain.agents.react.base import DocstoreExplorer docstore=DocstoreExplorer(Wikipedia())...
https://langchain.readthedocs.io/en/latest/modules/agents/agents/examples/react.html
a0bc0623318e-0
.ipynb .pdf Conversation Agent (for Chat Models) Conversation Agent (for Chat Models)# This notebook walks through using an agent optimized for conversation, using ChatModels. Other agents are often optimized for using tools to figure out the best response, which is not ideal in a conversational setting where you may w...
https://langchain.readthedocs.io/en/latest/modules/agents/agents/examples/chat_conversation_agent.html
a0bc0623318e-1
} > Finished chain. 'Cloudy with showers. Low around 55F. Winds S at 5 to 10 mph. Chance of rain 60%. Humidity76%.' previous Custom Agent with Tool Retrieval next Conversation Agent By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 08, 2023.
https://langchain.readthedocs.io/en/latest/modules/agents/agents/examples/chat_conversation_agent.html
37aef4dd68a1-0
.ipynb .pdf MRKL MRKL# This notebook showcases using an agent to replicate the MRKL chain. This uses the example Chinook database. To set it up follow the instructions on https://database.guide/2-sample-databases-sqlite/, placing the .db file in a notebooks folder at the root of this repository. from langchain import L...
https://langchain.readthedocs.io/en/latest/modules/agents/agents/examples/mrkl.html
37aef4dd68a1-1
What albums by Alanis Morissette are in the FooBar database? SQLQuery: /Users/harrisonchase/workplace/langchain/langchain/sql_database.py:191: SAWarning: Dialect sqlite+pysqlite does *not* support Decimal objects natively, and SQLAlchemy must convert from floating point - rounding errors and other issues may occur. Ple...
https://langchain.readthedocs.io/en/latest/modules/agents/agents/examples/mrkl.html
a98863dae490-0
.ipynb .pdf Multi-Input Tools Contents Multi-Input Tools with a string format Multi-Input Tools# This notebook shows how to use a tool that requires multiple inputs with an agent. The recommended way to do so is with the StructuredTool class. import os os.environ["LANGCHAIN_TRACING"] = "true" from langchain import Op...
https://langchain.readthedocs.io/en/latest/modules/agents/tools/multi_input_tool.html
878ef5333bfe-0
.ipynb .pdf Defining Custom Tools Contents Completely New Tools - String Input and Output Tool dataclass Subclassing the BaseTool class Using the tool decorator Custom Structured Tools StructuredTool dataclass Subclassing the BaseTool Using the decorator Modify existing tools Defining the priorities among Tools Using...
https://langchain.readthedocs.io/en/latest/modules/agents/tools/custom_tools.html
878ef5333bfe-1
Action Input: "Camila Morrone age" Observation: 25 years Thought:Now that I have her age, I need to calculate her age raised to the 0.43 power Action: Calculator Action Input: 25^(0.43) > Entering new LLMMathChain chain... 25^(0.43)```text 25**(0.43) ``` ...numexpr.evaluate("25**(0.43)")... Answer: 3.991298452658078 > ...
https://langchain.readthedocs.io/en/latest/modules/agents/tools/custom_tools.html
878ef5333bfe-2
from langchain.tools import tool @tool def search_api(query: str) -> str: """Searches the API for the query.""" return f"Results for query {query}" search_api You can also provide arguments like the tool name and whether to return directly. @tool("search", return_direct=True) def search_api(query: str) -> str: ...
https://langchain.readthedocs.io/en/latest/modules/agents/tools/custom_tools.html
878ef5333bfe-3
return search_wrapper.run(query) async def _arun(self, query: str, engine: str = "google", gl: str = "us", hl: str = "en", run_manager: Optional[AsyncCallbackManagerForToolRun] = None) -> str: """Use the tool asynchronously.""" raise NotImplementedError("custom_search does not support async") ...
https://langchain.readthedocs.io/en/latest/modules/agents/tools/custom_tools.html
878ef5333bfe-4
agent.run("what is the most famous song of christmas") > Entering new AgentExecutor chain... I should use a music search engine to find the answer Action: Music Search Action Input: most famous song of christmas'All I Want For Christmas Is You' by Mariah Carey. I now know the final answer Final Answer: 'All I Want For...
https://langchain.readthedocs.io/en/latest/modules/agents/tools/custom_tools.html
878ef5333bfe-5
Action: Search_tool3 Action Input: "Leo DiCaprio girlfriend" Observation: Leonardo DiCaprio and Gigi Hadid were recently spotted at a pre-Oscars party, sparking interest once again in their rumored romance. The Revenant actor and the model first made headlines when they were spotted together at a New York Fashion Week ...
https://langchain.readthedocs.io/en/latest/modules/agents/tools/custom_tools.html
4e8aac2d530d-0
.md .pdf Getting Started Contents List of Tools Getting Started# Tools are functions that agents can use to interact with the world. These tools can be generic utilities (e.g. search), other chains, or even other agents. Currently, tools can be loaded with the following snippet: from langchain.agents import load_tool...
https://langchain.readthedocs.io/en/latest/modules/agents/tools/getting_started.html
4e8aac2d530d-1
Notes: A natural language connection to the TMDB API (https://api.themoviedb.org/3), specifically the /search/movie endpoint. Requires LLM: Yes Extra Parameters: tmdb_bearer_token (your Bearer Token to access this endpoint - note that this is different from the API key) google-search Tool Name: Search Tool Description:...
https://langchain.readthedocs.io/en/latest/modules/agents/tools/getting_started.html
8fa46b33b6b6-0
.ipynb .pdf Tool Input Schema Tool Input Schema# By default, tools infer the argument schema by inspecting the function signature. For more strict requirements, custom input schema can be specified, along with custom validation logic. from typing import Any, Dict from langchain.agents import AgentType, initialize_agent...
https://langchain.readthedocs.io/en/latest/modules/agents/tools/tool_input_validation.html
8fa46b33b6b6-1
694 # We then call the tool on the tool input to get an observation --> 695 observation = tool.run( 696 agent_action.tool_input, 697 verbose=self.verbose, 698 color=color, 699 **tool_run_kwargs, 700 ) 701 else: 702 tool_run_kwargs = self.agent....
https://langchain.readthedocs.io/en/latest/modules/agents/tools/tool_input_validation.html
8ba763380ace-0
.ipynb .pdf Gradio Tools Contents Using a tool Using within an agent Gradio Tools# There are many 1000s of Gradio apps on Hugging Face Spaces. This library puts them at the tips of your LLM’s fingers 🦾 Specifically, gradio-tools is a Python library for converting Gradio apps into tools that can be leveraged by a lar...
https://langchain.readthedocs.io/en/latest/modules/agents/tools/examples/gradio_tools.html
8ba763380ace-1
Job Status: Status.STARTING eta: None Due to heavy traffic on this app, the prediction will take approximately 73 seconds.For faster predictions without waiting in queue, you may duplicate the space using: Client.duplicate(damo-vilab/modelscope-text-to-video-synthesis) Job Status: Status.IN_QUEUE eta: 73.89824726581574...
https://langchain.readthedocs.io/en/latest/modules/agents/tools/examples/gradio_tools.html
8d8e4ee4b834-0
.ipynb .pdf ChatGPT Plugins ChatGPT Plugins# This example shows how to use ChatGPT Plugins within LangChain abstractions. Note 1: This currently only works for plugins with no auth. Note 2: There are almost certainly other ways to do this, this is just a first pass. If you have better ideas, please open a PR! from lang...
https://langchain.readthedocs.io/en/latest/modules/agents/tools/examples/chatgpt_plugins.html
8d8e4ee4b834-1
Observation: {"products":[{"name":"Lacoste Men's Pack of Plain T-Shirts","url":"https://www.klarna.com/us/shopping/pl/cl10001/3202043025/Clothing/Lacoste-Men-s-Pack-of-Plain-T-Shirts/?utm_source=openai","price":"$26.60","attributes":["Material:Cotton","Target Group:Man","Color:White,Black"]},{"name":"Hanes Men's Ultima...
https://langchain.readthedocs.io/en/latest/modules/agents/tools/examples/chatgpt_plugins.html
3d7d03d2161c-0
.ipynb .pdf Search Tools Contents Google Serper API Wrapper SerpAPI GoogleSearchAPIWrapper SearxNG Meta Search Engine Search Tools# This notebook shows off usage of various search tools. from langchain.agents import load_tools from langchain.agents import initialize_agent from langchain.agents import AgentType from l...
https://langchain.readthedocs.io/en/latest/modules/agents/tools/examples/search_tools.html
3d7d03d2161c-1
Thought: I now know the current weather conditions in Pomfret. Final Answer: Showers early becoming a steady light rain later in the day. Near record high temperatures. High around 60F. Winds SW at 10 to 15 mph. Chance of rain 60%. > Finished AgentExecutor chain. 'Showers early becoming a steady light rain later in the...
https://langchain.readthedocs.io/en/latest/modules/agents/tools/examples/search_tools.html
84ab24a8de5f-0
.ipynb .pdf Requests Contents Inside the tool Requests# The web contains a lot of information that LLMs do not have access to. In order to easily let LLMs interact with that information, we provide a wrapper around the Python Requests module that takes in a URL and fetches data from that URL. from langchain.agents im...
https://langchain.readthedocs.io/en/latest/modules/agents/tools/examples/requests.html
84ab24a8de5f-1
'<!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="en"><head><meta content="Search the world\'s information, including webpages, images, videos and more. Google has many special features to help you find exactly what you\'re looking for." name="description"><meta content="noodp" name="robots"...
https://langchain.readthedocs.io/en/latest/modules/agents/tools/examples/requests.html