id
stringlengths
14
16
text
stringlengths
31
3.14k
source
stringlengths
58
124
cc818135d6bf-24
_DumpException(e){throw e;}\nfunction _F_installCss(c){}\n(function(){google.jl={blt:\'none\',chnk:0,dw:false,dwu:true,emtn:0,end:0,ico:false,ikb:0,ine:false,injs:\'none\',injt:0,injth:0,injv2:false,lls:\'default\',pdt:0,rep:0,snet:true,strt:0,ubm:false,uwp:true};})();(function(){var pmc=\'{\\x22d\\x22:{},\\x22sb_he\\x...
/content/https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html
cc818135d6bf-25
Lucky\\x22,\\x22lml\\x22:\\x22Learn more\\x22,\\x22psrc\\x22:\\x22This search was removed from your \\\\u003Ca href\\x3d\\\\\\x22/history\\\\\\x22\\\\u003EWeb History\\\\u003C/a\\\\u003E\\x22,\\x22psrl\\x22:\\x22Remove\\x22,\\x22sbit\\x22:\\x22Search by image\\x22,\\x22srch\\x22:\\x22Google Search\\x22},\\x22ovr\\x22:{...
/content/https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html
cc818135d6bf-26
previous Python REPL next Search Tools By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 26, 2023.
/content/https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html
69e8e356f929-0
.ipynb .pdf Arxiv API Arxiv API# This notebook goes over how to use the arxiv component. First, you need to install arxiv python package. !pip install arxiv from langchain.utilities import ArxivAPIWrapper Run a query to get information about some scientific article/articles. The query text is limited to 300 characters....
/content/https://python.langchain.com/en/latest/modules/agents/tools/examples/arxiv.html
69e8e356f929-1
'Published: 2017-10-10\nTitle: On Mixing Behavior of a Family of Random Walks Determined by a Linear Recurrence\nAuthors: Caprice Stanley, Seth Sullivant\nSummary: We study random walks on the integers mod $G_n$ that are determined by an\ninteger sequence $\\{ G_n \\}_{n \\geq 1}$ generated by a linear recurrence\nrela...
/content/https://python.langchain.com/en/latest/modules/agents/tools/examples/arxiv.html
69e8e356f929-2
V. Plyaskin\nSummary: The results on the fluxes of charged particles and neutrinos from a\n3-dimensional (3D) simulation of atmospheric showers are presented. An\nagreement of calculated fluxes with data on charged particles from the AMS and\nCAPRICE detectors is demonstrated. Predictions on neutrino fluxes at differen...
/content/https://python.langchain.com/en/latest/modules/agents/tools/examples/arxiv.html
69e8e356f929-3
Now, we are trying to find information about non-existing article. In this case, the response is “No good Arxiv Result was found” docs = arxiv.run("1605.08386WWW") docs 'No good Arxiv Result was found' previous Apify next Bash By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 2...
/content/https://python.langchain.com/en/latest/modules/agents/tools/examples/arxiv.html
9f2399fb8ff7-0
.ipynb .pdf Wikipedia API Wikipedia API# This notebook goes over how to use the wikipedia component. First, you need to install wikipedia python package. pip install wikipedia from langchain.utilities import WikipediaAPIWrapper wikipedia = WikipediaAPIWrapper() wikipedia.run('HUNTER X HUNTER')
/content/https://python.langchain.com/en/latest/modules/agents/tools/examples/wikipedia.html
9f2399fb8ff7-1
'Page: Hunter × Hunter\nSummary: Hunter × Hunter (stylized as HUNTER×HUNTER and pronounced "hunter hunter") is a Japanese manga series written and illustrated by Yoshihiro Togashi. It has been serialized in Shueisha\'s shōnen manga magazine Weekly Shōnen Jump since March 1998, although the manga has frequently gone on ...
/content/https://python.langchain.com/en/latest/modules/agents/tools/examples/wikipedia.html
9f2399fb8ff7-2
into English and released in North America by Viz Media since April 2005. Both television series have been also licensed by Viz Media, with the first series having aired on the Funimation Channel in 2009 and the second series broadcast on Adult Swim\'s Toonami programming block from April 2016 to June 2019.\nHunter × H...
/content/https://python.langchain.com/en/latest/modules/agents/tools/examples/wikipedia.html
9f2399fb8ff7-3
composition, Takahiro Yoshimatsu designing the characters and Yoshihisa Hirano composing the music. Instead of having the old cast reprise their roles for the new adaptation, the series features an entirely new cast to voice the characters. The new series premiered airing weekly on Nippon TV and the nationwide Nippon N...
/content/https://python.langchain.com/en/latest/modules/agents/tools/examples/wikipedia.html
9f2399fb8ff7-4
List of Hunter × Hunter characters\nSummary: The Hunter × Hunter manga series, created by Yoshihiro Togashi, features an extensive cast of characters. It takes place in a fictional universe where licensed specialists known as Hunters travel the world taking on special jobs ranging from treasure hunting to assassination...
/content/https://python.langchain.com/en/latest/modules/agents/tools/examples/wikipedia.html
9f2399fb8ff7-5
previous SerpAPI next Wolfram Alpha By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 26, 2023.
/content/https://python.langchain.com/en/latest/modules/agents/tools/examples/wikipedia.html
2404ade73218-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...
/content/https://python.langchain.com/en/latest/modules/agents/tools/examples/search_tools.html
2404ade73218-1
> Entering new AgentExecutor chain... I need to find out what the current weather is in Pomfret. Action: Search Action Input: "weather in Pomfret" Observation: Partly cloudy skies during the morning hours will give way to cloudy skies with light rain and snow developing in the afternoon. High 42F. Winds WNW at 10 to 1...
/content/https://python.langchain.com/en/latest/modules/agents/tools/examples/search_tools.html
2404ade73218-2
Action: Google Search Action Input: "weather in Pomfret" Observation: 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%. Pomfret, CT Weather Forecast, with current conditions, wind, air quality, and what to expect fo...
/content/https://python.langchain.com/en/latest/modules/agents/tools/examples/search_tools.html
2404ade73218-3
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...
/content/https://python.langchain.com/en/latest/modules/agents/tools/examples/search_tools.html
2404ade73218-4
10 Day Weather - Pomfret, VT As of 3:51 am EST Special Weather Statement Today 39°/ 32° 37% Wed 01 | Day 39° 37% NE 4 mph Cloudy with snow showers developing for the afternoon. High 39F.... Pomfret, CT ; Current Weather. 1:06 AM. 35°F · RealFeel® 32° ; TODAY'S WEATHER FORECAST. 3/3. 44°Hi. RealFeel® 50° ; TONIGHT'S WEA...
/content/https://python.langchain.com/en/latest/modules/agents/tools/examples/search_tools.html
2404ade73218-5
Pomfret Center, CT Weather Conditions | Weather Underground star Popular Cities San Francisco, CA 49 °F Clear Manhattan, NY 37 °F Fair Schiller Park, IL (60176) warning39 °F Mostly Cloudy... Thought: I now know the final answer Final Answer: The current weather in Pomfret is mainly cloudy with snow showers around in th...
/content/https://python.langchain.com/en/latest/modules/agents/tools/examples/search_tools.html
70277ed69467-0
.ipynb .pdf Custom MultiAction Agent Custom MultiAction Agent# This notebook goes through how to create your own custom agent. An agent consists of three 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 ...
/content/https://python.langchain.com/en/latest/modules/agents/agents/custom_multi_action_agent.html
70277ed69467-1
along with observations **kwargs: User inputs. Returns: Action specifying what tool to use. """ if len(intermediate_steps) == 0: return [ AgentAction(tool="Search", tool_input=kwargs["input"], log=""), AgentAction(tool="RandomWo...
/content/https://python.langchain.com/en/latest/modules/agents/agents/custom_multi_action_agent.html
70277ed69467-2
> Entering new AgentExecutor chain... The current population of Canada is 38,669,152 as of Monday, April 24, 2023, based on Worldometer elaboration of the latest United Nations data. Now I'm doing this! foo > Finished chain. 'bar' previous Custom MRKL Agent next Custom Agent with Tool Retrieval By Harrison Chase ...
/content/https://python.langchain.com/en/latest/modules/agents/agents/custom_multi_action_agent.html
e03e89b3f4f9-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...
/content/https://python.langchain.com/en/latest/modules/agents/agents/custom_mrkl_agent.html
e03e89b3f4f9-1
suffix: String to put after the list of tools. input_variables: List of input variables the final prompt will expect. For this exercise, we will give our agent access to Google Search, and we will customize it in that we will have it answer as a pirate. from langchain.agents import ZeroShotAgent, Tool, AgentExecutor fr...
/content/https://python.langchain.com/en/latest/modules/agents/agents/custom_mrkl_agent.html
e03e89b3f4f9-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...
/content/https://python.langchain.com/en/latest/modules/agents/agents/custom_mrkl_agent.html
e03e89b3f4f9-3
Thought: I now know the final answer Final Answer: Arrr, Canada be havin' 38,661,927 people livin' there as of 2023! > Finished chain. "Arrr, Canada be havin' 38,661,927 people livin' there as of 2023!" Multiple inputs# Agents can also work with prompts that require multiple inputs. prefix = """Answer the following que...
/content/https://python.langchain.com/en/latest/modules/agents/agents/custom_mrkl_agent.html
e03e89b3f4f9-4
Action: Search Action Input: Canada population estimates 2023 Observation: Canada's population was estimated at 39,566,248 on January 1, 2023, after a record population growth of 1,050,110 people from January 1, 2022, to January 1, 2023. Thought: I now know the final answer. Final Answer: La popolazione del Canada è st...
/content/https://python.langchain.com/en/latest/modules/agents/agents/custom_mrkl_agent.html
fd90cd463bf0-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...
/content/https://python.langchain.com/en/latest/modules/agents/agents/agent_types.html
fd90cd463bf0-1
react-docstore self-ask-with-search conversational-react-description By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 26, 2023.
/content/https://python.langchain.com/en/latest/modules/agents/agents/agent_types.html
4256fb2a80a0-0
.ipynb .pdf Custom Agent Custom Agent# This notebook goes through how to create your own custom agent. An agent consists of three 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 lan...
/content/https://python.langchain.com/en/latest/modules/agents/agents/custom_agent.html
4256fb2a80a0-1
) -> Union[AgentAction, AgentFinish]: """Given input, decided what to do. Args: intermediate_steps: Steps the LLM has taken to date, along with observations **kwargs: User inputs. Returns: Action specifying what tool to use. """ ...
/content/https://python.langchain.com/en/latest/modules/agents/agents/custom_agent.html
dcb1e1ca814f-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...
/content/https://python.langchain.com/en/latest/modules/agents/agents/custom_llm_agent.html
dcb1e1ca814f-1
Set up environment# Do necessary imports, etc. from langchain.agents import Tool, AgentExecutor, LLMSingleActionAgent, AgentOutputParser from langchain.prompts import StringPromptTemplate from langchain import OpenAI, SerpAPIWrapper, LLMChain from typing import List, Union from langchain.schema import AgentAction, Agen...
/content/https://python.langchain.com/en/latest/modules/agents/agents/custom_llm_agent.html
dcb1e1ca814f-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...
/content/https://python.langchain.com/en/latest/modules/agents/agents/custom_llm_agent.html
dcb1e1ca814f-3
prompt = CustomPromptTemplate( template=template, tools=tools, # This omits the `agent_scratchpad`, `tools`, and `tool_names` variables because those are generated dynamically # This includes the `intermediate_steps` variable because that is needed input_variables=["input", "intermediate_steps"] ) O...
/content/https://python.langchain.com/en/latest/modules/agents/agents/custom_llm_agent.html
dcb1e1ca814f-4
if not match: raise ValueError(f"Could not parse LLM output: `{llm_output}`") action = match.group(1).strip() action_input = match.group(2) # Return the action and action input return AgentAction(tool=action, tool_input=action_input.strip(" ").strip('"'), log=llm_output) outp...
/content/https://python.langchain.com/en/latest/modules/agents/agents/custom_llm_agent.html
dcb1e1ca814f-5
> Entering new AgentExecutor chain... Thought: I need to find out the population of Canada in 2023 Action: Search Action Input: Population of Canada in 2023 Observation:The current population of Canada is 38,658,314 as of Wednesday, April 12, 2023, based on Worldometer elaboration of the latest United Nations data. I n...
/content/https://python.langchain.com/en/latest/modules/agents/agents/custom_llm_agent.html
dcb1e1ca814f-6
template=template_with_history, tools=tools, # This omits the `agent_scratchpad`, `tools`, and `tool_names` variables because those are generated dynamically # This includes the `intermediate_steps` variable because that is needed input_variables=["input", "intermediate_steps", "history"] ) llm_chain = ...
/content/https://python.langchain.com/en/latest/modules/agents/agents/custom_llm_agent.html
dcb1e1ca814f-7
> Finished chain. "Arrr, there be 38,658,314 people livin' in Canada as of 2023!" agent_executor.run("how about in mexico?") > Entering new AgentExecutor chain... Thought: I need to find out how many people live in Mexico. Action: Search Action Input: How many people live in Mexico as of 2023? Observation:The current p...
/content/https://python.langchain.com/en/latest/modules/agents/agents/custom_llm_agent.html
02ec69249e0e-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 ...
/content/https://python.langchain.com/en/latest/modules/agents/agents/custom_agent_with_tool_retrieval.html
02ec69249e0e-1
description="useful for when you need to answer questions about current events" ) def fake_func(inp: str) -> str: return "foo" fake_tools = [ Tool( name=f"foo-{i}", func=fake_func, description=f"a silly function that you can use to get more information about the number {i}" ) ...
/content/https://python.langchain.com/en/latest/modules/agents/agents/custom_agent_with_tool_retrieval.html
02ec69249e0e-2
get_tools("whats the weather?") [Tool(name='Search', description='useful for when you need to answer questions about current events', return_direct=False, verbose=False, callback_manager=<langchain.callbacks.shared.SharedCallbackManager object at 0x114b28a90>, func=<bound method SerpAPIWrapper.run of SerpAPIWrapper(sea...
/content/https://python.langchain.com/en/latest/modules/agents/agents/custom_agent_with_tool_retrieval.html
02ec69249e0e-3
Tool(name='foo-12', description='a silly function that you can use to get more information about the number 12', return_direct=False, verbose=False, callback_manager=<langchain.callbacks.shared.SharedCallbackManager object at 0x114b28a90>, func=<function fake_func at 0x15e5bd1f0>, coroutine=None), Tool(name='foo-15', ...
/content/https://python.langchain.com/en/latest/modules/agents/agents/custom_agent_with_tool_retrieval.html
02ec69249e0e-4
Tool(name='foo-12', description='a silly function that you can use to get more information about the number 12', return_direct=False, verbose=False, callback_manager=<langchain.callbacks.shared.SharedCallbackManager object at 0x114b28a90>, func=<function fake_func at 0x15e5bd1f0>, coroutine=None), Tool(name='foo-14', ...
/content/https://python.langchain.com/en/latest/modules/agents/agents/custom_agent_with_tool_retrieval.html
02ec69249e0e-5
{tools} Use the following format: Question: the input question you must answer Thought: you should always think about what to do Action: the action to take, should be one of [{tool_names}] Action Input: the input to the action Observation: the result of the action ... (this Thought/Action/Action Input/Observation can r...
/content/https://python.langchain.com/en/latest/modules/agents/agents/custom_agent_with_tool_retrieval.html
02ec69249e0e-6
tools = self.tools_getter(kwargs["input"]) # Create a tools variable from the list of tools provided kwargs["tools"] = "\n".join([f"{tool.name}: {tool.description}" for tool in tools]) # Create a list of tool names for the tools provided kwargs["tool_names"] = ", ".join([tool.name for to...
/content/https://python.langchain.com/en/latest/modules/agents/agents/custom_agent_with_tool_retrieval.html
02ec69249e0e-7
log=llm_output, ) # Parse out the action and action input regex = r"Action\s*\d*\s*:(.*?)\nAction\s*\d*\s*Input\s*\d*\s*:[\s]*(.*)" match = re.search(regex, llm_output, re.DOTALL) if not match: raise ValueError(f"Could not parse LLM output: `{llm_output}`") ...
/content/https://python.langchain.com/en/latest/modules/agents/agents/custom_agent_with_tool_retrieval.html
02ec69249e0e-8
agent_executor.run("What's the weather in SF?") > Entering new AgentExecutor chain... Thought: I need to find out what the weather is in SF Action: Search Action Input: Weather in SF Observation:Mostly cloudy skies early, then partly cloudy in the afternoon. High near 60F. ENE winds shifting to W at 10 to 15 mph. Humid...
/content/https://python.langchain.com/en/latest/modules/agents/agents/custom_agent_with_tool_retrieval.html
330d82ff81f6-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...
/content/https://python.langchain.com/en/latest/modules/agents/agents/custom_llm_chat_agent.html
330d82ff81f6-1
In this notebook we walk through how to create a custom LLM agent. Set up environment# Do necessary imports, etc. from langchain.agents import Tool, AgentExecutor, LLMSingleActionAgent, AgentOutputParser from langchain.prompts import BaseChatPromptTemplate from langchain import SerpAPIWrapper, LLMChain from langchain.c...
/content/https://python.langchain.com/en/latest/modules/agents/agents/custom_llm_chat_agent.html
330d82ff81f6-2
Action: the action to take, should be one of [{tool_names}] 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...
/content/https://python.langchain.com/en/latest/modules/agents/agents/custom_llm_chat_agent.html
330d82ff81f6-3
formatted = self.template.format(**kwargs) return [HumanMessage(content=formatted)] prompt = CustomPromptTemplate( template=template, tools=tools, # This omits the `agent_scratchpad`, `tools`, and `tool_names` variables because those are generated dynamically # This includes the `intermediate_st...
/content/https://python.langchain.com/en/latest/modules/agents/agents/custom_llm_chat_agent.html
330d82ff81f6-4
match = re.search(regex, llm_output, re.DOTALL) if not match: raise ValueError(f"Could not parse LLM output: `{llm_output}`") action = match.group(1).strip() action_input = match.group(2) # Return the action and action input return AgentAction(tool=action, tool_input=...
/content/https://python.langchain.com/en/latest/modules/agents/agents/custom_llm_chat_agent.html
330d82ff81f6-5
agent_executor.run("How many people live in canada as of 2023?") > Entering new AgentExecutor chain... Thought: Wot year be it now? That be important to know the answer. Action: Search Action Input: "current population canada 2023" Observation:38,649,283Ahoy! That be the correct year, but the answer be in regular numbe...
/content/https://python.langchain.com/en/latest/modules/agents/agents/custom_llm_chat_agent.html
d93bb485eca7-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...
/content/https://python.langchain.com/en/latest/modules/agents/agents/examples/conversational_agent.html
d93bb485eca7-1
> Entering new AgentExecutor chain... Thought: Do I need to use a tool? No AI: Your name is Bob! > Finished chain. 'Your name is Bob!' agent_chain.run("what are some good dinners to make this week, if i like thai food?") > Entering new AgentExecutor chain... Thought: Do I need to use a tool? Yes Action: Current Search ...
/content/https://python.langchain.com/en/latest/modules/agents/agents/examples/conversational_agent.html
d93bb485eca7-2
Observation: Argentina national football team Thought: Do I need to use a tool? No AI: The last letter in your name is "b" and the winner of the 1978 World Cup was the Argentina national football team. > Finished chain. 'The last letter in your name is "b" and the winner of the 1978 World Cup was the Argentina national...
/content/https://python.langchain.com/en/latest/modules/agents/agents/examples/conversational_agent.html
619cc53cdb76-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...
/content/https://python.langchain.com/en/latest/modules/agents/agents/examples/mrkl_chat.html
619cc53cdb76-1
), Tool( name="FooBar DB", func=db_chain.run, description="useful for when you need to answer questions about FooBar. Input should be in the form of a question containing full context" ) ] mrkl = initialize_agent(tools, llm, agent=AgentType.CHAT_ZERO_SHOT_REACT_DESCRIPTION, verbose=True)...
/content/https://python.langchain.com/en/latest/modules/agents/agents/examples/mrkl_chat.html
619cc53cdb76-2
Thought:I now know the final answer. Final Answer: Gigi Hadid is Leo DiCaprio's girlfriend and her current age raised to the 0.43 power is approximately 4.13. > Finished chain. "Gigi Hadid is Leo DiCaprio's girlfriend and her current age raised to the 0.43 power is approximately 4.13." mrkl.run("What is the full name o...
/content/https://python.langchain.com/en/latest/modules/agents/agents/examples/mrkl_chat.html
619cc53cdb76-3
What albums does Alanis Morissette have in the 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. Please ...
/content/https://python.langchain.com/en/latest/modules/agents/agents/examples/mrkl_chat.html
bea49bafd3e5-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...
/content/https://python.langchain.com/en/latest/modules/agents/agents/examples/chat_conversation_agent.html
bea49bafd3e5-1
), ] memory = ConversationBufferMemory(memory_key="chat_history", return_messages=True) llm=ChatOpenAI(temperature=0) agent_chain = initialize_agent(tools, llm, agent=AgentType.CHAT_CONVERSATIONAL_REACT_DESCRIPTION, verbose=True, memory=memory) agent_chain.run(input="hi, i am bob") > Entering new AgentExecutor chain......
/content/https://python.langchain.com/en/latest/modules/agents/agents/examples/chat_conversation_agent.html
bea49bafd3e5-2
{ "action": "Final Answer", "action_input": "Your name is Bob." } > Finished chain. 'Your name is Bob.' agent_chain.run("what are some good dinners to make this week, if i like thai food?") > Entering new AgentExecutor chain... { "action": "Current Search", "action_input": "Thai food dinner recipes" } O...
/content/https://python.langchain.com/en/latest/modules/agents/agents/examples/chat_conversation_agent.html
bea49bafd3e5-3
agent_chain.run(input="tell me the last letter in my name, and also tell me who won the world cup in 1978?") > Entering new AgentExecutor chain... ```json { "action": "Current Search", "action_input": "who won the world cup in 1978" } ``` Observation: Argentina national football team Thought: WARNING:root:Faile...
/content/https://python.langchain.com/en/latest/modules/agents/agents/examples/chat_conversation_agent.html
bea49bafd3e5-4
Thought: WARNING:root:Failed to persist run: HTTPConnectionPool(host='localhost', port=8000): Max retries exceeded with url: /chain-runs (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x13fa9d7f0>: Failed to establish a new connection: [Errno 61] Connection refused')) { "action": "Final...
/content/https://python.langchain.com/en/latest/modules/agents/agents/examples/chat_conversation_agent.html
8f5fee1969aa-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())...
/content/https://python.langchain.com/en/latest/modules/agents/agents/examples/react.html
8f5fee1969aa-1
Action: Search[David Chanoff] Observation: David Chanoff is a noted author of non-fiction work. His work has typically involved collaborations with the principal protagonist of the work concerned. His collaborators have included; Augustus A. White, Joycelyn Elders, Đoàn Văn Toại, William J. Crowe, Ariel Sharon, Kenneth...
/content/https://python.langchain.com/en/latest/modules/agents/agents/examples/react.html
20edeaeb035a-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(...
/content/https://python.langchain.com/en/latest/modules/agents/agents/examples/self_ask_with_search.html
3b774017deb4-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...
/content/https://python.langchain.com/en/latest/modules/agents/agents/examples/mrkl.html
3b774017deb4-1
) ] mrkl = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True) mrkl.run("Who is Leo DiCaprio's girlfriend? What is her current age raised to the 0.43 power?") > Entering new AgentExecutor chain... I need to find out who Leo DiCaprio's girlfriend is and then calculate her age raised ...
/content/https://python.langchain.com/en/latest/modules/agents/agents/examples/mrkl.html
3b774017deb4-2
mrkl.run("What is the full name of the artist who recently released an album called 'The Storm Before the Calm' and are they in the FooBar database? If so, what albums of theirs are in the FooBar database?") > Entering new AgentExecutor chain... I need to find out the artist's full name and then search the FooBar data...
/content/https://python.langchain.com/en/latest/modules/agents/agents/examples/mrkl.html
3b774017deb4-3
sample_rows = connection.execute(command) SELECT "Title" FROM "Album" INNER JOIN "Artist" ON "Album"."ArtistId" = "Artist"."ArtistId" WHERE "Name" = 'Alanis Morissette' LIMIT 5; SQLResult: [('Jagged Little Pill',)] Answer: The albums by Alanis Morissette in the FooBar database are Jagged Little Pill. > Finished chain....
/content/https://python.langchain.com/en/latest/modules/agents/agents/examples/mrkl.html
03c6e2e9dce9-0
.ipynb .pdf SQL Database Agent Contents Initialization Example: describing a table Example: describing a table, recovering from an error Example: running queries Recovering from an error SQL Database Agent# This notebook showcases an agent designed to interact with a sql databases. The agent builds off of SQLDatabase...
/content/https://python.langchain.com/en/latest/modules/agents/toolkits/examples/sql_database.html
03c6e2e9dce9-1
agent_executor.run("Describe the playlisttrack table") > Entering new AgentExecutor chain... Action: list_tables_sql_db Action Input: "" Observation: Artist, Invoice, Playlist, Genre, Album, PlaylistTrack, Track, InvoiceLine, MediaType, Employee, Customer Thought: I should look at the schema of the playlisttrack table ...
/content/https://python.langchain.com/en/latest/modules/agents/toolkits/examples/sql_database.html
03c6e2e9dce9-2
agent_executor.run("Describe the playlistsong table") > Entering new AgentExecutor chain... Action: list_tables_sql_db Action Input: "" Observation: Genre, PlaylistTrack, MediaType, Invoice, InvoiceLine, Track, Playlist, Customer, Album, Employee, Artist Thought: I should look at the schema of the PlaylistSong table Ac...
/content/https://python.langchain.com/en/latest/modules/agents/toolkits/examples/sql_database.html
03c6e2e9dce9-3
1 3402 1 3389 1 3390 Thought: I now know the final answer Final Answer: The PlaylistTrack table contains two columns, PlaylistId and TrackId, which are both integers and are used to link Playlist and Track tables. > Finished chain. 'The PlaylistTrack table contains two columns, PlaylistId and TrackId, which are both in...
/content/https://python.langchain.com/en/latest/modules/agents/toolkits/examples/sql_database.html
03c6e2e9dce9-4
"Email" NVARCHAR(60) NOT NULL, "SupportRepId" INTEGER, PRIMARY KEY ("CustomerId"), FOREIGN KEY("SupportRepId") REFERENCES "Employee" ("EmployeeId") ) SELECT * FROM 'Customer' LIMIT 3; CustomerId FirstName LastName Company Address City State Country PostalCode Phone Fax Email SupportRepId 1 Luís Gonçalves Embraer ...
/content/https://python.langchain.com/en/latest/modules/agents/toolkits/examples/sql_database.html
03c6e2e9dce9-5
PRIMARY KEY ("InvoiceId"), FOREIGN KEY("CustomerId") REFERENCES "Customer" ("CustomerId") ) SELECT * FROM 'Invoice' LIMIT 3; InvoiceId CustomerId InvoiceDate BillingAddress BillingCity BillingState BillingCountry BillingPostalCode Total 1 2 2009-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98...
/content/https://python.langchain.com/en/latest/modules/agents/toolkits/examples/sql_database.html
03c6e2e9dce9-6
Thought: I now know the final answer Final Answer: The customers from the USA spent the most, with a total of $523.06. > Finished chain. 'The customers from the USA spent the most, with a total of $523.06.' agent_executor.run("Show the total number of tracks in each playlist. The Playlist name should be included in the...
/content/https://python.langchain.com/en/latest/modules/agents/toolkits/examples/sql_database.html
03c6e2e9dce9-7
PlaylistId TrackId 1 3402 1 3389 1 3390 Thought: I can use a SELECT statement to get the total number of tracks in each playlist. Action: query_checker_sql_db Action Input: SELECT Playlist.Name, COUNT(PlaylistTrack.TrackId) AS TotalTracks FROM Playlist INNER JOIN PlaylistTrack ON Playlist.PlaylistId = PlaylistTrack.Pla...
/content/https://python.langchain.com/en/latest/modules/agents/toolkits/examples/sql_database.html
03c6e2e9dce9-8
Thought: I now know the final answer. Final Answer: The total number of tracks in each playlist are: '90’s Music' (1477), 'Brazilian Music' (39), 'Classical' (75), 'Classical 101 - Deep Cuts' (25), 'Classical 101 - Next Steps' (25), 'Classical 101 - The Basics' (25), 'Grunge' (15), 'Heavy Metal Classic' (26), 'Music' (...
/content/https://python.langchain.com/en/latest/modules/agents/toolkits/examples/sql_database.html
03c6e2e9dce9-9
Action Input: "Artist, InvoiceLine, Track" Observation: CREATE TABLE "Artist" ( "ArtistId" INTEGER NOT NULL, "Name" NVARCHAR(120), PRIMARY KEY ("ArtistId") ) SELECT * FROM 'Artist' LIMIT 3; ArtistId Name 1 AC/DC 2 Accept 3 Aerosmith CREATE TABLE "Track" ( "TrackId" INTEGER NOT NULL, "Name" NVARCHAR(200) NOT NU...
/content/https://python.langchain.com/en/latest/modules/agents/toolkits/examples/sql_database.html
03c6e2e9dce9-10
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99 3 Fast As a Shark 3 2 1 F. Baltes, S. Kaufman, U. Dirkscneider & W. Hoffman 230619 3990994 0.99 CREATE TABLE "InvoiceLine" ( "InvoiceLineId" INTEGER NOT NULL, "InvoiceId" INTEGER NOT NULL, "TrackId" INTEGER NOT NULL, "UnitPrice" NUMERIC(10, 2) NOT NULL, "Quant...
/content/https://python.langchain.com/en/latest/modules/agents/toolkits/examples/sql_database.html
03c6e2e9dce9-11
Observation: Error: (sqlite3.OperationalError) no such column: Track.ArtistId [SQL: SELECT Artist.Name, SUM(InvoiceLine.Quantity) AS TotalQuantity FROM Artist INNER JOIN Track ON Artist.ArtistId = Track.ArtistId INNER JOIN InvoiceLine ON Track.TrackId = InvoiceLine.TrackId GROUP BY Artist.Name ORDER BY TotalQuantity DE...
/content/https://python.langchain.com/en/latest/modules/agents/toolkits/examples/sql_database.html
03c6e2e9dce9-12
Thought: I now know the final answer. Action: query_sql_db Action Input: SELECT Artist.Name, SUM(InvoiceLine.Quantity) AS TotalQuantity FROM Artist INNER JOIN Album ON Artist.ArtistId = Album.ArtistId INNER JOIN Track ON Album.AlbumId = Track.AlbumId INNER JOIN InvoiceLine ON Track.TrackId = InvoiceLine.TrackId GROUP B...
/content/https://python.langchain.com/en/latest/modules/agents/toolkits/examples/sql_database.html
ef29d9ea4bc2-0
.ipynb .pdf CSV Agent CSV Agent# This notebook shows how to use agents to interact with a csv. It is mostly optimized for question answering. NOTE: this agent calls the Pandas DataFrame agent under the hood, which in turn calls the Python agent, which executes LLM generated Python code - this can be bad if the LLM gene...
/content/https://python.langchain.com/en/latest/modules/agents/toolkits/examples/csv.html
ef29d9ea4bc2-1
agent.run("whats the square root of the average age?") > Entering new AgentExecutor chain... Thought: I need to calculate the average age first Action: python_repl_ast Action Input: df['Age'].mean() Observation: 29.69911764705882 Thought: I can now calculate the square root Action: python_repl_ast Action Input: math.sq...
/content/https://python.langchain.com/en/latest/modules/agents/toolkits/examples/csv.html
ed7a79af929d-0
.ipynb .pdf Natural Language APIs Contents First, import dependencies and load the LLM Next, load the Natural Language API Toolkits Create the Agent Using Auth + Adding more Endpoints Thank you! Natural Language APIs# Natural Language API Toolkits (NLAToolkits) permit LangChain Agents to efficiently plan and combine ...
/content/https://python.langchain.com/en/latest/modules/agents/toolkits/examples/openapi_nla.html
ed7a79af929d-1
Attempting to load an OpenAPI 3.0.1 spec. This may result in degraded performance. Convert your OpenAPI spec to 3.1.* spec for better support. Attempting to load an OpenAPI 3.0.1 spec. This may result in degraded performance. Convert your OpenAPI spec to 3.1.* spec for better support. Attempting to load an OpenAPI 3....
/content/https://python.langchain.com/en/latest/modules/agents/toolkits/examples/openapi_nla.html
ed7a79af929d-2
verbose=True, agent_kwargs={"format_instructions":openapi_format_instructions}) mrkl.run("I have an end of year party for my Italian class and have to buy some Italian clothes for it") > Entering new AgentExecutor chain... I need to find out what kind of Italian clothes are available Action: Open_AI_Klarna_product_Api...
/content/https://python.langchain.com/en/latest/modules/agents/toolkits/examples/openapi_nla.html
ed7a79af929d-3
Since each NLATool exposes a concisee natural language interface to its wrapped API, the top level conversational agent has an easier job incorporating each endpoint to satisfy a user’s request. Adding the Spoonacular endpoints. Go to the Spoonacular API Console and make a free account. Click on Profile and copy your A...
/content/https://python.langchain.com/en/latest/modules/agents/toolkits/examples/openapi_nla.html
ed7a79af929d-4
Unsupported APIPropertyLocation "header" for parameter Content-Type. Valid values are ['path', 'query'] Ignoring optional parameter Unsupported APIPropertyLocation "header" for parameter Accept. Valid values are ['path', 'query'] Ignoring optional parameter Unsupported APIPropertyLocation "header" for parameter Content...
/content/https://python.langchain.com/en/latest/modules/agents/toolkits/examples/openapi_nla.html
ed7a79af929d-5
Unsupported APIPropertyLocation "header" for parameter Accept. Valid values are ['path', 'query'] Ignoring optional parameter Unsupported APIPropertyLocation "header" for parameter Accept. Valid values are ['path', 'query'] Ignoring optional parameter Unsupported APIPropertyLocation "header" for parameter Accept. Valid...
/content/https://python.langchain.com/en/latest/modules/agents/toolkits/examples/openapi_nla.html
ed7a79af929d-6
) mrkl.run(user_input) > Entering new AgentExecutor chain... I need to find a recipe and an outfit that is Italian-themed. Action: spoonacular_API.searchRecipes Action Input: Italian Observation: The API response contains 10 Italian recipes, including Turkey Tomato Cheese Pizza, Broccolini Quinoa Pilaf, Bruschetta Sty...
/content/https://python.langchain.com/en/latest/modules/agents/toolkits/examples/openapi_nla.html
ed7a79af929d-7
Thought: I now know the final answer. Final Answer: To present for your Italian language class, you could wear an Italian Gold Sparkle Perfectina Necklace - Gold, an Italian Design Miami Cuban Link Chain Necklace - Gold, or an Italian Gold Miami Cuban Link Chain Necklace - Gold. For a recipe, you could make Turkey Toma...
/content/https://python.langchain.com/en/latest/modules/agents/toolkits/examples/openapi_nla.html
ed7a79af929d-8
"In Italian, you can say 'Buon appetito' to someone to wish them to enjoy their meal. This phrase is commonly used in Italy when someone is about to eat, often at the beginning of a meal. It's similar to saying 'Bon appétit' in French or 'Guten Appetit' in German." previous OpenAPI agents next Pandas Dataframe Agent C...
/content/https://python.langchain.com/en/latest/modules/agents/toolkits/examples/openapi_nla.html
58136f950fdf-0
.ipynb .pdf Python Agent Contents Fibonacci Example Training neural net Python Agent# This notebook showcases an agent designed to write and execute python code to answer a question. from langchain.agents.agent_toolkits import create_python_agent from langchain.tools.python.tool import PythonREPLTool from langchain.p...
/content/https://python.langchain.com/en/latest/modules/agents/toolkits/examples/python.html
58136f950fdf-1
Return prediction for x = 5""") > Entering new AgentExecutor chain... I need to write a neural network in PyTorch and train it on the given data. Action: Python REPL Action Input: import torch # Define the model model = torch.nn.Sequential( torch.nn.Linear(1, 1) ) # Define the loss loss_fn = torch.nn.MSELoss() # ...
/content/https://python.langchain.com/en/latest/modules/agents/toolkits/examples/python.html
58136f950fdf-2
Epoch 900: loss = 0.0000 Epoch 1000: loss = 0.0000 Thought: I now know the final answer Final Answer: The prediction for x = 5 is 10.0. > Finished chain. 'The prediction for x = 5 is 10.0.' previous PowerBI Dataset Agent next SQL Database Agent Contents Fibonacci Example Training neural net By Harrison Chase ...
/content/https://python.langchain.com/en/latest/modules/agents/toolkits/examples/python.html