id stringlengths 14 16 | text stringlengths 36 2.73k | source stringlengths 49 117 |
|---|---|---|
24a4737753c1-5 | 'link': 'https://finance.yahoo.com/quote/AAPL',
'snippet': 'Find the latest Apple Inc. (AAPL) stock quote, '
'history, news and other vital information to help '
'you with your stock trading and investing.',
'position': 6}],
'peopleAlsoAsk':... | https://python.langchain.com/en/latest/modules/agents/tools/examples/google_serper.html |
24a4737753c1-6 | 'iPad, Mac, iPod, Apple Watch, and\n'
'Apple TV.',
'title': 'Apple Inc Company Profile - Apple Inc Overview - '
'GlobalData',
'link': 'https://www.globaldata.com/company-profile/apple-inc/'},
{'questio... | https://python.langchain.com/en/latest/modules/agents/tools/examples/google_serper.html |
24a4737753c1-7 | 'hl': 'en',
'num': 10,
'type': 'images'},
'images': [{'title': 'Lion - Wikipedia',
'imageUrl': 'https://upload.wikimedia.org/wikipedia/commons/thumb/7/73/Lion_waiting_in_Namibia.jpg/1200px-Lion_waiting_in_Namibia.jpg',
'imageWidth': 1200,
... | https://python.langchain.com/en/latest/modules/agents/tools/examples/google_serper.html |
24a4737753c1-8 | 'domain': 'www.britannica.com',
'link': 'https://www.britannica.com/animal/lion',
'position': 2},
{'title': 'African lion, facts and photos',
'imageUrl': 'https://i.natgeofe.com/n/487a0d69-8202-406f-a6a0-939ed3704693/african-lion.JPG',
'imageWidth': 3072,
... | https://python.langchain.com/en/latest/modules/agents/tools/examples/google_serper.html |
24a4737753c1-9 | 'imageWidth': 1200,
'imageHeight': 1200,
'thumbnailUrl': 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTlewcJ5SwC7yKup6ByaOjTnAFDeoOiMxyJTQaph2W_I3dnks4&s',
'thumbnailWidth': 225,
'thumbnailHeight': 225,
'source': 'St. Louis Zoo',
... | https://python.langchain.com/en/latest/modules/agents/tools/examples/google_serper.html |
24a4737753c1-10 | {'title': 'Lion | Characteristics, Habitat, & Facts | Britannica',
'imageUrl': 'https://cdn.britannica.com/29/150929-050-547070A1/lion-Kenya-Masai-Mara-National-Reserve.jpg',
'imageWidth': 1600,
'imageHeight': 1085,
'thumbnailUrl': 'https://encrypted-tbn0.gstatic.com/... | https://python.langchain.com/en/latest/modules/agents/tools/examples/google_serper.html |
24a4737753c1-11 | 'imageWidth': 1365,
'imageHeight': 768,
'thumbnailUrl': 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTc_4vCHscgvFvYy3PSrtIOE81kNLAfhDK8F3mfOuotL0kUkbs&s',
'thumbnailWidth': 299,
'thumbnailHeight': 168,
'source': 'USA Today',
'do... | https://python.langchain.com/en/latest/modules/agents/tools/examples/google_serper.html |
24a4737753c1-12 | {'title': "Lion | Smithsonian's National Zoo",
'imageUrl': 'https://nationalzoo.si.edu/sites/default/files/styles/1400_scale/public/animals/exhibit/africanlion-005.jpg?itok=6wA745g_',
'imageWidth': 1400,
'imageHeight': 845,
'thumbnailUrl': 'https://encrypted-tbn0.gsta... | https://python.langchain.com/en/latest/modules/agents/tools/examples/google_serper.html |
24a4737753c1-13 | 'source': 'Virginia Zoo',
'domain': 'virginiazoo.org',
'link': 'https://virginiazoo.org/zoos-new-male-lion-explores-habitat-for-thefirst-time/',
'position': 10}]}
Searching for Google News#
We can also query Google News using this wrapper. For example:
search = GoogleSerperAPIWrap... | https://python.langchain.com/en/latest/modules/agents/tools/examples/google_serper.html |
24a4737753c1-14 | {'title': 'Global companies by market cap: Tesla fell most in April',
'link': 'https://www.reuters.com/markets/global-companies-by-market-cap-tesla-fell-most-april-2023-05-02/',
'snippet': 'Tesla Inc was the biggest loser among top companies by '
'market capitalisation in Apr... | https://python.langchain.com/en/latest/modules/agents/tools/examples/google_serper.html |
24a4737753c1-15 | 'position': 3},
{'title': 'Joby Aviation to get investment from Tesla shareholder '
'Baillie Gifford',
'link': 'https://finance.yahoo.com/news/joby-aviation-investment-tesla-shareholder-204450712.html',
'snippet': 'This comes days after Joby clinched a $55 million '
... | https://python.langchain.com/en/latest/modules/agents/tools/examples/google_serper.html |
24a4737753c1-16 | 'position': 5},
{'title': 'The Tesla Model 3 Long Range AWD Is Now Available in the '
'U.S. With 325 Miles of Range',
'link': 'https://www.notateslaapp.com/news/1393/tesla-reopens-orders-for-model-3-long-range-after-months-of-unavailability',
'snippet': 'Tesla has reo... | https://python.langchain.com/en/latest/modules/agents/tools/examples/google_serper.html |
24a4737753c1-17 | 'date': '14 hours ago',
'source': 'Tesla Oracle',
'imageUrl': 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRO7M5ZLQE-Zo4-_5dv9hNAQZ3wSqfvYCuKqzxHG-M6CgLpwPMMG_ssebdcMg&s',
'position': 7},
{'title': 'Tesla putting facility in new part of country - Austin '
... | https://python.langchain.com/en/latest/modules/agents/tools/examples/google_serper.html |
24a4737753c1-18 | 'Long Range edition with a starting price of $47240, '
'according to its website.',
'date': '5 hours ago',
'source': 'Bloomberg.com',
'imageUrl': 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTWWIC4VpMTfRvSyqiomODOoLg0xhoBf-Tc1qweKnSuaiTk-Y1wMJZM3jct0w&s',... | https://python.langchain.com/en/latest/modules/agents/tools/examples/google_serper.html |
24a4737753c1-19 | 'date': '53 mins ago',
'source': 'Reuters',
'imageUrl': 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSSTcsXeenqmEKdiekvUgAmqIPR4nlAmgjTkBqLpza-lLfjX1CwB84MoNVj0Q&s',
'position': 1},
{'title': 'Ryder lanza solución llave en mano para vehículos '
'e... | https://python.langchain.com/en/latest/modules/agents/tools/examples/google_serper.html |
24a4737753c1-20 | 'Sanders tells American Billionaires.',
'link': 'https://thebharatexpressnews.com/i-think-people-can-get-by-with-999-million-bernie-sanders-tells-american-billionaires-heres-how-the-ultra-rich-can-pay-less-income-tax-than-you-legally/',
'snippet': 'The report noted that in 2007 and 2011, Amazon.co... | https://python.langchain.com/en/latest/modules/agents/tools/examples/google_serper.html |
24a4737753c1-21 | Searching for Google Places#
We can also query Google Places using this wrapper. For example:
search = GoogleSerperAPIWrapper(type="places")
results = search.results("Italian restaurants in Upper East Side")
pprint.pp(results)
{'searchParameters': {'q': 'Italian restaurants in Upper East Side',
'g... | https://python.langchain.com/en/latest/modules/agents/tools/examples/google_serper.html |
24a4737753c1-22 | {'position': 3,
'title': 'Caravaggio',
'address': '23 E 74th St',
'latitude': 40.773412799999996,
'longitude': -73.96473379999999,
'thumbnailUrl': 'https://lh5.googleusercontent.com/p/AF1QipPDGchokDvppoLfmVEo6X_bWd3Fz0HyxIHTEe9V=w92-h92-n-k-no',
... | https://python.langchain.com/en/latest/modules/agents/tools/examples/google_serper.html |
24a4737753c1-23 | 'rating': 4.5,
'ratingCount': 344,
'category': 'Italian'},
{'position': 6,
'title': 'Come Prima',
'address': '903 Madison Ave',
'latitude': 40.772124999999996,
'longitude': -73.965012,
'thumbnailUrl': 'https://lh5.goo... | https://python.langchain.com/en/latest/modules/agents/tools/examples/google_serper.html |
24a4737753c1-24 | 'longitude': -73.9689825,
'thumbnailUrl': 'https://lh5.googleusercontent.com/p/AF1QipPifIgzOCD5SjgzzqBzGkdZCBp0MQsK5k7M7znn=w92-h92-n-k-no',
'rating': 4.6,
'ratingCount': 941,
'category': 'Italian'},
{'position': 9,
'title': 'Pinocchio Restaur... | https://python.langchain.com/en/latest/modules/agents/tools/examples/google_serper.html |
24a4737753c1-25 | previous
Google Search
next
Gradio Tools
Contents
As part of a Self Ask With Search Chain
Obtaining results with metadata
Searching for Google Images
Searching for Google News
Searching for Google Places
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on May 28, 2023. | https://python.langchain.com/en/latest/modules/agents/tools/examples/google_serper.html |
12ea50c0f841-0 | .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... | https://python.langchain.com/en/latest/modules/agents/tools/examples/wolfram_alpha.html |
694cabe88680-0 | .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.... | https://python.langchain.com/en/latest/modules/agents/tools/examples/bing_search.html |
694cabe88680-1 | '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... | https://python.langchain.com/en/latest/modules/agents/tools/examples/bing_search.html |
694cabe88680-2 | assignment operator.It adds two values and assigns the sum to a variable (left operand). W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, <b>Python</b>, SQL, Java, and many, many more. This tutorial introduces t... | https://python.langchain.com/en/latest/modules/agents/tools/examples/bing_search.html |
694cabe88680-3 | To install <b>Python</b> using the Microsoft Store: Go to your Start menu (lower left Windows icon), type "Microsoft Store", select the link to open the store. Once the store is open, select Search from the upper-right menu and enter "<b>Python</b>". Select which version of <b>Python</b> you would l... | https://python.langchain.com/en/latest/modules/agents/tools/examples/bing_search.html |
694cabe88680-4 | 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... | https://python.langchain.com/en/latest/modules/agents/tools/examples/bing_search.html |
694cabe88680-5 | {'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... | https://python.langchain.com/en/latest/modules/agents/tools/examples/bing_search.html |
0935955eefce-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://python.langchain.com/en/latest/modules/agents/tools/examples/gradio_tools.html |
0935955eefce-1 | from langchain.agents import initialize_agent
from langchain.llms import OpenAI
from gradio_tools.tools import (StableDiffusionTool, ImageCaptioningTool, StableDiffusionPromptGeneratorTool,
TextToVideoTool)
from langchain.memory import ConversationBufferMemory
llm = OpenAI(temperature=0)... | https://python.langchain.com/en/latest/modules/agents/tools/examples/gradio_tools.html |
0935955eefce-2 | Thought: Do I need to use a tool? Yes
Action: StableDiffusion
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
Observat... | https://python.langchain.com/en/latest/modules/agents/tools/examples/gradio_tools.html |
0935955eefce-3 | Job Status: Status.IN_QUEUE eta: 42.49370198879602
Job Status: Status.IN_QUEUE eta: 21.314297944849187
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... | https://python.langchain.com/en/latest/modules/agents/tools/examples/gradio_tools.html |
44bad711af89-0 | .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',... | https://python.langchain.com/en/latest/modules/agents/tools/examples/youtube.html |
d8f0e57e1076-0 | .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... | https://python.langchain.com/en/latest/modules/agents/tools/examples/sceneXplain.html |
d8f0e57e1076-1 | 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... | https://python.langchain.com/en/latest/modules/agents/tools/examples/sceneXplain.html |
d8f0e57e1076-2 | By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on May 28, 2023. | https://python.langchain.com/en/latest/modules/agents/tools/examples/sceneXplain.html |
2994385e9009-0 | .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... | https://python.langchain.com/en/latest/modules/agents/tools/examples/openweathermap.html |
2994385e9009-1 | agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
verbose=True
)
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:
Deta... | https://python.langchain.com/en/latest/modules/agents/tools/examples/openweathermap.html |
8aa9d898e8b1-0 | .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... | https://python.langchain.com/en/latest/modules/agents/tools/examples/ifttt.html |
8aa9d898e8b1-1 | service, and you’re ready to start receiving data and triggering actions 🎉
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.if... | https://python.langchain.com/en/latest/modules/agents/tools/examples/ifttt.html |
bb70ee48d45c-0 | .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... | https://python.langchain.com/en/latest/modules/agents/tools/examples/metaphor_search.html |
bb70ee48d45c-1 | {'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... | https://python.langchain.com/en/latest/modules/agents/tools/examples/metaphor_search.html |
bb70ee48d45c-2 | 'title': 'So You Want to Save the World - LessWrong', 'dateCreated': '2012-01-01', 'author': 'Lukeprog', 'score': 0.18853715062141418}, {'url': 'https://openai.com/blog/planning-for-agi-and-beyond', 'title': 'Planning for AGI and beyond', 'dateCreated': '2023-02-24', 'author': 'Authors', 'score': 0.18665121495723724}, ... | https://python.langchain.com/en/latest/modules/agents/tools/examples/metaphor_search.html |
bb70ee48d45c-3 | 'title': 'The Proof of Doom - LessWrong', 'dateCreated': '2022-03-09', 'author': 'Johnlawrenceaspden', 'score': 0.18159329891204834}, {'url': 'https://intelligence.org/why-ai-safety/', 'title': 'Why AI Safety? - Machine Intelligence Research Institute', 'dateCreated': '2017-03-01', 'author': None, 'score': 0.1814115345... | https://python.langchain.com/en/latest/modules/agents/tools/examples/metaphor_search.html |
bb70ee48d45c-4 | [{'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'... | https://python.langchain.com/en/latest/modules/agents/tools/examples/metaphor_search.html |
bb70ee48d45c-5 | 'date_created': '2023-02-24'},
{'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 H... | https://python.langchain.com/en/latest/modules/agents/tools/examples/metaphor_search.html |
bb70ee48d45c-6 | )
async_browser = create_async_playwright_browser()
toolkit = PlayWrightBrowserToolkit.from_browser(async_browser=async_browser)
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["ext... | https://python.langchain.com/en/latest/modules/agents/tools/examples/metaphor_search.html |
bb70ee48d45c-7 | Thought:I need to navigate to the URL provided in the search results to find the tweet.
> Finished chain.
'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
... | https://python.langchain.com/en/latest/modules/agents/tools/examples/metaphor_search.html |
1cd08a6a2651-0 | .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... | https://python.langchain.com/en/latest/modules/agents/tools/examples/serpapi.html |
1cd08a6a2651-1 | repl_tool = Tool(
name="python_repl",
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
Custo... | https://python.langchain.com/en/latest/modules/agents/tools/examples/serpapi.html |
47f1637a97fb-0 | .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
... | https://python.langchain.com/en/latest/modules/agents/tools/examples/human_tools.html |
47f1637a97fb-1 | def get_input() -> str:
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".joi... | https://python.langchain.com/en/latest/modules/agents/tools/examples/human_tools.html |
47f1637a97fb-2 | oh who said it
q
Observation: oh who said it
Thought:I can use DuckDuckGo Search to find out who said the quote
Action: DuckDuckGo Search
Action Input: "Who said 'Veni, vidi, vici'?" | https://python.langchain.com/en/latest/modules/agents/tools/examples/human_tools.html |
47f1637a97fb-3 | 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... | https://python.langchain.com/en/latest/modules/agents/tools/examples/human_tools.html |
47f1637a97fb-4 | Caesar ve· ni, vi· di, vi· ci ˌwā-nē ˌwē-dē ˈwē-kē ˌvā-nē ˌvē-dē ˈvē-chē : I came, I saw, I conquered Articles Related to veni, vidi, vici 'In Vino Veritas' and Other Latin... Dictionary Entries Near veni, vidi, vici Venite veni, vidi, vici Venizélos See More Nearby Entries Cite this Entry Style The simplest explanatio... | https://python.langchain.com/en/latest/modules/agents/tools/examples/human_tools.html |
47f1637a97fb-5 | expression of triumph. The words are said to have been used by Caesar as he was enjoying a triumph. | https://python.langchain.com/en/latest/modules/agents/tools/examples/human_tools.html |
47f1637a97fb-6 | 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... | https://python.langchain.com/en/latest/modules/agents/tools/examples/human_tools.html |
efe7c51421f5-0 | .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... | https://python.langchain.com/en/latest/modules/agents/tools/examples/huggingface_tools.html |
4c972ee6615a-0 | .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 = ... | https://python.langchain.com/en/latest/modules/agents/tools/examples/arxiv.html |
4c972ee6615a-1 | Thought:The paper is about heat-bath random walks with Markov bases on graphs of lattice points.
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 lattic... | https://python.langchain.com/en/latest/modules/agents/tools/examples/arxiv.html |
4c972ee6615a-2 | docs = arxiv.run("Caprice Stanley")
docs
'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... | https://python.langchain.com/en/latest/modules/agents/tools/examples/arxiv.html |
4c972ee6615a-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
AWS Lambda API
Contents
The ArXiv API Wrapper
By Harrison Chase
© Copyright 2023, H... | https://python.langchain.com/en/latest/modules/agents/tools/examples/arxiv.html |
f94cff66ccfc-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://python.langchain.com/en/latest/modules/agents/tools/examples/chatgpt_plugins.html |
f94cff66ccfc-1 | 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':... | https://python.langchain.com/en/latest/modules/agents/tools/examples/chatgpt_plugins.html |
f94cff66ccfc-2 | {'schema': {'$ref': '#/components/schemas/ProductResponse'}}}}, '503': {'description': 'one or more services are unavailable'}}, 'deprecated': False}}}, 'components': {'schemas': {'Product': {'type': 'object', 'properties': {'attributes': {'type': 'array', 'items': {'type': 'string'}}, 'name': {'type': 'string'}, 'pric... | https://python.langchain.com/en/latest/modules/agents/tools/examples/chatgpt_plugins.html |
f94cff66ccfc-3 | 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 | https://python.langchain.com/en/latest/modules/agents/tools/examples/chatgpt_plugins.html |
f94cff66ccfc-4 | 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://python.langchain.com/en/latest/modules/agents/tools/examples/chatgpt_plugins.html |
f94cff66ccfc-5 | Comfort T-shirts Men's 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"]}]} | https://python.langchain.com/en/latest/modules/agents/tools/examples/chatgpt_plugins.html |
f94cff66ccfc-6 | 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... | https://python.langchain.com/en/latest/modules/agents/tools/examples/chatgpt_plugins.html |
aff1d89c3a12-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://python.langchain.com/en/latest/modules/agents/agents/custom_llm_agent.html |
aff1d89c3a12-1 | from langchain.prompts import StringPromptTemplate
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 ... | https://python.langchain.com/en/latest/modules/agents/agents/custom_llm_agent.html |
aff1d89c3a12-2 | Question: {input}
{agent_scratchpad}"""
# 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, Observat... | https://python.langchain.com/en/latest/modules/agents/agents/custom_llm_agent.html |
aff1d89c3a12-3 | class CustomOutputParser(AgentOutputParser):
def parse(self, llm_output: str) -> Union[AgentAction, AgentFinish]:
# Check if agent should finish
if "Final Answer:" in llm_output:
return AgentFinish(
# Return values is generally always a dictionary with a single `outp... | https://python.langchain.com/en/latest/modules/agents/agents/custom_llm_agent.html |
aff1d89c3a12-4 | # LLM chain consisting of the LLM and a prompt
llm_chain = LLMChain(llm=llm, prompt=prompt)
tool_names = [tool.name for tool in tools]
agent = LLMSingleActionAgent(
llm_chain=llm_chain,
output_parser=output_parser,
stop=["\nObservation:"],
allowed_tools=tool_names
)
Use the Agent#
Now we can use it!
a... | https://python.langchain.com/en/latest/modules/agents/agents/custom_llm_agent.html |
aff1d89c3a12-5 | 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 repeat N times)
Thought: I now know... | https://python.langchain.com/en/latest/modules/agents/agents/custom_llm_agent.html |
aff1d89c3a12-6 | 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 now know the final answer
Final Answer:... | https://python.langchain.com/en/latest/modules/agents/agents/custom_llm_agent.html |
84cad4a222e4-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://python.langchain.com/en/latest/modules/agents/agents/custom_llm_chat_agent.html |
84cad4a222e4-1 | !pip install langchain
!pip install google-search-results
!pip install openai
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 ty... | https://python.langchain.com/en/latest/modules/agents/agents/custom_llm_chat_agent.html |
84cad4a222e4-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
These were previous tasks you completed:
Begin!
Question: {input}
{agent_sc... | https://python.langchain.com/en/latest/modules/agents/agents/custom_llm_chat_agent.html |
84cad4a222e4-3 | # This includes the `intermediate_steps` variable because that is needed
input_variables=["input", "intermediate_steps"]
)
Output Parser#
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 pa... | https://python.langchain.com/en/latest/modules/agents/agents/custom_llm_chat_agent.html |
84cad4a222e4-4 | llm = ChatOpenAI(openai_api_key=OPENAI_API_KEY, temperature=0)
Define the stop sequence#
This is important because it tells the LLM when to stop generation.
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 Observati... | https://python.langchain.com/en/latest/modules/agents/agents/custom_llm_chat_agent.html |
84cad4a222e4-5 | previous
Custom LLM Agent
next
Custom MRKL 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
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on May 28, 2023. | https://python.langchain.com/en/latest/modules/agents/agents/custom_llm_chat_agent.html |
39dd628ce445-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://python.langchain.com/en/latest/modules/agents/agents/custom_mrkl_agent.html |
39dd628ce445-1 | 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
from langchain import OpenAI, SerpAPIWrapper, LLM... | https://python.langchain.com/en/latest/modules/agents/agents/custom_mrkl_agent.html |
39dd628ce445-2 | 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 "Args"
Question: {input}
{agent_scratchpad}
Note that we are able to feed agents a self-defined prompt template, i.e. not restricted to the p... | https://python.langchain.com/en/latest/modules/agents/agents/custom_mrkl_agent.html |
39dd628ce445-3 | Multiple inputs#
Agents can also work with prompts that require multiple inputs.
prefix = """Answer the following questions as best you can. You have access to the following tools:"""
suffix = """When answering, you MUST speak in the following language: {language}.
Question: {input}
{agent_scratchpad}"""
prompt = ZeroS... | https://python.langchain.com/en/latest/modules/agents/agents/custom_mrkl_agent.html |
39dd628ce445-4 | Thought: I now know the final answer.
Final Answer: 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.
> Finished chain.
'La popolazione del Canada è stata stimata a 39.566.248 il 1° gennaio 2023,... | https://python.langchain.com/en/latest/modules/agents/agents/custom_mrkl_agent.html |
c0fea4500f2a-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://python.langchain.com/en/latest/modules/agents/agents/custom_agent.html |
c0fea4500f2a-1 | Args:
intermediate_steps: Steps the LLM has taken to date,
along with observations
**kwargs: User inputs.
Returns:
Action specifying what tool to use.
"""
return AgentAction(tool="Search", tool_input=kwargs["input"], log="")
agent = FakeAgent()... | https://python.langchain.com/en/latest/modules/agents/agents/custom_agent.html |
62fcf0acbfda-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://python.langchain.com/en/latest/modules/agents/agents/custom_agent_with_tool_retrieval.html |
62fcf0acbfda-1 | 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}"
)
for i in range(99)
]
ALL_TOOLS = [search_tool] + fake_tools
Tool Retriever#
We will use a vectorstore to create embedd... | https://python.langchain.com/en/latest/modules/agents/agents/custom_agent_with_tool_retrieval.html |
62fcf0acbfda-2 | 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', ... | https://python.langchain.com/en/latest/modules/agents/agents/custom_agent_with_tool_retrieval.html |
62fcf0acbfda-3 | 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', ... | https://python.langchain.com/en/latest/modules/agents/agents/custom_agent_with_tool_retrieval.html |
62fcf0acbfda-4 | from typing import Callable
# 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 in... | https://python.langchain.com/en/latest/modules/agents/agents/custom_agent_with_tool_retrieval.html |
62fcf0acbfda-5 | class CustomOutputParser(AgentOutputParser):
def parse(self, llm_output: str) -> Union[AgentAction, AgentFinish]:
# Check if agent should finish
if "Final Answer:" in llm_output:
return AgentFinish(
# Return values is generally always a dictionary with a single `outp... | https://python.langchain.com/en/latest/modules/agents/agents/custom_agent_with_tool_retrieval.html |
62fcf0acbfda-6 | 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("What's the weather in SF?")
> Entering new AgentExecutor chain...
Thought: I need to... | https://python.langchain.com/en/latest/modules/agents/agents/custom_agent_with_tool_retrieval.html |
e1558bd222c1-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://python.langchain.com/en/latest/modules/agents/agents/custom_multi_action_agent.html |
e1558bd222c1-1 | """
if len(intermediate_steps) == 0:
return [
AgentAction(tool="Search", tool_input=kwargs["input"], log=""),
AgentAction(tool="RandomWord", tool_input=kwargs["input"], log=""),
]
else:
return AgentFinish(return_values={"output": "bar"}... | https://python.langchain.com/en/latest/modules/agents/agents/custom_multi_action_agent.html |
e1558bd222c1-2 | By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on May 28, 2023. | https://python.langchain.com/en/latest/modules/agents/agents/custom_multi_action_agent.html |
c5621bbc6d78-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://python.langchain.com/en/latest/modules/agents/agents/agent_types.html |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.