id stringlengths 14 16 | text stringlengths 36 2.73k | source stringlengths 49 117 |
|---|---|---|
422e1aad04d4-0 | .ipynb
.pdf
MRKL
MRKL#
This notebook showcases using an agent to replicate the MRKL chain.
This uses the example Chinook database.
To set it up follow the instructions on https://database.guide/2-sample-databases-sqlite/, placing the .db file in a notebooks folder at the root of this repository.
from langchain import L... | https://python.langchain.com/en/latest/modules/agents/agents/examples/mrkl.html |
422e1aad04d4-1 | > Entering new AgentExecutor chain...
I need to find out who Leo DiCaprio's girlfriend is and then calculate her age raised to the 0.43 power.
Action: Search
Action Input: "Who is Leo DiCaprio's girlfriend?"
Observation: DiCaprio met actor Camila Morrone in December 2017, when she was 20 and he was 43. They were spott... | https://python.langchain.com/en/latest/modules/agents/agents/examples/mrkl.html |
422e1aad04d4-2 | > Entering new AgentExecutor chain...
I need to find out the artist's full name and then search the FooBar database for their albums.
Action: Search
Action Input: "The Storm Before the Calm" artist
Observation: The Storm Before the Calm (stylized in all lowercase) is the tenth (and eighth international) studio album b... | https://python.langchain.com/en/latest/modules/agents/agents/examples/mrkl.html |
422e1aad04d4-3 | Thought: I now know the final answer.
Final Answer: The artist who released the album 'The Storm Before the Calm' is Alanis Morissette and the albums of hers in the FooBar database are Jagged Little Pill.
> Finished chain.
"The artist who released the album 'The Storm Before the Calm' is Alanis Morissette and the album... | https://python.langchain.com/en/latest/modules/agents/agents/examples/mrkl.html |
d4e8a596bb5b-0 | .md
.pdf
Getting Started
Contents
List of Tools
Getting Started#
Tools are functions that agents can use to interact with the world.
These tools can be generic utilities (e.g. search), other chains, or even other agents.
Currently, tools can be loaded with the following snippet:
from langchain.agents import load_tool... | https://python.langchain.com/en/latest/modules/agents/tools/getting_started.html |
d4e8a596bb5b-1 | 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 Wolfram Alpha API and then parses results.
Requires ... | https://python.langchain.com/en/latest/modules/agents/tools/getting_started.html |
d4e8a596bb5b-2 | 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. The input should be a question in natural language that this API can answer.
Notes: A natural language connection to the Open Meteo API (https://api.open-meteo.com/), ... | https://python.langchain.com/en/latest/modules/agents/tools/getting_started.html |
d4e8a596bb5b-3 | For more information on this, see this page
searx-search
Tool Name: Search
Tool Description: A wrapper around SearxNG meta search engine. Input should be a search query.
Notes: SearxNG is easy to deploy self-hosted. It is a good privacy friendly alternative to Google Search. Uses the SearxNG API.
Requires LLM: No
Extra... | https://python.langchain.com/en/latest/modules/agents/tools/getting_started.html |
d4e8a596bb5b-4 | Notes: A connection to the OpenWeatherMap API (https://api.openweathermap.org), specifically the /data/2.5/weather endpoint.
Requires LLM: No
Extra Parameters: openweathermap_api_key (your API key to access this endpoint)
previous
Tools
next
Defining Custom Tools
Contents
List of Tools
By Harrison Chase
... | https://python.langchain.com/en/latest/modules/agents/tools/getting_started.html |
e6531256ba05-0 | .ipynb
.pdf
Multi-Input Tools
Contents
Multi-Input Tools with a string format
Multi-Input Tools#
This notebook shows how to use a tool that requires multiple inputs with an agent. The recommended way to do so is with the StructuredTool class.
import os
os.environ["LANGCHAIN_TRACING"] = "true"
from langchain import Op... | https://python.langchain.com/en/latest/modules/agents/tools/multi_input_tool.html |
e6531256ba05-1 | '3 times 4 is 12'
Multi-Input Tools with a string format#
An alternative to the structured tool would be to use the regular Tool class and accept a single string. The tool would then have to handle the parsing logic to extract the relavent values from the text, which tightly couples the tool representation to the agent... | https://python.langchain.com/en/latest/modules/agents/tools/multi_input_tool.html |
e6531256ba05-2 | > Entering new AgentExecutor chain...
I need to multiply two numbers
Action: Multiplier
Action Input: 3,4
Observation: 12
Thought: I now know the final answer
Final Answer: 3 times 4 is 12
> Finished chain.
'3 times 4 is 12'
previous
Defining Custom Tools
next
Tool Input Schema
Contents
Multi-Input Tools with a st... | https://python.langchain.com/en/latest/modules/agents/tools/multi_input_tool.html |
d7d02dc557f7-0 | .ipynb
.pdf
Tool Input Schema
Tool Input Schema#
By default, tools infer the argument schema by inspecting the function signature. For more strict requirements, custom input schema can be specified, along with custom validation logic.
from typing import Any, Dict
from langchain.agents import AgentType, initialize_agent... | https://python.langchain.com/en/latest/modules/agents/tools/tool_input_validation.html |
d7d02dc557f7-1 | answer = agent.run("What's the main title on langchain.com?")
print(answer)
The main title of langchain.com is "LANG CHAIN 🦜️🔗 Official Home Page"
agent.run("What's the main title on google.com?")
---------------------------------------------------------------------------
ValidationError Tra... | https://python.langchain.com/en/latest/modules/agents/tools/tool_input_validation.html |
d7d02dc557f7-2 | 112 try:
--> 113 outputs = self._call(inputs)
114 except (KeyboardInterrupt, Exception) as e:
115 self.callback_manager.on_chain_error(e, verbose=self.verbose)
File ~/code/lc/lckg/langchain/agents/agent.py:792, in AgentExecutor._call(self, inputs)
790 # We now enter the agent loop (until it returns ... | https://python.langchain.com/en/latest/modules/agents/tools/tool_input_validation.html |
d7d02dc557f7-3 | 103 tool_input: Union[str, Dict],
(...)
107 **kwargs: Any,
108 ) -> str:
109 """Run the tool."""
--> 110 run_input = self._parse_input(tool_input)
111 if not self.verbose and verbose is not None:
112 verbose_ = verbose
File ~/code/lc/lckg/langchain/tools/base.py:71, in... | https://python.langchain.com/en/latest/modules/agents/tools/tool_input_validation.html |
2ebff0101125-0 | .ipynb
.pdf
Defining Custom Tools
Contents
Completely New Tools - String Input and Output
Tool dataclass
Subclassing the BaseTool class
Using the tool decorator
Custom Structured Tools
StructuredTool dataclass
Subclassing the BaseTool
Using the decorator
Modify existing tools
Defining the priorities among Tools
Using... | https://python.langchain.com/en/latest/modules/agents/tools/custom_tools.html |
2ebff0101125-1 | Tool dataclass#
The ‘Tool’ dataclass wraps functions that accept a single string input and returns a string output.
# Load the tool configs that are needed.
search = SerpAPIWrapper()
llm_math_chain = LLMMathChain(llm=llm, verbose=True)
tools = [
Tool.from_function(
func=search.run,
name = "Search",
... | https://python.langchain.com/en/latest/modules/agents/tools/custom_tools.html |
2ebff0101125-2 | > Entering new AgentExecutor chain...
I need to find out Leo DiCaprio's girlfriend's name and her age
Action: Search
Action Input: "Leo DiCaprio girlfriend"
Observation: After rumours of a romance with Gigi Hadid, the Oscar winner has seemingly moved on. First being linked to the television personality in September 202... | https://python.langchain.com/en/latest/modules/agents/tools/custom_tools.html |
2ebff0101125-3 | Subclassing the BaseTool class#
You can also directly subclass BaseTool. This is useful if you want more control over the instance variables or if you want to propagate callbacks to nested chains or other tools.
from typing import Optional, Type
from langchain.callbacks.manager import AsyncCallbackManagerForToolRun, Ca... | https://python.langchain.com/en/latest/modules/agents/tools/custom_tools.html |
2ebff0101125-4 | agent.run("Who is Leo DiCaprio's girlfriend? What is her current age raised to the 0.43 power?")
> Entering new AgentExecutor chain...
I need to use custom_search to find out who Leo DiCaprio's girlfriend is, and then use the Calculator to raise her age to the 0.43 power.
Action: custom_search
Action Input: "Leo DiCapr... | https://python.langchain.com/en/latest/modules/agents/tools/custom_tools.html |
2ebff0101125-5 | > Finished chain.
'3.547023357958959'
Using the tool decorator#
To make it easier to define custom tools, a @tool decorator is provided. This decorator can be used to quickly create a Tool from a simple function. The decorator uses the function name as the tool name by default, but this can be overridden by passing a s... | https://python.langchain.com/en/latest/modules/agents/tools/custom_tools.html |
2ebff0101125-6 | """Searches the API for the query."""
return "Results"
search_api
Tool(name='search', description='search(query: str) -> str - Searches the API for the query.', args_schema=<class '__main__.SearchInput'>, return_direct=True, verbose=False, callback_manager=<langchain.callbacks.shared.SharedCallbackManager object at... | https://python.langchain.com/en/latest/modules/agents/tools/custom_tools.html |
2ebff0101125-7 | """Use the tool."""
search_wrapper = SerpAPIWrapper(params={"engine": engine, "gl": gl, "hl": hl})
return search_wrapper.run(query)
async def _arun(self, query: str, engine: str = "google", gl: str = "us", hl: str = "en", run_manager: Optional[AsyncCallbackManagerForToolRun] = None) -> str:
... | https://python.langchain.com/en/latest/modules/agents/tools/custom_tools.html |
2ebff0101125-8 | """Use the tool asynchronously."""
raise NotImplementedError("custom_search does not support async")
Using the decorator#
The tool decorator creates a structured tool automatically if the signature has multiple arguments.
import requests
from langchain.tools import tool
@tool
def post_message(url: str... | https://python.langchain.com/en/latest/modules/agents/tools/custom_tools.html |
2ebff0101125-9 | Action: Google Search
Action Input: "Leo DiCaprio current girlfriend age"
Observation: Leonardo DiCaprio has been linked with 19-year-old model Eden Polani, continuing the rumour that he doesn't date any women over the age of ...
Thought:I need to find out the age of Eden Polani.
Action: Calculator
Action Input: 19^(0.... | https://python.langchain.com/en/latest/modules/agents/tools/custom_tools.html |
2ebff0101125-10 | tools = [
Tool(
name = "Search",
func=search.run,
description="useful for when you need to answer questions about current events"
),
Tool(
name="Music Search",
func=lambda x: "'All I Want For Christmas Is You' by Mariah Carey.", #Mock Function
description="A M... | https://python.langchain.com/en/latest/modules/agents/tools/custom_tools.html |
2ebff0101125-11 | return_direct=True
)
]
llm = OpenAI(temperature=0)
agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True)
agent.run("whats 2**.12")
> Entering new AgentExecutor chain...
I need to calculate this
Action: Calculator
Action Input: 2**.12Answer: 1.086734862526058
> Finished cha... | https://python.langchain.com/en/latest/modules/agents/tools/custom_tools.html |
5d51269a1462-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... | https://python.langchain.com/en/latest/modules/agents/tools/examples/apify.html |
5d51269a1462-1 | loader = apify.call_actor(
actor_id="apify/website-content-crawler",
run_input={"startUrls": [{"url": "https://python.langchain.com/en/latest/"}]},
dataset_mapping_function=lambda item: Document(
page_content=item["text"] or "", metadata={"source": item["url"]}
),
)
Initialize the vector index f... | https://python.langchain.com/en/latest/modules/agents/tools/examples/apify.html |
90dc3b0df7d7-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 |
90dc3b0df7d7-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 |
90dc3b0df7d7-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 |
90dc3b0df7d7-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 |
90dc3b0df7d7-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 |
90dc3b0df7d7-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 |
90dc3b0df7d7-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 |
90dc3b0df7d7-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 |
55f919e871db-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.... | https://python.langchain.com/en/latest/modules/agents/tools/examples/google_search.html |
55f919e871db-1 | tool.run("Obama's first name?")
"STATE OF HAWAII. 1 Child's First Name. (Type or print). 2. Sex. BARACK. 3. This Birth. CERTIFICATE OF LIVE BIRTH. FILE. NUMBER 151 le. lb. Middle Name. Barack Hussein Obama II is an American former politician who served as the 44th president of the United States from 2009 to 2017. A mem... | https://python.langchain.com/en/latest/modules/agents/tools/examples/google_search.html |
55f919e871db-2 | Number of Results#
You can use the k parameter to set the number of results
search = GoogleSearchAPIWrapper(k=1)
tool = Tool(
name = "I'm Feeling Lucky",
description="Search Google and return the first result.",
func=search.run
)
tool.run("python")
'The official home of the Python Programming Language.'
‘Th... | https://python.langchain.com/en/latest/modules/agents/tools/examples/google_search.html |
d299b3cbf12e-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 |
d299b3cbf12e-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 |
d299b3cbf12e-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 |
0e8924b050a0-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 |
0e8924b050a0-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 |
0e8924b050a0-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 |
0e8924b050a0-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 |
0e8924b050a0-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 |
0e8924b050a0-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 |
0e8924b050a0-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 |
cdb1eda32e2c-0 | .ipynb
.pdf
Google Serper API
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
Google Serper API#
This notebook goes over how to use the Google Serper component to search the web. First you need to sign u... | https://python.langchain.com/en/latest/modules/agents/tools/examples/google_serper.html |
cdb1eda32e2c-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'
Obtaining results with metadata#
If you would also like to obtain the results in a structured way including metadata. For this we will be using the results method ... | https://python.langchain.com/en/latest/modules/agents/tools/examples/google_serper.html |
cdb1eda32e2c-2 | 'CEO': 'Tim Cook (Aug 24, 2011–)',
'Headquarters': 'Cupertino, CA',
'Founded': 'April 1, 1976, Los Altos, CA',
'Founders': 'Steve Jobs, Steve Wozniak, '
'Ronald Wayne, ... | https://python.langchain.com/en/latest/modules/agents/tools/examples/google_serper.html |
cdb1eda32e2c-3 | "Apple is the world's largest technology company by "
'revenue, ...',
'attributes': {'Products': 'AirPods; Apple Watch; iPad; iPhone; '
'Mac; Full list',
'Founders': 'Steve Jobs; Steve Wozniak; Ronald '
... | https://python.langchain.com/en/latest/modules/agents/tools/examples/google_serper.html |
cdb1eda32e2c-4 | 'attributes': {'Related People': 'Steve Jobs Steve Wozniak Jony '
'Ive Tim Cook Angela Ahrendts',
'Date': '1976 - present'},
'imageUrl': 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcS3liELlhrMz3Wpsox29U8jJ3L8qETR0hBWHXbF... | https://python.langchain.com/en/latest/modules/agents/tools/examples/google_serper.html |
cdb1eda32e2c-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 |
cdb1eda32e2c-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 |
cdb1eda32e2c-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 |
cdb1eda32e2c-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 |
cdb1eda32e2c-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 |
cdb1eda32e2c-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 |
cdb1eda32e2c-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 |
cdb1eda32e2c-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 |
cdb1eda32e2c-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 |
cdb1eda32e2c-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 |
cdb1eda32e2c-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 |
cdb1eda32e2c-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 |
cdb1eda32e2c-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 |
cdb1eda32e2c-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 |
cdb1eda32e2c-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 |
cdb1eda32e2c-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 |
cdb1eda32e2c-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 |
cdb1eda32e2c-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 |
cdb1eda32e2c-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 |
cdb1eda32e2c-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 |
cdb1eda32e2c-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 |
41bb065829e7-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 |
41bb065829e7-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 |
41bb065829e7-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 |
41bb065829e7-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 |
41bb065829e7-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 |
41bb065829e7-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 |
41bb065829e7-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 |
b40e113f63c7-0 | .ipynb
.pdf
AWS Lambda API
AWS Lambda API#
This notebook goes over how to use the AWS Lambda Tool component.
AWS Lambda is a serverless computing service provided by Amazon Web Services (AWS), designed to allow developers to build and run applications and services without the need for provisioning or managing servers. ... | https://python.langchain.com/en/latest/modules/agents/tools/examples/awslambda.html |
b40e113f63c7-1 | agent.run("Send an email to test@testing123.com saying hello world.")
previous
ArXiv API Tool
next
Shell Tool
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on May 28, 2023. | https://python.langchain.com/en/latest/modules/agents/tools/examples/awslambda.html |
40cb057d1304-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... | https://python.langchain.com/en/latest/modules/agents/tools/examples/google_places.html |
6512b113544f-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 |
6512b113544f-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 |
6512b113544f-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 |
6512b113544f-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 |
cec7bb3b0cad-0 | .ipynb
.pdf
Twilio
Contents
Setup
Sending a message
Twilio#
This notebook goes over how to use the Twilio API wrapper to send a text message.
Setup#
To use this tool you need to install the Python Twilio package twilio
# !pip install twilio
You’ll also need to set up a Twilio account and get your credentials. You’ll ... | https://python.langchain.com/en/latest/modules/agents/tools/examples/twilio.html |
9f838025c411-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... | https://python.langchain.com/en/latest/modules/agents/tools/examples/zapier.html |
9f838025c411-1 | os.environ["OPENAI_API_KEY"] = os.environ.get("OPENAI_API_KEY", "")
# get from https://nla.zapier.com/demo/provider/debug (under User Information, after logging in):
os.environ["ZAPIER_NLA_API_KEY"] = os.environ.get("ZAPIER_NLA_API_KEY", "")
Example with Agent#
Zapier tools can be used with an agent. See the example b... | https://python.langchain.com/en/latest/modules/agents/tools/examples/zapier.html |
9f838025c411-2 | 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... | https://python.langchain.com/en/latest/modules/agents/tools/examples/zapier.html |
9f838025c411-3 | Observation: {"message__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.", "message__permalink": "https://langchain.slack.com/archives/C04TSGU0RA7/p1678859932375259", "channel": "C04TSGU0RA7",... | https://python.langchain.com/en/latest/modules/agents/tools/examples/zapier.html |
9f838025c411-4 | from langchain.tools.zapier.tool import ZapierNLARunAction
from langchain.utilities.zapier import ZapierNLAWrapper
## step 0. expose gmail 'find email' and slack 'send direct message' actions
# first go here, log in, expose (enable) the two actions: https://nla.zapier.com/demo/start -- for this example, can leave all f... | https://python.langchain.com/en/latest/modules/agents/tools/examples/zapier.html |
9f838025c411-5 | SLACK_HANDLE = "@Ankush Gola"
def nla_slack(inputs):
action = next((a for a in actions if a["description"].startswith("Slack: Send Direct Message")), None)
instructions = f'Send this to {SLACK_HANDLE} in Slack: {inputs["draft_reply"]}'
return {"slack_data": ZapierNLARunAction(action_id=action["id"], zapier_... | https://python.langchain.com/en/latest/modules/agents/tools/examples/zapier.html |
9f838025c411-6 | overall_chain.run(GMAIL_SEARCH_INSTRUCTIONS)
> 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 & h... | https://python.langchain.com/en/latest/modules/agents/tools/examples/zapier.html |
9f838025c411-7 | 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[... | https://python.langchain.com/en/latest/modules/agents/tools/examples/zapier.html |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.