id stringlengths 14 16 | text stringlengths 31 3.14k | source stringlengths 58 124 |
|---|---|---|
4e247a09009b-0 | .md
.pdf
Getting Started
Contents
List of Tools
Getting Started#
Tools are functions that agents can use to interact with the world.
These tools can be generic utilities (e.g. search), other chains, or even other agents.
Currently, tools can be loaded with the following snippet:
from langchain.agents import load_tool... | /content/https://python.langchain.com/en/latest/modules/agents/tools/getting_started.html |
4e247a09009b-1 | Notes: Calls the Serp API and then parses results.
Requires LLM: No
wolfram-alpha
Tool Name: Wolfram Alpha
Tool Description: A wolfram alpha search engine. Useful for when you need to answer questions about Math, Science, Technology, Culture, Society and Everyday Life. Input should be a search query.
Notes: Calls the W... | /content/https://python.langchain.com/en/latest/modules/agents/tools/getting_started.html |
4e247a09009b-2 | Requires LLM: Yes
llm-math
Tool Name: Calculator
Tool Description: Useful for when you need to answer questions about math.
Notes: An instance of the LLMMath chain.
Requires LLM: Yes
open-meteo-api
Tool Name: Open Meteo API
Tool Description: Useful for when you want to get weather information from the OpenMeteo API. Th... | /content/https://python.langchain.com/en/latest/modules/agents/tools/getting_started.html |
4e247a09009b-3 | google-search
Tool Name: Search
Tool Description: A wrapper around Google Search. Useful for when you need to answer questions about current events. Input should be a search query.
Notes: Uses the Google Custom Search API
Requires LLM: No
Extra Parameters: google_api_key, google_cse_id
For more information on this, see... | /content/https://python.langchain.com/en/latest/modules/agents/tools/getting_started.html |
4e247a09009b-4 | Notes: A natural language connection to the Listen Notes Podcast API (https://www.PodcastAPI.com), specifically the /search/ endpoint.
Requires LLM: Yes
Extra Parameters: listen_api_key (your api key to access this endpoint)
openweathermap-api
Tool Name: OpenWeatherMap
Tool Description: A wrapper around OpenWeatherMap ... | /content/https://python.langchain.com/en/latest/modules/agents/tools/getting_started.html |
280747081e75-0 | .ipynb
.pdf
Tool Input Schema
Tool Input Schema#
By default, tools infer the argument schema by inspecting the function signature. For more strict requirements, custom input schema can be specified, along with custom validation logic.
from typing import Any, Dict
from langchain.agents import AgentType, initialize_agent... | /content/https://python.langchain.com/en/latest/modules/agents/tools/tool_input_validation.html |
280747081e75-1 | agent = initialize_agent([tool], llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=False)
# This will succeed, since there aren't any arguments that will be triggered during validation
answer = agent.run("What's the main title on langchain.com?")
print(answer)
The main title of langchain.com is "LANG CHAIN 🦜️�... | /content/https://python.langchain.com/en/latest/modules/agents/tools/tool_input_validation.html |
280747081e75-2 | --> 116 raise e
117 self.callback_manager.on_chain_end(outputs, verbose=self.verbose)
118 return self.prep_outputs(inputs, outputs, return_only_outputs)
File ~/code/lc/lckg/langchain/chains/base.py:113, in Chain.__call__(self, inputs, return_only_outputs)
107 self.callback_manager.on_chain_start(
10... | /content/https://python.langchain.com/en/latest/modules/agents/tools/tool_input_validation.html |
280747081e75-3 | File ~/code/lc/lckg/langchain/agents/agent.py:695, in AgentExecutor._take_next_step(self, name_to_tool_map, color_mapping, inputs, intermediate_steps)
693 tool_run_kwargs["llm_prefix"] = ""
694 # We then call the tool on the tool input to get an observation
--> 695 observation = tool.run(
69... | /content/https://python.langchain.com/en/latest/modules/agents/tools/tool_input_validation.html |
280747081e75-4 | ---> 71 input_args.parse_obj({key_: tool_input})
72 # Passing as a positional argument is more straightforward for
73 # backwards compatability
74 return tool_input
File ~/code/lc/lckg/.venv/lib/python3.11/site-packages/pydantic/main.py:526, in pydantic.main.BaseModel.parse_obj()
File ~/code/lc/lckg/... | /content/https://python.langchain.com/en/latest/modules/agents/tools/tool_input_validation.html |
e3e7480809fe-0 | .ipynb
.pdf
Zapier Natural Language Actions API
Contents
Zapier Natural Language Actions API
Example with Agent
Example with SimpleSequentialChain
Zapier Natural Language Actions API#
Full docs here: https://nla.zapier.com/api/v1/docs
Zapier Natural Language Actions gives you access to the 5k+ apps, 20k+ actions on Z... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/zapier.html |
e3e7480809fe-1 | This example goes over how to use the Zapier integration with a SimpleSequentialChain, then an Agent.
In code, below:
%load_ext autoreload
%autoreload 2
import os
# get from https://platform.openai.com/
os.environ["OPENAI_API_KEY"] = os.environ.get("OPENAI_API_KEY", "")
# get from https://nla.zapier.com/demo/provider/d... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/zapier.html |
e3e7480809fe-2 | agent = initialize_agent(toolkit.get_tools(), llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True)
agent.run("Summarize the last email I received regarding Silicon Valley Bank. Send the summary to the #test-zapier channel in slack.")
> Entering new AgentExecutor chain...
I need to find the email and summari... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/zapier.html |
e3e7480809fe-3 | Action: Gmail: Find Email
Action Input: Find the latest email from Silicon Valley Bank
Observation: {"from__name": "Silicon Valley Bridge Bank, N.A.", "from__email": "sreply@svb.com", "body_plain": "Dear Clients, After chaotic, tumultuous & stressful days, we have clarity on path for SVB, FDIC is fully insuring all dep... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/zapier.html |
e3e7480809fe-4 | Action: Slack: Send Channel Message
Action Input: Send a slack message to the #test-zapier channel with the text "Silicon Valley Bank has announced that Tim Mayopoulos is the new CEO. FDIC is fully insuring all deposits and they have an ask for clients and partners as they rebuild."
Observation: {"message__text": "Sili... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/zapier.html |
e3e7480809fe-5 | Thought: I now know the final answer.
Final Answer: I have sent a summary of the last email from Silicon Valley Bank to the #test-zapier channel in Slack.
> Finished chain.
'I have sent a summary of the last email from Silicon Valley Bank to the #test-zapier channel in Slack.'
Example with SimpleSequentialChain#
If you... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/zapier.html |
e3e7480809fe-6 | return {"email_data": ZapierNLARunAction(action_id=action["id"], zapier_description=action["description"], params_schema=action["params"]).run(inputs["instructions"])}
gmail_chain = TransformChain(input_variables=["instructions"], output_variables=["email_data"], transform=nla_gmail)
## step 2. generate draft reply
tem... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/zapier.html |
e3e7480809fe-7 | slack_chain = TransformChain(input_variables=["draft_reply"], output_variables=["slack_data"], transform=nla_slack)
## finally, execute
overall_chain = SimpleSequentialChain(chains=[gmail_chain, reply_chain, slack_chain], verbose=True)
overall_chain.run(GMAIL_SEARCH_INSTRUCTIONS)
> Entering new SimpleSequentialChain ch... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/zapier.html |
e3e7480809fe-8 | > Entering new SimpleSequentialChain chain...
{"from__name": "Silicon Valley Bridge Bank, N.A.", "from__email": "sreply@svb.com", "body_plain": "Dear Clients, After chaotic, tumultuous & stressful days, we have clarity on path for SVB, FDIC is fully insuring all deposits & have an ask for clients & partners as we rebui... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/zapier.html |
e3e7480809fe-9 | Best regards,
[Your Name]
{"message__text": "Dear Silicon Valley Bridge Bank, \n\nThank you for your email and the update regarding your new CEO Tim Mayopoulos. We appreciate your dedication to keeping your clients and partners informed and we look forward to continuing our relationship with you. \n\nBest regards, \n[... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/zapier.html |
e3e7480809fe-10 | > Finished chain.
'{"message__text": "Dear Silicon Valley Bridge Bank, \\n\\nThank you for your email and the update regarding your new CEO Tim Mayopoulos. We appreciate your dedication to keeping your clients and partners informed and we look forward to continuing our relationship with you. \\n\\nBest regards, \\n[You... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/zapier.html |
bf7cbfa69687-0 | .ipynb
.pdf
SearxNG Search API
Contents
Custom Parameters
Obtaining results with metadata
SearxNG Search API#
This notebook goes over how to use a self hosted SearxNG search API to search the web.
You can check this link for more informations about Searx API parameters.
import pprint
from langchain.utilities import S... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/searx_search.html |
bf7cbfa69687-1 | search.run("large language model ", engines=['wiki'])
'Large language models (LLMs) represent a major advancement in AI, with the promise of transforming domains through learned knowledge. LLM sizes have been increasing 10X every year for the last few years, and as these models grow in complexity and size, so do their ... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/searx_search.html |
bf7cbfa69687-2 | Passing other Searx parameters for searx like language
search = SearxSearchWrapper(searx_host="http://127.0.0.1:8888", k=1)
search.run("deep learning", language='es', engines=['wiki'])
'Aprendizaje profundo (en inglés, deep learning) es un conjunto de algoritmos de aprendizaje automático (en inglés, machine learning) q... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/searx_search.html |
bf7cbfa69687-3 | 'engines': ['google scholar'],
'category': 'science'},
{'snippet': '… Large language models (LLMs) have introduced new possibilities '
'for prototyping with AI [18]. Pre-trained on a large amount of '
'text data, models … language instructions called prompts. …',
'title': 'Promptchainer: ... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/searx_search.html |
bf7cbfa69687-4 | 'code',
'link': 'https://arxiv.org/abs/2206.12839',
'engines': ['google scholar'],
'category': 'science'},
{'snippet': '… Figure 2 | The benefits of different components of a prompt '
'for the largest language model (Gopher), as estimated from '
'hierarchical logistic regression. Each p... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/searx_search.html |
bf7cbfa69687-5 | 'effective in general. Besides, the performance gaps tend to '
'diminish when the scale of training data grows large.',
'title': 'Do Prompts Solve NLP Tasks Using Natural Language?',
'link': 'http://arxiv.org/abs/2203.00902v1',
'engines': ['arxiv'],
'category': 'science'},
{'snippet': 'Cross-promp... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/searx_search.html |
bf7cbfa69687-6 | 'target-prompt data during training and is a single-stage '
'approach. PAES is easy to apply in practice and achieves '
'state-of-the-art performance on the Automated Student Assessment '
'Prize (ASAP) dataset.',
'title': 'Prompt Agnostic Essay Scorer: A Domain Generalization Ap... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/searx_search.html |
bf7cbfa69687-7 | 'prompting performance; yet, none of the correlations are strong '
'enough; 3) using pseudo parallel prompt examples constructed '
'from monolingual data via zero-shot prompting could improve '
'translation; and 4) improved performance is achievable by '
'transferring... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/searx_search.html |
bf7cbfa69687-8 | 'probability of label words. Based on these findings, we also '
'propose a method for generating prompts using only unlabeled '
'data, outperforming strong baselines by an average of 7.0% '
'accuracy across three tasks.',
'title': "Toward Human Readable Prompt Tuning: Kubrick's ... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/searx_search.html |
bf7cbfa69687-9 | 'Informed by this more encompassing theory of prompt programming, '
'we also introduce the idea of a metaprompt that seeds the model '
'to generate its own natural language prompts for a range of '
'tasks. Finally, we discuss how these more general methods of '
'inter... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/searx_search.html |
bf7cbfa69687-10 | 'link': 'https://github.com/deepmind/dramatron',
'engines': ['github'],
'category': 'it'}]
We could also directly query for results from github and other source forges.
results = search.results("large language model", num_results = 20, engines=['github', 'gitlab'])
pprint.pp(results)
[{'snippet': "Implementation of... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/searx_search.html |
bf7cbfa69687-11 | {'snippet': 'Dramatron uses large language models to generate coherent '
'scripts and screenplays.',
'title': 'dramatron',
'link': 'https://github.com/deepmind/dramatron',
'engines': ['github'],
'category': 'it'},
{'snippet': 'Code for loralib, an implementation of "LoRA: Low-Rank '
'... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/searx_search.html |
bf7cbfa69687-12 | 'and accessible large-scale language model training, built with '
'Hugging Face 🤗 Transformers.',
'title': 'mistral',
'link': 'https://github.com/stanford-crfm/mistral',
'engines': ['github'],
'category': 'it'},
{'snippet': 'A prize for finding tasks that cause large language models to '
... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/searx_search.html |
bf7cbfa69687-13 | 'Samwald research group: https://samwald.info/',
'title': 'ThoughtSource',
'link': 'https://github.com/OpenBioLink/ThoughtSource',
'engines': ['github'],
'category': 'it'},
{'snippet': 'A comprehensive list of papers using large language/multi-modal '
'models for Robotics/RL, including papers, cod... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/searx_search.html |
bf7cbfa69687-14 | 'title': 'dust',
'link': 'https://github.com/dust-tt/dust',
'engines': ['github'],
'category': 'it'},
{'snippet': 'Polyglot: Large Language Models of Well-balanced Competence in '
'Multi-languages',
'title': 'polyglot',
'link': 'https://github.com/EleutherAI/polyglot',
'engines': ['github'],
... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/searx_search.html |
bf7cbfa69687-15 | 'title': 'xl-sum',
'link': 'https://github.com/csebuetnlp/xl-sum',
'engines': ['github'],
'category': 'it'}]
previous
Search Tools
next
SerpAPI
Contents
Custom Parameters
Obtaining results with metadata
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on Apr 26, 2023. | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/searx_search.html |
6bf79006e100-0 | .ipynb
.pdf
Google Places
Google Places#
This notebook goes through how to use Google Places API
#!pip install googlemaps
import os
os.environ["GPLACES_API_KEY"] = ""
from langchain.tools import GooglePlacesTool
places = GooglePlacesTool()
places.run("al fornos")
"1. Delfina Restaurant\nAddress: 3621 18th St, San Franc... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/google_places.html |
875096c99851-0 | .ipynb
.pdf
Google Serper API
Contents
As part of a Self Ask With Search Chain
Google Serper API#
This notebook goes over how to use the Google Serper component to search the web. First you need to sign up for a free account at serper.dev and get your api key.
import os
os.environ["SERPER_API_KEY"] = ""
from langchai... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/google_serper.html |
875096c99851-1 | Follow up: Where is Carlos Alcaraz from?
Intermediate answer: El Palmar, Spain
So the final answer is: El Palmar, Spain
> Finished chain.
'El Palmar, Spain'
previous
Google Search
next
Gradio Tools
Contents
As part of a Self Ask With Search Chain
By Harrison Chase
© Copyright 2023, Harrison Chase.
... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/google_serper.html |
d22d0177d7d3-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.... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/bing_search.html |
d22d0177d7d3-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... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/bing_search.html |
d22d0177d7d3-2 | of the <b>Python</b> language and system. It helps to have a <b>Python</b> interpreter handy for hands-on experience, but all examples are self-contained, so the tutorial can be read off-line as well. For a description of standard objects and modules, see The <b>Python</b> Standard ... <b>Python</b> is a general-purpos... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/bing_search.html |
d22d0177d7d3-3 | 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... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/bing_search.html |
d22d0177d7d3-4 | {'snippet': '<b>Apples</b> can do a lot for you, thanks to plant chemicals called flavonoids. And they have pectin, a fiber that breaks down in your gut. If you take off the apple’s skin before eating it, you won ...',
'title': 'Apples: Nutrition & Health Benefits - WebMD',
'link': 'https://www.webmd.com/food-r... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/bing_search.html |
d22d0177d7d3-5 | previous
Bash
next
ChatGPT Plugins
Contents
Number of results
Metadata Results
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on Apr 26, 2023. | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/bing_search.html |
31d2851bb5a9-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... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/ifttt.html |
31d2851bb5a9-1 | complete the setup.
Congratulations! You have successfully connected the Webhook to the desired
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
ht... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/ifttt.html |
88efca36bbe9-0 | .ipynb
.pdf
DuckDuckGo Search
DuckDuckGo Search#
This notebook goes over how to use the duck-duck-go search component.
# !pip install duckduckgo-search
from langchain.tools import DuckDuckGoSearchTool
search = DuckDuckGoSearchTool()
search.run("Obama's first name?") | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/ddg.html |
88efca36bbe9-1 | search.run("Obama's first name?")
'Barack Obama, in full Barack Hussein Obama II, (born August 4, 1961, Honolulu, Hawaii, U.S.), 44th president of the United States (2009-17) and the first African American to hold the office. Before winning the presidency, Obama represented Illinois in the U.S. Senate (2005-08). Barack... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/ddg.html |
88efca36bbe9-2 | previous
ChatGPT Plugins
next
Google Places
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on Apr 26, 2023. | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/ddg.html |
b32cedba8891-0 | .ipynb
.pdf
Apify
Apify#
This notebook shows how to use the Apify integration for LangChain.
Apify is a cloud platform for web scraping and data extraction,
which provides an ecosystem of more than a thousand
ready-made apps called Actors for various web scraping, crawling, and data extraction use cases.
For example, y... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/apify.html |
b32cedba8891-1 | Note that if you already have some results in an Apify dataset, you can load them directly using ApifyDatasetLoader, as shown in this notebook. In that notebook, you’ll also find the explanation of the dataset_mapping_function, which is used to map fields from the Apify dataset records to LangChain Document fields.
loa... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/apify.html |
b32cedba8891-2 | previous
Tool Input Schema
next
Arxiv API
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on Apr 26, 2023. | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/apify.html |
c6952fb20f34-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... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/gradio_tools.html |
c6952fb20f34-1 | from PIL import Image
im = Image.open("/Users/harrisonchase/workplace/langchain/docs/modules/agents/tools/examples/b61c1dd9-47e2-46f1-a47c-20d27640993d/tmp4ap48vnm.jpg")
display(im)
Using within an agent#
from langchain.agents import initialize_agent
from langchain.llms import OpenAI
from gradio_tools.tools import (Sta... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/gradio_tools.html |
c6952fb20f34-2 | Loaded as API: https://microsoft-promptist.hf.space ✔
Loaded as API: https://damo-vilab-modelscope-text-to-video-synthesis.hf.space ✔
> Entering new AgentExecutor chain...
Thought: Do I need to use a tool? Yes
Action: StableDiffusionPromptGenerator
Action Input: A dog riding a skateboard
Job Status: Status.STARTING eta... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/gradio_tools.html |
c6952fb20f34-3 | Job Status: Status.STARTING eta: None
Observation: a painting of a dog sitting on a skateboard
Thought: Do I need to use a tool? Yes
Action: TextToVideo
Action Input: a painting of a dog sitting on a skateboard
Job Status: Status.STARTING eta: None
Due to heavy traffic on this app, the prediction will take approximatel... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/gradio_tools.html |
0a015068265c-0 | .ipynb
.pdf
Python REPL
Python REPL#
Sometimes, for complex calculations, rather than have an LLM generate the answer directly, it can be better to have the LLM generate code to calculate the answer, and then run that code to get the answer. In order to easily do that, we provide a simple Python REPL to execute command... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/python.html |
ae3d6d8415cd-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... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/serpapi.html |
4052c74033f2-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... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/wolfram_alpha.html |
9f56f18faf0a-0 | .ipynb
.pdf
Google Search
Contents
Number of Results
Metadata Results
Google Search#
This notebook goes over how to use the google search component.
First, you need to set up the proper API keys and environment variables. To set it up, create the GOOGLE_API_KEY in the Google Cloud credential console (https://console.... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/google_search.html |
9f56f18faf0a-1 | '1 Child\'s First Name. 2. 6. 7d. Street Address. 71. (Type or print). BARACK. Sex. 3. This Birth. 4. If Twin or Triplet,. Was Child Born. Barack Hussein Obama II is an American retired politician who served as the 44th president of the United States from 2009 to 2017. His full name is Barack Hussein Obama II. Since th... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/google_search.html |
9f56f18faf0a-2 | Number of Results#
You can use the k parameter to set the number of results
search = GoogleSearchAPIWrapper(k=1)
search.run("python")
'The official home of the Python Programming Language.'
‘The official home of the Python Programming Language.’
Metadata Results#
Run query through GoogleSearch and return snippet, title... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/google_search.html |
9f56f18faf0a-3 | 'link': 'https://en.wikipedia.org/wiki/Apple'},
{'snippet': 'Apples are a popular fruit. They contain antioxidants, vitamins, dietary fiber, and a range of other nutrients. Due to their varied nutrient content,\xa0...',
'title': 'Apples: Benefits, nutrition, and tips',
'link': 'https://www.medicalnewstoday.com/art... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/google_search.html |
8899789a5720-0 | .ipynb
.pdf
OpenWeatherMap API
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 we will need to set some environment vari... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/openweathermap.html |
d27b92b3c8a8-0 | .ipynb
.pdf
Bash
Bash#
It can often be useful to have an LLM generate bash commands, and then run them. A common use case for this is letting the LLM interact with your local file system. We provide an easy util to execute bash commands.
from langchain.utilities import BashProcess
bash = BashProcess()
print(bash.run("l... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/bash.html |
555f21df5b7f-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... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/chatgpt_plugins.html |
555f21df5b7f-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':... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/chatgpt_plugins.html |
555f21df5b7f-2 | 'responses': {'200': {'description': 'Products found', 'content': {'application/json': {'schema': {'$ref': '#/components/schemas/ProductResponse'}}}}, '503': {'description': 'one or more services are unavailable'}}, 'deprecated': False}}}, 'components': {'schemas': {'Product': {'type': 'object', 'properties': {'attribu... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/chatgpt_plugins.html |
555f21df5b7f-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 | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/chatgpt_plugins.html |
555f21df5b7f-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... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/chatgpt_plugins.html |
555f21df5b7f-5 | (Small-Large):S,XL,L,M"]},{"name":"Polo Classic Fit Cotton V-Neck T-Shirts 3-Pack","url":"https://www.klarna.com/us/shopping/pl/cl10001/3203028500/Clothing/Polo-Classic-Fit-Cotton-V-Neck-T-Shirts-3-Pack/?utm_source=openai","price":"$29.95","attributes":["Material:Cotton","Target Group:Man","Color:White,Blue,Black"]},{"... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/chatgpt_plugins.html |
555f21df5b7f-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... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/chatgpt_plugins.html |
24540c326d6e-0 | .ipynb
.pdf
Human as a tool
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.
import sys
from langchain.chat_models import ChatOpenAI
from langchain.llms import OpenAI
from langchain.agents import load_tools, initialize_agent
from langchain.agents import Ag... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/human_tools.html |
24540c326d6e-1 | Action: Calculator
Action Input: "Is 2021 a leap year?"
Observation: Answer: False
Thought:I have all the information I need to answer the original question.
Final Answer: Eric Zhu's birthday is on August 1st and it is not a leap year in 2021.
> Finished chain.
"Eric Zhu's birthday is on August 1st and it is not a leap... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/human_tools.html |
cc818135d6bf-0 | .ipynb
.pdf
Requests
Requests#
The web contains a lot of information that LLMs do not have access to. In order to easily let LLMs interact with that information, we provide a wrapper around the Python Requests module that takes in a URL and fetches data from that URL.
from langchain.utilities import TextRequestsWrapper... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html |
cc818135d6bf-1 | '<!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="en"><head><meta content="Search the world\'s information, including webpages, images, videos and more. Google has many special features to help you find exactly what you\'re looking for." name="description"><meta content="noodp" name="robots"... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html |
cc818135d6bf-2 | nonce="skA52jTjrFARNMkurZZTjQ">(function(){window.google={kEI:\'5dkIZP3HJ4WPur8PmJ23iAc\',kEXPI:\'0,18168,772936,568305,6059,206,4804,2316,383,246,5,1129120,1197787,614,165,379924,16115,28684,22431,1361,12313,17586,4998,13228,37471,4820,887,1985,2891,3926,7828,606,29842,826,19390,10632,15324,432,3,346,1244,1,5444,149,1... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html |
cc818135d6bf-3 | 4,1528,2304,29062,9871,3194,11443,2215,2980,10815,7428,5821,2536,4094,7596,1,42154,2,14022,2373,342,23024,5679,1021,31121,4569,6258,23418,1252,5835,14967,4333,7484,445,2,2,1,24626,2006,8155,7381,2,3,15965,872,9626,10008,7,1922,5784,3995,19130,2261,14763,6304,2008,18192,927,14678,4531,14,82,16514,3692,109,1513,899,879,2... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html |
cc818135d6bf-4 | ,879,2226,2751,1854,1931,156,8524,2426,721,1021,904,1423,4415,988,3030,426,5684,1411,23,867,2685,4720,1300,504,567,6974,9,184,26,469,2238,5,1648,109,1127,450,6708,5318,1002,258,3392,1991,4,29,212,2,375,537,1046,314,1720,78,890,1861,1,1172,2275,129,29,632,274,599,731,1305,392,307,536,592,87,113,762,845,2552,3788,220,669... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html |
cc818135d6bf-5 | 2,3788,220,669,3,750,1174,601,310,611,27,54,49,398,51,238,1079,67,3232,710,1652,82,5,667,2077,544,3,15,2,24,497,977,40,338,224,119,101,149,4,4,129,218,25,683,1,378,533,382,284,189,143,5,204,393,1137,781,4,81,1558,241,104,5232351,297,152,8798692,3311,141,795,19735,302,46,23950484,553,4041590,1964,1008,15665,2893,512,573... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html |
cc818135d6bf-6 | 665,2893,512,5738,12560,1540,1218,146,1415332\',kBL:\'Td3a\'};google.sn=\'webhp\';google.kHL=\'en\';})();(function(){\nvar | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html |
cc818135d6bf-7 | f=this||self;var h,k=[];function l(a){for(var b;a&&(!a.getAttribute||!(b=a.getAttribute("eid")));)a=a.parentNode;return b||h}function m(a){for(var b=null;a&&(!a.getAttribute||!(b=a.getAttribute("leid")));)a=a.parentNode;return b}\nfunction n(a,b,c,d,g){var e="";c||-1!==b.search("&ei=")||(e="&ei="+l(d),-1===b.search("&l... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html |
cc818135d6bf-8 | c};h=google.kEI;google.getEI=l;google.getLEI=m;google.ml=function(){return null};google.log=function(a,b,c,d,g){if(c=n(a,b,c,d,g)){a=new Image;var e=k.length;k[e]=a;a.onerror=a.onload=a.onabort=function(){delete k[e]};a.src=c}};google.logUrl=n;}).call(this);(function(){google.y={};google.sy=[];google.x=function(a,b){if... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html |
cc818135d6bf-9 | c=a.id;else{do c=Math.random();while(google.y[c])}google.y[c]=[a,b];return!1};google.sx=function(a){google.sy.push(a)};google.lm=[];google.plm=function(a){google.lm.push.apply(google.lm,a)};google.lq=[];google.load=function(a,b,c){google.lq.push([[a],b,c])};google.loadAll=function(a,b){google.lq.push([a,b])};google.bx=... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html |
cc818135d6bf-10 | a;a:{for(a=b.target;a&&a!==document.documentElement;a=a.parentElement)if("A"===a.tagName){a="1"===a.getAttribute("data-nohref");break a}a=!1}a&&b.preventDefault()},!0);}).call(this);</script><style>#gbar,#guser{font-size:13px;padding-top:1px !important;}#gbar{height:22px}#guser{padding-bottom:7px !important;text-align:... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html |
cc818135d6bf-11 | 0}td{line-height:.8em}.gac_m td{line-height:17px}form{margin-bottom:20px}.h{color:#1558d6}em{font-weight:bold;font-style:normal}.lst{height:25px;width:496px}.gsfi,.lst{font:18px arial,sans-serif}.gsfs{font:17px arial,sans-serif}.ds{display:inline-box;display:inline-block;margin:3px 0 4px;margin-left:4px}input{font-fami... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html |
cc818135d6bf-12 | 0 -261px repeat-x;border:none;color:#000;cursor:pointer;height:30px;margin:0;outline:0;font:15px arial,sans-serif;vertical-align:top}.lsb:active{background:#dadce0}.lst:focus{outline:none}</style><script nonce="skA52jTjrFARNMkurZZTjQ">(function(){window.google.erd={jsr:1,bv:1756,de:true};\nvar h=this||self;var k,l=null... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html |
cc818135d6bf-13 | c="/gen_204?atyp=i&ei="+b(google.kEI);google.kEXPI&&(c+="&jexpid="+b(google.kEXPI));c+="&srcpg="+b(google.sn)+"&jsr="+b(t.jsr)+"&bver="+b(t.bv);var f=a.lineNumber;void 0!==f&&(c+="&line="+f);var g=\na.fileName;g&&(0<g.indexOf("-extension:/")&&(e=3),c+="&script="+b(g),f&&g===window.location.href&&(f=document.documentEle... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html |
cc818135d6bf-14 | instanceof Error?e:Error(a),void 0===d||"lineNumber"in a||(a.lineNumber=d),void 0===b||"fileName"in a||(a.fileName=b),google.ml(a,!1,void 0,!1,"SyntaxError"===a.name||"SyntaxError"===a.message.substring(0,11)||-1!==a.message.indexOf("Script error")?3:0));r=null;p&&q>=l&&(window.onerror=null)};})();</script></head><body... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html |
cc818135d6bf-15 | <a class=gb1 href="https://maps.google.com/maps?hl=en&tab=wl">Maps</a> <a class=gb1 href="https://play.google.com/?hl=en&tab=w8">Play</a> <a class=gb1 href="https://www.youtube.com/?tab=w1">YouTube</a> <a class=gb1 href="https://news.google.com/?tab=wn">News</a> <a class=gb1 href="https://mail.google.com/mail/?tab=wm">... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html |
cc818135d6bf-16 | class=gb4>Sign in</a></nobr></div><div class=gbh style=left:0></div><div class=gbh style=right:0></div></div><center><br clear="all" id="lgpd"><div id="lga"><a href="/search?ie=UTF-8&q=International+Women%27s+Day&oi=ddle&ct=207425752&hl=en&si=AEcPFx5y3cpWB8t3QIlw940Bbgd-HLN-aNYSTraERzz0WyAsdPcV8QlbA... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html |
cc818135d6bf-17 | name="f"><table cellpadding="0" cellspacing="0"><tr valign="top"><td width="25%"> </td><td align="center" nowrap=""><input name="ie" value="ISO-8859-1" type="hidden"><input value="en" name="hl" type="hidden"><input name="source" type="hidden" value="hp"><input name="biw" type="hidden"><input name="bih" type="hidde... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html |
cc818135d6bf-18 | (this.form.q.value){this.checked = 1;if (this.form.iflsig)this.form.iflsig.disabled = false;}\nelse top.location=\'/doodles/\';};})();</script><input value="AK50M_UAAAAAZAjn9T7DxAH0-e8rhw3d8palbJFsdibi" name="iflsig" type="hidden"></span></span></td><td class="fl sblc" align="left" nowrap="" width="25%"><a href="/advan... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html |
cc818135d6bf-19 | ActiveXObject(d),b="2"}catch(h){}}a=b;if("2"==a&&-1==location.search.indexOf("&gbv=2")){var f=google.gbvu,g=document.getElementById("gbv");g&&(g.value=a);f&&window.setTimeout(function(){location.href=f},0)};}).call(this);</script></form><div id="gac_scont"></div><div style="font-size:83%;min-height:3.5em"><br><div id="... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html |
cc818135d6bf-20 | </span><a class="NKcBbd" href="https://www.google.com/url?q=https://artsandculture.google.com/project/women-in-culture%3Futm_source%3Dgoogle%26utm_medium%3Dhppromo%26utm_campaign%3Dinternationalwomensday23&source=hpp&id=19034031&ct=3&usg=AOvVaw1Q51Nb9U7JNUznM352o8BF&sa=X&ved=0ahUKEwi9zuH2gM39AhW... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html |
cc818135d6bf-21 | nonce="skA52jTjrFARNMkurZZTjQ">(function(){window.google.cdo={height:757,width:1440};(function(){var a=window.innerWidth,b=window.innerHeight;if(!a||!b){var c=window.document,d="CSS1Compat"==c.compatMode?c.documentElement:c.body;a=d.clientWidth;b=d.clientHeight}a&&b&&(a!=google.cdo.width||b!=google.cdo.height)&&google.... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html |
cc818135d6bf-22 | u=\'/xjs/_/js/k\\x3dxjs.hp.en.ObwAV4EjOBQ.O/am\\x3dAACgEwBAAYAF/d\\x3d1/ed\\x3d1/rs\\x3dACT90oGDUDSLlBIGF3CSmUWoHe0AKqeZ6w/m\\x3dsb_he,d\';var amd=0;\nvar d=this||self,e=function(a){return a};var g;var l=function(a,b){this.g=b===h?a:""};l.prototype.toString=function(){return this.g+""};var h={};\nfunction m(){var a=u;g... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html |
cc818135d6bf-23 | 0===g){b=null;var k=d.trustedTypes;if(k&&k.createPolicy){try{b=k.createPolicy("goog#html",{createHTML:e,createScript:e,createScriptURL:e})}catch(q){d.console&&d.console.error(q.message)}g=b}else g=b}a=(b=g)?b.createScriptURL(a):a;a=new l(a,h);c.src=\na instanceof l&&a.constructor===l?a.g:"type_error:TrustedResourceUrl"... | /content/https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.