id
stringlengths
14
16
source
stringlengths
49
117
text
stringlengths
16
2.73k
90a0cca0ac7e-21
https://python.langchain.com/en/latest/modules/agents/tools/examples/google_serper.html
'longitude': -73.96473379999999, 'thumbnailUrl': 'https://lh5.googleusercontent.com/p/AF1QipPDGchokDvppoLfmVEo6X_bWd3Fz0HyxIHTEe9V=w92-h92-n-k-no', 'rating': 4.5, 'ratingCount': 276, 'category': 'Italian'}, {'position': 4, 'title': 'Luna Rossa...
90a0cca0ac7e-22
https://python.langchain.com/en/latest/modules/agents/tools/examples/google_serper.html
'latitude': 40.772124999999996, 'longitude': -73.965012, 'thumbnailUrl': 'https://lh5.googleusercontent.com/p/AF1QipNrX19G0NVdtDyMovCQ-M-m0c_gLmIxrWDQAAbz=w92-h92-n-k-no', 'rating': 4.5, 'ratingCount': 176, 'category': 'Italian'}, {'position':...
90a0cca0ac7e-23
https://python.langchain.com/en/latest/modules/agents/tools/examples/google_serper.html
'title': 'Pinocchio Restaurant', 'address': '300 E 92nd St', 'latitude': 40.781453299999995, 'longitude': -73.9486788, 'thumbnailUrl': 'https://lh5.googleusercontent.com/p/AF1QipNtxlIyEEJHtDtFtTR9nB38S8A2VyMu-mVVz72A=w92-h92-n-k-no', 'rating': 4.5, ...
89efac01e0d0-0
https://python.langchain.com/en/latest/modules/agents/tools/examples/wolfram_alpha.html
.ipynb .pdf Wolfram Alpha Wolfram Alpha# This notebook goes over how to use the wolfram alpha component. First, you need to set up your Wolfram Alpha developer account and get your APP ID: Go to wolfram alpha and sign up for a developer account here Create an app and get your APP ID pip install wolframalpha Then we wil...
2717a60edcfe-0
https://python.langchain.com/en/latest/modules/agents/tools/examples/bing_search.html
.ipynb .pdf Bing Search Contents Number of results Metadata Results Bing Search# This notebook goes over how to use the bing search component. First, you need to set up the proper API keys and environment variables. To set it up, follow the instructions found here. Then we will need to set some environment variables....
2717a60edcfe-1
https://python.langchain.com/en/latest/modules/agents/tools/examples/bing_search.html
'Thanks to the flexibility of <b>Python</b> and the powerful ecosystem of packages, the Azure CLI supports features such as autocompletion (in shells that support it), persistent credentials, JMESPath result parsing, lazy initialization, network-less unit tests, and more. Building an open-source and cross-platform Azur...
2717a60edcfe-2
https://python.langchain.com/en/latest/modules/agents/tools/examples/bing_search.html
and modules, see The <b>Python</b> Standard ... <b>Python</b> is a general-purpose, versatile, and powerful programming language. It&#39;s a great first language because <b>Python</b> code is concise and easy to read. Whatever you want to do, <b>python</b> can do it. From web development to machine learning to data sci...
2717a60edcfe-3
https://python.langchain.com/en/latest/modules/agents/tools/examples/bing_search.html
Number of results# You can use the k parameter to set the number of results search = BingSearchAPIWrapper(k=1) search.run("python") 'Thanks to the flexibility of <b>Python</b> and the powerful ecosystem of packages, the Azure CLI supports features such as autocompletion (in shells that support it), persistent credentia...
2717a60edcfe-4
https://python.langchain.com/en/latest/modules/agents/tools/examples/bing_search.html
{'snippet': '<b>Apples</b> boast many vitamins and minerals, though not in high amounts. However, <b>apples</b> are usually a good source of vitamin C. Vitamin C. Also called ascorbic acid, this vitamin is a common ...', 'title': 'Apples 101: Nutrition Facts and Health Benefits', 'link': 'https://www.healthline.com...
df327ff5c32c-0
https://python.langchain.com/en/latest/modules/agents/tools/examples/gradio_tools.html
.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...
df327ff5c32c-1
https://python.langchain.com/en/latest/modules/agents/tools/examples/gradio_tools.html
from gradio_tools.tools import (StableDiffusionTool, ImageCaptioningTool, StableDiffusionPromptGeneratorTool, TextToVideoTool) from langchain.memory import ConversationBufferMemory llm = OpenAI(temperature=0) memory = ConversationBufferMemory(memory_key="chat_history") tools = [StableDif...
df327ff5c32c-2
https://python.langchain.com/en/latest/modules/agents/tools/examples/gradio_tools.html
Action Input: A dog riding a skateboard, digital painting, artstation, concept art, smooth, sharp focus, illustration, art by artgerm and greg rutkowski and alphonse mucha Job Status: Status.STARTING eta: None Job Status: Status.PROCESSING eta: None Observation: /Users/harrisonchase/workplace/langchain/docs/modules/age...
df327ff5c32c-3
https://python.langchain.com/en/latest/modules/agents/tools/examples/gradio_tools.html
Observation: /var/folders/bm/ylzhm36n075cslb9fvvbgq640000gn/T/tmp5snj_nmzf20_cb3m.mp4 Thought: Do I need to use a tool? No AI: Here is a video of a painting of a dog sitting on a skateboard. > Finished chain. previous Google Serper API next GraphQL tool Contents Using a tool Using within an agent By Harrison Chase ...
69045b8961ee-0
https://python.langchain.com/en/latest/modules/agents/tools/examples/youtube.html
.ipynb .pdf YouTubeSearchTool YouTubeSearchTool# This notebook shows how to use a tool to search YouTube Adapted from venuv/langchain_yt_tools #! pip install youtube_search from langchain.tools import YouTubeSearchTool tool = YouTubeSearchTool() tool.run("lex friedman") "['/watch?v=VcVfceTsD0A&pp=ygUMbGV4IGZyaWVkbWFu',...
5a54175b6a7a-0
https://python.langchain.com/en/latest/modules/agents/tools/examples/sceneXplain.html
.ipynb .pdf SceneXplain Contents Usage in an Agent SceneXplain# SceneXplain is an ImageCaptioning service accessible through the SceneXplain Tool. To use this tool, you’ll need to make an account and fetch your API Token from the website. Then you can instantiate the tool. import os os.environ["SCENEX_API_KEY"] = "<Y...
5a54175b6a7a-1
https://python.langchain.com/en/latest/modules/agents/tools/examples/sceneXplain.html
Observation: In a charmingly whimsical scene, a young girl is seen braving the rain alongside her furry companion, the lovable Totoro. The two are depicted standing on a bustling street corner, where they are sheltered from the rain by a bright yellow umbrella. The girl, dressed in a cheerful yellow frock, holds onto t...
5a54175b6a7a-2
https://python.langchain.com/en/latest/modules/agents/tools/examples/sceneXplain.html
Last updated on Jun 04, 2023.
f315fc84fc8e-0
https://python.langchain.com/en/latest/modules/agents/tools/examples/openweathermap.html
.ipynb .pdf OpenWeatherMap API Contents Use the wrapper Use the tool OpenWeatherMap API# This notebook goes over how to use the OpenWeatherMap component to fetch weather information. First, you need to sign up for an OpenWeatherMap API key: Go to OpenWeatherMap and sign up for an API key here pip install pyowm Then w...
f315fc84fc8e-1
https://python.langchain.com/en/latest/modules/agents/tools/examples/openweathermap.html
agent_chain.run("What's the weather like in London?") > Entering new AgentExecutor chain... I need to find out the current weather in London. Action: OpenWeatherMap Action Input: London,GB Observation: In London,GB, the current weather is as follows: Detailed status: broken clouds Wind speed: 2.57 m/s, direction: 240°...
f0b3e582178c-0
https://python.langchain.com/en/latest/modules/agents/tools/examples/ifttt.html
.ipynb .pdf IFTTT WebHooks Contents Creating a webhook Configuring the “If This” Configuring the “Then That” Finishing up IFTTT WebHooks# This notebook shows how to use IFTTT Webhooks. From https://github.com/SidU/teams-langchain-js/wiki/Connecting-IFTTT-Services. Creating a webhook# Go to https://ifttt.com/create Co...
f0b3e582178c-1
https://python.langchain.com/en/latest/modules/agents/tools/examples/ifttt.html
Finishing up# To get your webhook URL go to https://ifttt.com/maker_webhooks/settings Copy the IFTTT key value from there. The URL is of the form https://maker.ifttt.com/use/YOUR_IFTTT_KEY. Grab the YOUR_IFTTT_KEY value. from langchain.tools.ifttt import IFTTTWebhook import os key = os.environ["IFTTTKey"] url = f"https...
ea532d04ee70-0
https://python.langchain.com/en/latest/modules/agents/tools/examples/metaphor_search.html
.ipynb .pdf Metaphor Search Contents Metaphor Search Call the API Use Metaphor as a tool Metaphor Search# This notebook goes over how to use Metaphor search. First, you need to set up the proper API keys and environment variables. Request an API key [here](Sign up for early access here). Then enter your API key as an...
ea532d04ee70-1
https://python.langchain.com/en/latest/modules/agents/tools/examples/metaphor_search.html
{'results': [{'url': 'https://www.anthropic.com/index/core-views-on-ai-safety', 'title': 'Core Views on AI Safety: When, Why, What, and How', 'dateCreated': '2023-03-08', 'author': None, 'score': 0.1998831331729889}, {'url': 'https://aisafety.wordpress.com/', 'title': 'Extinction Risk from Artificial Intelligence', 'da...
ea532d04ee70-2
https://python.langchain.com/en/latest/modules/agents/tools/examples/metaphor_search.html
'2023-02-24', 'author': 'Authors', 'score': 0.18665121495723724}, {'url': 'https://waitbutwhy.com/2015/01/artificial-intelligence-revolution-1.html', 'title': 'The Artificial Intelligence Revolution: Part 1 - Wait But Why', 'dateCreated': '2015-01-22', 'author': 'Tim Urban', 'score': 0.18604731559753418}, {'url': 'http...
ea532d04ee70-3
https://python.langchain.com/en/latest/modules/agents/tools/examples/metaphor_search.html
[{'title': 'Core Views on AI Safety: When, Why, What, and How', 'url': 'https://www.anthropic.com/index/core-views-on-ai-safety', 'author': None, 'date_created': '2023-03-08'}, {'title': 'Extinction Risk from Artificial Intelligence', 'url': 'https://aisafety.wordpress.com/', 'author': None, 'date_created'...
ea532d04ee70-4
https://python.langchain.com/en/latest/modules/agents/tools/examples/metaphor_search.html
{'title': 'The Artificial Intelligence Revolution: Part 1 - Wait But Why', 'url': 'https://waitbutwhy.com/2015/01/artificial-intelligence-revolution-1.html', 'author': 'Tim Urban', 'date_created': '2015-01-22'}, {'title': 'Anthropic: Core Views on AI Safety: When, Why, What, and How - EA Forum', 'url': 'https:...
ea532d04ee70-5
https://python.langchain.com/en/latest/modules/agents/tools/examples/metaphor_search.html
tools = toolkit.get_tools() tools_by_name = {tool.name: tool for tool in tools} print(tools_by_name.keys()) navigate_tool = tools_by_name["navigate_browser"] extract_text = tools_by_name["extract_text"] from langchain.agents import initialize_agent, AgentType from langchain.chat_models import ChatOpenAI from langchain....
ea532d04ee70-6
https://python.langchain.com/en/latest/modules/agents/tools/examples/metaphor_search.html
'I need to navigate to the URL provided in the search results to find the tweet.' previous IFTTT WebHooks next OpenWeatherMap API Contents Metaphor Search Call the API Use Metaphor as a tool By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 04, 2023.
48d01c26c3ce-0
https://python.langchain.com/en/latest/modules/agents/tools/examples/serpapi.html
.ipynb .pdf SerpAPI Contents Custom Parameters SerpAPI# This notebook goes over how to use the SerpAPI component to search the web. from langchain.utilities import SerpAPIWrapper search = SerpAPIWrapper() search.run("Obama's first name?") 'Barack Hussein Obama II' Custom Parameters# You can also customize the SerpAPI...
48d01c26c3ce-1
https://python.langchain.com/en/latest/modules/agents/tools/examples/serpapi.html
description="A Python shell. Use this to execute python commands. Input should be a valid python command. If you want to see the output of a value, you should print it out with `print(...)`.", func=search.run, ) previous SearxNG Search API next Twilio Contents Custom Parameters By Harrison Chase © Co...
a61809ec04a1-0
https://python.langchain.com/en/latest/modules/agents/tools/examples/human_tools.html
.ipynb .pdf Human as a tool Contents Configuring the Input Function Human as a tool# Human are AGI so they can certainly be used as a tool to help out AI agent when it is confused. from langchain.chat_models import ChatOpenAI from langchain.llms import OpenAI from langchain.agents import load_tools, initialize_agent ...
a61809ec04a1-1
https://python.langchain.com/en/latest/modules/agents/tools/examples/human_tools.html
print("Insert your text. Enter 'q' or press Ctrl-D (or Ctrl-Z on Windows) to end.") contents = [] while True: try: line = input() except EOFError: break if line == "q": break contents.append(line) return "\n".join(contents) # You can modify...
a61809ec04a1-2
https://python.langchain.com/en/latest/modules/agents/tools/examples/human_tools.html
Action: DuckDuckGo Search Action Input: "Who said 'Veni, vidi, vici'?"
a61809ec04a1-3
https://python.langchain.com/en/latest/modules/agents/tools/examples/human_tools.html
Observation: Updated on September 06, 2019. "Veni, vidi, vici" is a famous phrase said to have been spoken by the Roman Emperor Julius Caesar (100-44 BCE) in a bit of stylish bragging that impressed many of the writers of his day and beyond. The phrase means roughly "I came, I saw, I conquered" and it could be pronounc...
a61809ec04a1-4
https://python.langchain.com/en/latest/modules/agents/tools/examples/human_tools.html
the phrase so powerful. Caesar was a gifted writer, and the phrase makes use of Latin grammar to ... One of the best known and most frequently quoted Latin expression, veni, vidi, vici may be found hundreds of times throughout the centuries used as an expression of triumph. The words are said to have been used by Caesa...
a61809ec04a1-5
https://python.langchain.com/en/latest/modules/agents/tools/examples/human_tools.html
Thought:I now know the final answer Final Answer: Julius Caesar said the quote "Veni, vidi, vici" which means "I came, I saw, I conquered". > Finished chain. 'Julius Caesar said the quote "Veni, vidi, vici" which means "I came, I saw, I conquered".' previous HuggingFace Tools next IFTTT WebHooks Contents Configurin...
eb6cc50b52c7-0
https://python.langchain.com/en/latest/modules/agents/tools/examples/huggingface_tools.html
.ipynb .pdf HuggingFace Tools HuggingFace Tools# Huggingface Tools supporting text I/O can be loaded directly using the load_huggingface_tool function. # Requires transformers>=4.29.0 and huggingface_hub>=0.14.1 !pip install --upgrade transformers huggingface_hub > /dev/null from langchain.agents import load_huggingfac...
7f6c15c95b56-0
https://python.langchain.com/en/latest/modules/agents/tools/examples/arxiv.html
.ipynb .pdf ArXiv API Tool Contents The ArXiv API Wrapper ArXiv API Tool# This notebook goes over how to use the arxiv component. First, you need to install arxiv python package. !pip install arxiv from langchain.chat_models import ChatOpenAI from langchain.agents import load_tools, initialize_agent, AgentType llm = ...
7f6c15c95b56-1
https://python.langchain.com/en/latest/modules/agents/tools/examples/arxiv.html
Final Answer: The paper 1605.08386 is about heat-bath random walks with Markov bases on graphs of lattice points. > Finished chain. 'The paper 1605.08386 is about heat-bath random walks with Markov bases on graphs of lattice points.' The ArXiv API Wrapper# The tool wraps the API Wrapper. Below, we can explore some of t...
7f6c15c95b56-2
https://python.langchain.com/en/latest/modules/agents/tools/examples/arxiv.html
'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...
7f6c15c95b56-3
https://python.langchain.com/en/latest/modules/agents/tools/examples/arxiv.html
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 AWS Lambda API Contents The ArXiv API Wrapper By Harrison Chase © Copyright 2023, H...
e559d7e2f081-0
https://python.langchain.com/en/latest/modules/agents/tools/examples/chatgpt_plugins.html
.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...
e559d7e2f081-1
https://python.langchain.com/en/latest/modules/agents/tools/examples/chatgpt_plugins.html
OpenAPI Spec: {'openapi': '3.0.1', 'info': {'version': 'v0', 'title': 'Open AI Klarna product Api'}, 'servers': [{'url': 'https://www.klarna.com/us/shopping'}], 'tags': [{'name': 'open-ai-product-endpoint', 'description': 'Open AI Product Endpoint. Query for products.'}], 'paths': {'/public/openai/v0/products': {'get':...
e559d7e2f081-2
https://python.langchain.com/en/latest/modules/agents/tools/examples/chatgpt_plugins.html
{'products': {'type': 'array', 'items': {'$ref': '#/components/schemas/Product'}}}, 'title': 'ProductResponse'}}}}
e559d7e2f081-3
https://python.langchain.com/en/latest/modules/agents/tools/examples/chatgpt_plugins.html
Thought:I need to use the Klarna Shopping API to search for t shirts. Action: requests_get Action Input: https://www.klarna.com/us/shopping/public/openai/v0/products?q=t%20shirts
e559d7e2f081-4
https://python.langchain.com/en/latest/modules/agents/tools/examples/chatgpt_plugins.html
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...
e559d7e2f081-5
https://python.langchain.com/en/latest/modules/agents/tools/examples/chatgpt_plugins.html
3-pack","url":"https://www.klarna.com/us/shopping/pl/cl10001/3202640533/Clothing/adidas-Comfort-T-shirts-Men-s-3-pack/?utm_source=openai","price":"$14.99","attributes":["Material:Cotton","Target Group:Man","Color:White,Black","Neckline:Round"]}]}
e559d7e2f081-6
https://python.langchain.com/en/latest/modules/agents/tools/examples/chatgpt_plugins.html
Thought:The available t shirts in Klarna are Lacoste Men's Pack of Plain T-Shirts, Hanes Men's Ultimate 6pk. Crewneck T-Shirts, Nike Boy's Jordan Stretch T-shirts, Polo Classic Fit Cotton V-Neck T-Shirts 3-Pack, and adidas Comfort T-shirts Men's 3-pack. Final Answer: The available t shirts in Klarna are Lacoste Men's P...
feff7a739661-0
https://python.langchain.com/en/latest/modules/agents/agents/custom_llm_agent.html
.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...
feff7a739661-1
https://python.langchain.com/en/latest/modules/agents/agents/custom_llm_agent.html
from langchain import OpenAI, SerpAPIWrapper, LLMChain from typing import List, Union from langchain.schema import AgentAction, AgentFinish import re Set up tool# Set up any tools the agent may want to use. This may be necessary to put in the prompt (so that the agent knows to use these tools). # Define which tools the...
feff7a739661-2
https://python.langchain.com/en/latest/modules/agents/agents/custom_llm_agent.html
# Set up a prompt template class CustomPromptTemplate(StringPromptTemplate): # The template to use template: str # The list of tools available tools: List[Tool] def format(self, **kwargs) -> str: # Get the intermediate steps (AgentAction, Observation tuples) # Format them in a p...
feff7a739661-3
https://python.langchain.com/en/latest/modules/agents/agents/custom_llm_agent.html
# Check if agent should finish if "Final Answer:" in llm_output: return AgentFinish( # 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_...
feff7a739661-4
https://python.langchain.com/en/latest/modules/agents/agents/custom_llm_agent.html
agent = LLMSingleActionAgent( llm_chain=llm_chain, output_parser=output_parser, stop=["\nObservation:"], allowed_tools=tool_names ) Use the Agent# Now we can use it! agent_executor = AgentExecutor.from_agent_and_tools(agent=agent, tools=tools, verbose=True) agent_executor.run("How many people live in ...
feff7a739661-5
https://python.langchain.com/en/latest/modules/agents/agents/custom_llm_agent.html
... (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 lots of "Arg"s Previous conversation history: {history} New question: {input} {...
feff7a739661-6
https://python.langchain.com/en/latest/modules/agents/agents/custom_llm_agent.html
Final Answer: Arrr, there be 38,658,314 people livin' in Canada as of 2023! > 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...
290a3eb9a134-0
https://python.langchain.com/en/latest/modules/agents/agents/custom_llm_chat_agent.html
.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...
290a3eb9a134-1
https://python.langchain.com/en/latest/modules/agents/agents/custom_llm_chat_agent.html
from langchain.agents import Tool, AgentExecutor, LLMSingleActionAgent, AgentOutputParser from langchain.prompts import BaseChatPromptTemplate from langchain import SerpAPIWrapper, LLMChain from langchain.chat_models import ChatOpenAI from typing import List, Union from langchain.schema import AgentAction, AgentFinish,...
290a3eb9a134-2
https://python.langchain.com/en/latest/modules/agents/agents/custom_llm_chat_agent.html
... (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 These were previous tasks you completed: Begin! Question: {input} {agent_scratchpad}""" # Set up a prompt template class CustomPromptTemplate(BaseChatP...
290a3eb9a134-3
https://python.langchain.com/en/latest/modules/agents/agents/custom_llm_chat_agent.html
The output parser is responsible for parsing the LLM output into AgentAction and AgentFinish. This usually depends heavily on the prompt used. This is where you can change the parsing to do retries, handle whitespace, etc class CustomOutputParser(AgentOutputParser): def parse(self, llm_output: str) -> Union[Ag...
290a3eb9a134-4
https://python.langchain.com/en/latest/modules/agents/agents/custom_llm_chat_agent.html
This depends heavily on the prompt and model you are using. Generally, you want this to be whatever token you use in the prompt to denote the start of an Observation (otherwise, the LLM may hallucinate an observation for you). Set up the Agent# We can now combine everything to set up our agent # LLM chain consisting of...
290a3eb9a134-5
https://python.langchain.com/en/latest/modules/agents/agents/custom_llm_chat_agent.html
By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 04, 2023.
a112f241bce3-0
https://python.langchain.com/en/latest/modules/agents/agents/custom_mrkl_agent.html
.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...
a112f241bce3-1
https://python.langchain.com/en/latest/modules/agents/agents/custom_mrkl_agent.html
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 from langchain import OpenAI, SerpAPIWrapper, LLMChain search = SerpAPIWrapper() tools = [ Tool( name = "Sea...
a112f241bce3-2
https://python.langchain.com/en/latest/modules/agents/agents/custom_mrkl_agent.html
Begin! Remember to speak as a pirate when giving your final answer. Use lots of "Args" Question: {input} {agent_scratchpad} Note that we are able to feed agents a self-defined prompt template, i.e. not restricted to the prompt generated by the create_prompt function, assuming it meets the agent’s requirements. For exam...
a112f241bce3-3
https://python.langchain.com/en/latest/modules/agents/agents/custom_mrkl_agent.html
suffix = """When answering, you MUST speak in the following language: {language}. Question: {input} {agent_scratchpad}""" prompt = ZeroShotAgent.create_prompt( tools, prefix=prefix, suffix=suffix, input_variables=["input", "language", "agent_scratchpad"] ) llm_chain = LLMChain(llm=OpenAI(temperature=...
a112f241bce3-4
https://python.langchain.com/en/latest/modules/agents/agents/custom_mrkl_agent.html
'La popolazione del Canada è stata stimata a 39.566.248 il 1° gennaio 2023, dopo un record di crescita demografica di 1.050.110 persone dal 1° gennaio 2022 al 1° gennaio 2023.' previous Custom LLM Agent (with a ChatModel) next Custom MultiAction Agent Contents Custom LLMChain Multiple inputs By Harrison Chase ...
09f9d091aff1-0
https://python.langchain.com/en/latest/modules/agents/agents/custom_agent.html
.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...
09f9d091aff1-1
https://python.langchain.com/en/latest/modules/agents/agents/custom_agent.html
along with observations **kwargs: User inputs. Returns: Action specifying what tool to use. """ return AgentAction(tool="Search", tool_input=kwargs["input"], log="") agent = FakeAgent() agent_executor = AgentExecutor.from_agent_and_tools(agent=agent, tools=tools, verbose=...
8a4644394d37-0
https://python.langchain.com/en/latest/modules/agents/agents/custom_agent_with_tool_retrieval.html
.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 ...
8a4644394d37-1
https://python.langchain.com/en/latest/modules/agents/agents/custom_agent_with_tool_retrieval.html
name=f"foo-{i}", func=fake_func, description=f"a silly function that you can use to get more information about the number {i}" ) for i in range(99) ] ALL_TOOLS = [search_tool] + fake_tools Tool Retriever# We will use a vectorstore to create embeddings for each tool description. Then, for an i...
8a4644394d37-2
https://python.langchain.com/en/latest/modules/agents/agents/custom_agent_with_tool_retrieval.html
Tool(name='foo-95', description='a silly function that you can use to get more information about the number 95', 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-12', ...
8a4644394d37-3
https://python.langchain.com/en/latest/modules/agents/agents/custom_agent_with_tool_retrieval.html
Tool(name='foo-14', description='a silly function that you can use to get more information about the number 14', 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-11', ...
8a4644394d37-4
https://python.langchain.com/en/latest/modules/agents/agents/custom_agent_with_tool_retrieval.html
# Set up a prompt template class CustomPromptTemplate(StringPromptTemplate): # The template to use template: str ############## NEW ###################### # The list of tools available tools_getter: Callable def format(self, **kwargs) -> str: # Get the intermediate steps (AgentActio...
8a4644394d37-5
https://python.langchain.com/en/latest/modules/agents/agents/custom_agent_with_tool_retrieval.html
# Check if agent should finish if "Final Answer:" in llm_output: return AgentFinish( # 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_...
8a4644394d37-6
https://python.langchain.com/en/latest/modules/agents/agents/custom_agent_with_tool_retrieval.html
agent_executor = AgentExecutor.from_agent_and_tools(agent=agent, tools=tools, verbose=True) 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 p...
f9356a09366a-0
https://python.langchain.com/en/latest/modules/agents/agents/custom_multi_action_agent.html
.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 ...
f9356a09366a-1
https://python.langchain.com/en/latest/modules/agents/agents/custom_multi_action_agent.html
AgentAction(tool="Search", tool_input=kwargs["input"], log=""), AgentAction(tool="RandomWord", tool_input=kwargs["input"], log=""), ] else: return AgentFinish(return_values={"output": "bar"}, log="") async def aplan( self, intermediate_steps: List[Tuple[AgentA...
0b6e50eb9bbc-0
https://python.langchain.com/en/latest/modules/agents/agents/agent_types.html
.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...
0b6e50eb9bbc-1
https://python.langchain.com/en/latest/modules/agents/agents/agent_types.html
Last updated on Jun 04, 2023.
0fc7bfd99b75-0
https://python.langchain.com/en/latest/modules/agents/agents/examples/structured_chat.html
.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...
0fc7bfd99b75-1
https://python.langchain.com/en/latest/modules/agents/agents/examples/structured_chat.html
"action": "Final Answer", "action_input": "Hello Erica, how can I assist you today?" } ``` > Finished chain. Hello Erica, how can I assist you today? response = await agent_chain.arun(input="Don't need help really just chatting.") print(response) > Entering new AgentExecutor chain... > Finished chain. I'm here to cha...
0fc7bfd99b75-2
https://python.langchain.com/en/latest/modules/agents/agents/examples/structured_chat.html
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 improvements to o...
0fc7bfd99b75-3
https://python.langchain.com/en/latest/modules/agents/agents/examples/structured_chat.html
and is moderately technical.
0fc7bfd99b75-4
https://python.langchain.com/en/latest/modules/agents/agents/examples/structured_chat.html
💡 TL;DR: We’ve introduced a new abstraction and a new document Retriever to facilitate the post-processing of retrieved documents. Specifically, the new abstraction makes it easy to take a set of retrieved documents and extract from them Apr 20, 2023 3 min read Autonomous Agents & Agent Simulations Over the past two w...
0fc7bfd99b75-5
https://python.langchain.com/en/latest/modules/agents/agents/examples/structured_chat.html
Originally we designed LangChain.js to run in Node.js, which is the Apr 11, 2023 3 min read LangChain x Supabase Supabase is holding an AI Hackathon this week. Here at LangChain we are big fans of both Supabase and hackathons, so we thought this would be a perfect time to highlight the multiple ways you can use LangCha...
0fc7bfd99b75-6
https://python.langchain.com/en/latest/modules/agents/agents/examples/structured_chat.html
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...
0fc7bfd99b75-7
https://python.langchain.com/en/latest/modules/agents/agents/examples/structured_chat.html
OpenAI/evals - focused on evaluating OpenAI models. Mar 14, 2023 3 min read LLMs and SQL Francisco Ingham and Jon Luo are two of the community members leading the change on the SQL integrations. We’re really excited to write this blog post with them going over all the tips and tricks they’ve learned doing so. We’re eve...
0fc7bfd99b75-8
https://python.langchain.com/en/latest/modules/agents/agents/examples/structured_chat.html
Authors: Parth Asawa (pgasawa@), Ayushi Batwara (ayushi.batwara@), Jason Mar 8, 2023 4 min read Prompt Selectors One common complaint we've heard is that the default prompt templates do not work equally well for all models. This became especially pronounced this past week when OpenAI released a ChatGPT API. This new AP...
0fc7bfd99b75-9
https://python.langchain.com/en/latest/modules/agents/agents/examples/structured_chat.html
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...
0fc7bfd99b75-10
https://python.langchain.com/en/latest/modules/agents/agents/examples/structured_chat.html
} ``` Observation: Navigating to https://xkcd.com/ returned status code 200 Thought:I can extract the latest comic title and alt text using CSS selectors. Action: ``` { "action": "get_elements", "action_input": { "selector": "#ctitle, #comic img", "attributes": ["alt", "src"] } } ``` Observation: [{"alt"...
0fc7bfd99b75-11
https://python.langchain.com/en/latest/modules/agents/agents/examples/structured_chat.html
Hi Erica! How can I assist you today? response = await agent_chain.arun(input="whats my name?") print(response) > Entering new AgentExecutor chain... Your name is Erica. > Finished chain. Your name is Erica. previous Self Ask With Search next Toolkits Contents Initialize Tools Adding in memory By Harrison Chase ...
d2958e41e08b-0
https://python.langchain.com/en/latest/modules/agents/agents/examples/self_ask_with_search.html
.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(...
7626c405342e-0
https://python.langchain.com/en/latest/modules/agents/agents/examples/mrkl_chat.html
.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...
7626c405342e-1
https://python.langchain.com/en/latest/modules/agents/agents/examples/mrkl_chat.html
mrkl.run("Who is Leo DiCaprio's girlfriend? What is her current age raised to the 0.43 power?") > Entering new AgentExecutor chain... Thought: The first question requires a search, while the second question requires a calculator. Action: ``` { "action": "Search", "action_input": "Leo DiCaprio girlfriend" } ``` Obse...
7626c405342e-2
https://python.langchain.com/en/latest/modules/agents/agents/examples/mrkl_chat.html
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... Question: What is the full name of the artist who recently released an alb...
7626c405342e-3
https://python.langchain.com/en/latest/modules/agents/agents/examples/mrkl_chat.html
SELECT "Title" FROM "Album" WHERE "ArtistId" IN (SELECT "ArtistId" FROM "Artist" WHERE "Name" = 'Alanis Morissette') LIMIT 5; SQLResult: [('Jagged Little Pill',)] Answer: Alanis Morissette has the album Jagged Little Pill in the database. > Finished chain. Observation: Alanis Morissette has the album Jagged Little Pil...
8b36b792a09c-0
https://python.langchain.com/en/latest/modules/agents/agents/examples/react.html
.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())...
8b36b792a09c-1
https://python.langchain.com/en/latest/modules/agents/agents/examples/react.html
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 Good and Felix Zandman. He ha...
209ac4e27a65-0
https://python.langchain.com/en/latest/modules/agents/agents/examples/chat_conversation_agent.html
.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...
209ac4e27a65-1
https://python.langchain.com/en/latest/modules/agents/agents/examples/chat_conversation_agent.html
"action_input": "Hello Bob! How can I assist you today?" } > Finished chain. 'Hello Bob! How can I assist you today?' agent_chain.run(input="what's my name?") > Entering new AgentExecutor chain... { "action": "Final Answer", "action_input": "Your name is Bob." } > Finished chain. 'Your name is Bob.' agent_chain...