id stringlengths 14 16 | text stringlengths 36 2.73k | source stringlengths 59 127 |
|---|---|---|
1fdbd6154f14-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... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/tool_input_validation.html |
1fdbd6154f14-1 | 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 Traceback (most recent call last)
Cell In[7], line 1
----> 1 agen... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/tool_input_validation.html |
1fdbd6154f14-2 | 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 something).
791 while self._should_continue(iterat... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/tool_input_validation.html |
1fdbd6154f14-3 | 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 BaseTool._parse_input(self, tool_input)
69 if... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/tool_input_validation.html |
b23ed91ac55a-0 | .ipynb
.pdf
Human-in-the-loop Tool Validation
Contents
Adding Human Approval
Configuring Human Approval
Human-in-the-loop Tool Validation#
This walkthrough demonstrates how to add Human validation to any Tool. We’ll do this using the HumanApprovalCallbackhandler.
Let’s suppose we need to make use of the ShellTool. Ad... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/human_approval.html |
b23ed91ac55a-1 | ----> 1 print(tool.run("ls /private"))
File ~/langchain/langchain/tools/base.py:257, in BaseTool.run(self, tool_input, verbose, start_color, color, callbacks, **kwargs)
255 # TODO: maybe also pass through run_manager is _run supports kwargs
256 new_arg_supported = signature(self._run).parameters.get("run_manage... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/human_approval.html |
b23ed91ac55a-2 | 155 except Exception as e:
156 if handler.raise_error:
--> 157 raise e
158 logging.warning(f"Error in {event_name} callback: {e}")
File ~/langchain/langchain/callbacks/manager.py:139, in _handle_event(handlers, event_name, ignore_condition_name, *args, **kwargs)
135 try:
136 if ignor... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/human_approval.html |
b23ed91ac55a-3 | from langchain.agents import load_tools
from langchain.agents import initialize_agent
from langchain.agents import AgentType
from langchain.llms import OpenAI
def _should_check(serialized_obj: dict) -> bool:
# Only require approval on ShellTool.
return serialized_obj.get("name") == "terminal"
def _approve(_inpu... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/human_approval.html |
b23ed91ac55a-4 | ls /private
no
---------------------------------------------------------------------------
HumanRejectedException Traceback (most recent call last)
Cell In[39], line 1
----> 1 agent.run("list all directories in /private", callbacks=callbacks)
File ~/langchain/langchain/chains/base.py:236, in Chain.ru... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/human_approval.html |
b23ed91ac55a-5 | 139 run_manager.on_chain_error(e)
File ~/langchain/langchain/agents/agent.py:953, in AgentExecutor._call(self, inputs, run_manager)
951 # We now enter the agent loop (until it returns something).
952 while self._should_continue(iterations, time_elapsed):
--> 953 next_step_output = self._take_next_step(
... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/human_approval.html |
b23ed91ac55a-6 | 255 # TODO: maybe also pass through run_manager is _run supports kwargs
256 new_arg_supported = signature(self._run).parameters.get("run_manager")
--> 257 run_manager = callback_manager.on_tool_start(
258 {"name": self.name, "description": self.description},
259 tool_input if isinstance(tool_input, ... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/human_approval.html |
b23ed91ac55a-7 | 158 logging.warning(f"Error in {event_name} callback: {e}")
File ~/langchain/langchain/callbacks/manager.py:139, in _handle_event(handlers, event_name, ignore_condition_name, *args, **kwargs)
135 try:
136 if ignore_condition_name is None or not getattr(
137 handler, ignore_condition_name
... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/human_approval.html |
244a11d1ae0c-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... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/custom_tools.html |
244a11d1ae0c-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",
... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/custom_tools.html |
244a11d1ae0c-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... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/custom_tools.html |
244a11d1ae0c-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... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/custom_tools.html |
244a11d1ae0c-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... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/custom_tools.html |
244a11d1ae0c-5 | '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 string as the first... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/custom_tools.html |
244a11d1ae0c-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... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/custom_tools.html |
244a11d1ae0c-7 | description = "useful for when you need to answer questions about current events"
def _run(self, query: str, engine: str = "google", gl: str = "us", hl: str = "en", run_manager: Optional[CallbackManagerForToolRun] = None) -> str:
"""Use the tool."""
search_wrapper = SerpAPIWrapper(params={"engine": ... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/custom_tools.html |
244a11d1ae0c-8 | 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:
"""Use the tool asynchronously."""
raise NotImplementedError("custom_search does not support async")
... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/custom_tools.html |
244a11d1ae0c-9 | Action: Google 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 2022, it appears as if his "age bracket" has moved up. This follows his rumoured relationship with... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/custom_tools.html |
244a11d1ae0c-10 | An example is below.
# Import things that are needed generically
from langchain.agents import initialize_agent, Tool
from langchain.agents import AgentType
from langchain.llms import OpenAI
from langchain import LLMMathChain, SerpAPIWrapper
search = SerpAPIWrapper()
tools = [
Tool(
name = "Search",
... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/custom_tools.html |
244a11d1ae0c-11 | llm_math_chain = LLMMathChain(llm=llm)
tools = [
Tool(
name="Calculator",
func=llm_math_chain.run,
description="useful for when you need to answer questions about math",
return_direct=True
)
]
llm = OpenAI(temperature=0)
agent = initialize_agent(tools, llm, agent=AgentType.ZERO_S... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/custom_tools.html |
244a11d1ae0c-12 | from langchain.chat_models import ChatOpenAI
from langchain.tools import Tool
from langchain.chat_models import ChatOpenAI
def _handle_error(error:ToolException) -> str:
return "The following errors occurred during tool execution:" + error.args[0]+ "Please try another tool."
def search_tool1(s: str):raise ToolExce... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/custom_tools.html |
244a11d1ae0c-13 | Thought:I should try using Search_tool2 instead.
Action: Search_tool2
Action Input: "Leo DiCaprio girlfriend"
Observation: The following errors occurred during tool execution:The search tool2 is not available.Please try another tool.
Thought:I should try using Search_tool3 as a last resort.
Action: Search_tool3
Action ... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/custom_tools.html |
b3e708726df4-0 | .ipynb
.pdf
Tools as OpenAI Functions
Tools as OpenAI Functions#
This notebook goes over how to use LangChain tools as OpenAI functions.
from langchain.chat_models import ChatOpenAI
from langchain.schema import HumanMessage
model = ChatOpenAI(model="gpt-3.5-turbo-0613")
from langchain.tools import MoveFileTool, format_... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/tools_as_openai_functions.html |
f1de38e13416-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... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/getting_started.html |
f1de38e13416-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 ... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/getting_started.html |
f1de38e13416-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/), ... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/getting_started.html |
f1de38e13416-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... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/getting_started.html |
f1de38e13416-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)
sleep
Tool Name: Sleep
Tool Description: Make agent sleep for some time.
Requires LLM: No
previous... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/getting_started.html |
c367a91ffc9a-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 DuckDuckGoSearchRun
search = DuckDuckGoSearchRun()
search.run("Obama's first name?") | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/ddg.html |
c367a91ffc9a-1 | '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 Hussein Obama II (/ b ə ˈ r ɑː k ... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/ddg.html |
c367a91ffc9a-2 | previous
ChatGPT Plugins
next
File System Tools
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on Jun 16, 2023. | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/ddg.html |
c4c96b676a7e-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.... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/bing_search.html |
c4c96b676a7e-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... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/bing_search.html |
c4c96b676a7e-2 | 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-purpose, versatile, and powerful programming language. It's a great first language because <b>Python</b> code is concise and easy to read. Wh... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/bing_search.html |
c4c96b676a7e-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... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/bing_search.html |
c4c96b676a7e-4 | {'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... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/bing_search.html |
2d747a9cb6cf-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',... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/youtube.html |
279c2126df90-0 | .ipynb
.pdf
Requests
Contents
Inside the tool
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.agents im... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/requests.html |
279c2126df90-1 | RequestsPatchTool(name='requests_patch', description='Use this when you want to PATCH to a website.\n Input should be a json string with two keys: "url" and "data".\n The value of "url" should be a string, and the value of "data" should be a dictionary of \n key-value pairs you want to PATCH to the url.\n B... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/requests.html |
279c2126df90-2 | Each requests tool contains a requests wrapper. You can work with these wrappers directly below
# Each tool wrapps a requests wrapper
requests_tools[0].requests_wrapper
TextRequestsWrapper(headers=None, aiosession=None)
from langchain.utilities import TextRequestsWrapper
requests = TextRequestsWrapper()
requests.get("h... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/requests.html |
279c2126df90-3 | '<!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"... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/requests.html |
279c2126df90-4 | nonce="MXrF0nnIBPkxBza4okrgPA">(function(){window.google={kEI:\'TA9QZOa5EdTakPIPuIad-Ac\',kEXPI:\'0,1359409,6059,206,4804,2316,383,246,5,1129120,1197768,626,380097,16111,28687,22431,1361,12319,17581,4997,13228,37471,7692,2891,3926,213,7615,606,50058,8228,17728,432,3,346,1244,1,16920,2648,4,1528,2304,29062,9871,3194,136... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/requests.html |
279c2126df90-5 | ,342,23024,6699,31123,4568,6258,23418,1252,5835,14967,4333,4239,3245,445,2,2,1,26632,239,7916,7321,60,2,3,15965,872,7830,1796,10008,7,1922,9779,36154,6305,2007,17765,427,20136,14,82,2730,184,13600,3692,109,2412,1548,4308,3785,15175,3888,1515,3030,5628,478,4,9706,1804,7734,2738,1853,1032,9480,2995,576,1041,5648,3722,205... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/requests.html |
279c2126df90-6 | ,1439,1128,7343,426,249,517,95,1102,14,696,1270,750,400,2208,274,2776,164,89,119,204,139,129,1710,2505,320,3,631,439,2,300,1645,172,1783,784,169,642,329,401,50,479,614,238,757,535,717,102,2,739,738,44,232,22,442,961,45,214,383,567,500,487,151,120,256,253,179,673,2,102,2,10,535,123,135,1685,5206695,190,2,20,50,198,59942... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/requests.html |
279c2126df90-7 | 9,1,5,1,16,7,2,41,247,4,9,7,9,15,4,4,121,24,23944834,4042142,1964,16672,2894,6250,15739,1726,647,409,837,1411438,146986,23612960,7,84,93,33,101,816,57,532,163,1,441,86,1,951,73,31,2,345,178,243,472,2,148,962,455,167,178,29,702,1856,288,292,805,93,137,68,416,177,292,399,55,95,2566\',kBL:\'hw1A\',kOPI:89978449};google.sn... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/requests.html |
279c2126df90-8 | h=this||self;function l(){return void 0!==window.google&&void 0!==window.google.kOPI&&0!==window.google.kOPI?window.google.kOPI:null};var m,n=[];function p(a){for(var b;a&&(!a.getAttribute||!(b=a.getAttribute("eid")));)a=a.parentNode;return b||m}function q(a){for(var b=null;a&&(!a.getAttribute||!(b=a.getAttribute("leid... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/requests.html |
279c2126df90-9 | null};google.log=function(a,b,c,d,k,e){e=void 0===e?l:e;c||(c=t(a,b,e,d,k));if(c=r(c)){a=new Image;var g=n.length;n[g]=a;a.onerror=a.onload=a.onabort=function(){delete n[g]};a.src=c}};google.logUrl=function(a,b){b=void 0===b?l:b;return t("",a,b)};}).call(this);(function(){google.y={};google.sy=[];google.x=function(a,b)... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/requests.html |
279c2126df90-10 | !important;}#gbar{height:22px}#guser{padding-bottom:7px !important;text-align:right}.gbh,.gbd{border-top:1px solid #c9d7f1;font-size:1px}.gbh{height:0;position:absolute;top:24px;width:100%}@media all{.gb1{height:22px;margin-right:.5em;vertical-align:top}#gbar{float:left}}a.gb1,a.gb4{text-decoration:underline !important... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/requests.html |
279c2126df90-11 | a{display:block;margin:2px 0;margin-left:13px;font-size:11px}.lsbb{background:#f8f9fa;border:solid 1px;border-color:#dadce0 #70757a #70757a #dadce0;height:30px}.lsbb{display:block}#WqQANb a{display:inline-block;margin:0 12px}.lsb{background:url(/images/nav_logo229.png) 0 -261px repeat-x;border:none;color:#000;cursor:po... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/requests.html |
279c2126df90-12 | null;q++;d=d||{};b=encodeURIComponent;var 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===win... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/requests.html |
279c2126df90-13 | nonce="MXrF0nnIBPkxBza4okrgPA">(function(){var src=\'/images/nav_logo229.png\';var iesg=false;document.body.onload = function(){window.n && window.n();if (document.images){new Image().src=src;}\nif (!iesg){document.f&&document.f.q.focus();document.gbqf&&document.gbqf.q.focus();}\n}\n})();</script><div id="mngb"><div id... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/requests.html |
279c2126df90-14 | class=gb4>Web History</a> | <a href="/preferences?hl=en" class=gb4>Settings</a> | <a target=_top id=gb_70 href="https://accounts.google.com/ServiceLogin?hl=en&passive=true&continue=https://www.google.com/&ec=GAZAAQ" class=gb4>Sign in</a></nobr></div><div class=gbh style=left:0></div><div class=gbh style=right:0></div>... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/requests.html |
279c2126df90-15 | class="ds"><span class="lsbb"><input class="lsb" value="Google Search" name="btnG" type="submit"></span></span><span class="ds"><span class="lsbb"><input class="lsb" id="tsuid_1" value="I\'m Feeling Lucky" name="btnI" type="submit"><script nonce="MXrF0nnIBPkxBza4okrgPA">(function(){var id=\'tsuid_1\';document.getElemen... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/requests.html |
279c2126df90-16 | 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="... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/requests.html |
279c2126df90-17 | Asian Pacific American Heritage Month with Google</a></div></div></div><span id="footer"><div style="font-size:10pt"><div style="margin:19px auto;text-align:center" id="WqQANb"><a href="/intl/en/ads/">Advertising</a><a href="/services/">Business Solutions</a><a href="/intl/en/about.html">About Google</a></div></div><p ... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/requests.html |
279c2126df90-18 | nonce="MXrF0nnIBPkxBza4okrgPA">(function(){var u=\'/xjs/_/js/k\\x3dxjs.hp.en.q0lHXBfs9JY.O/am\\x3dAAAA6AQAUABgAQ/d\\x3d1/ed\\x3d1/rs\\x3dACT90oE3ek6-fjkab6CsTH0wUEUUPhnExg/m\\x3dsb_he,d\';var amd=0;\nvar e=this||self,f=function(c){return c};var h;var n=function(c,g){this.g=g===l?c:""};n.prototype.toString=function(){re... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/requests.html |
279c2126df90-19 | 0:q.call(k,"script[nonce]"))?a.nonce||a.getAttribute("nonce")||"":"")&&b.setAttribute("nonce",k);document.body.appendChild(b);google.psa=!0;google.lx=g};google.bx||google.lx()};google.xjsu=u;e._F_jsUrl=u;setTimeout(function(){0<amd?google.caft(function(){return p()},amd):p()},0);})();window._ = window._ || {};window._D... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/requests.html |
279c2126df90-20 | Search\\x22,\\x22dym\\x22:\\x22Did you mean:\\x22,\\x22lcky\\x22:\\x22I\\\\u0026#39;m Feeling Lucky\\x22,\\x22lml\\x22:\\x22Learn more\\x22,\\x22psrc\\x22:\\x22This search was removed from your \\\\u003Ca href\\x3d\\\\\\x22/history\\\\\\x22\\\\u003EWeb History\\\\u003C/a\\\\u003E\\x22,\\x22psrl\\x22:\\x22Remove\\x22,\\... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/requests.html |
279c2126df90-21 | previous
Python REPL
next
SceneXplain
Contents
Inside the tool
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on Jun 16, 2023. | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/requests.html |
919448044e51-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... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/zapier.html |
919448044e51-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... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/zapier.html |
919448044e51-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... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/zapier.html |
919448044e51-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",... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/zapier.html |
919448044e51-4 | from langchain.prompts import PromptTemplate
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/de... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/zapier.html |
919448044e51-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_... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/zapier.html |
919448044e51-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... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/zapier.html |
919448044e51-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[... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/zapier.html |
919448044e51-8 | > 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... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/zapier.html |
620596164756-0 | .ipynb
.pdf
PubMed Tool
PubMed Tool#
This notebook goes over how to use PubMed as a tool
PubMed® comprises more than 35 million citations for biomedical literature from MEDLINE, life science journals, and online books. Citations may include links to full text content from PubMed Central and publisher web sites.
from la... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/pubmed.html |
674f2d57cc21-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
... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/human_tools.html |
674f2d57cc21-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... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/human_tools.html |
674f2d57cc21-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'?" | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/human_tools.html |
674f2d57cc21-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... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/human_tools.html |
674f2d57cc21-4 | simple, strong meaning: I'm powerful and fast. But it's not just the meaning that makes the phrase so powerful. Caesar was a gifted writer, and the phrase makes use of Latin grammar to ... One of the best known and most frequently quoted Latin expression, veni, vidi, vici may be found hundreds of times throughout the c... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/human_tools.html |
674f2d57cc21-5 | 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... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/human_tools.html |
dcd094e42eea-0 | .ipynb
.pdf
Shell Tool
Contents
Use with Agents
Shell Tool#
Giving agents access to the shell is powerful (though risky outside a sandboxed environment).
The LLM can use it to execute any shell commands. A common use case for this is letting the LLM interact with your local file system.
from langchain.tools import Sh... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/bash.html |
dcd094e42eea-1 | Action:
```
{
"action": "shell",
"action_input": {
"commands": [
"curl -s https://langchain.com | grep -o 'http[s]*://[^\" ]*' | sort"
]
}
}
```
/Users/wfh/code/lc/lckg/langchain/tools/shell/tool.py:34: UserWarning: The shell tool has no safeguards by default. Use at your own risk.
warnings.warn(
... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/bash.html |
dcd094e42eea-2 | > Finished chain.
'["https://blog.langchain.dev/", "https://discord.gg/6adMQxSpJS", "https://docs.langchain.com/docs/", "https://github.com/hwchase17/chat-langchain", "https://github.com/hwchase17/langchain", "https://github.com/hwchase17/langchainjs", "https://github.com/sullivan-sean/chat-langchainjs", "https://js.la... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/bash.html |
8a2d3d793670-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... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/gradio_tools.html |
8a2d3d793670-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)... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/gradio_tools.html |
8a2d3d793670-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... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/gradio_tools.html |
8a2d3d793670-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... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/gradio_tools.html |
edc58f4ae122-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... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/ifttt.html |
edc58f4ae122-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... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/ifttt.html |
dc38ca462716-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... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/google_serper.html |
dc38ca462716-1 | 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 of the wrapper.
search = GoogleSerperAPIW... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/google_serper.html |
dc38ca462716-2 | 'CEO': 'Tim Cook (Aug 24, 2011–)',
'Headquarters': 'Cupertino, CA',
'Founded': 'April 1, 1976, Los Altos, CA',
'Founders': 'Steve Jobs, Steve Wozniak, '
'Ronald Wayne, ... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/google_serper.html |
dc38ca462716-3 | 'revenue, ...',
'attributes': {'Products': 'AirPods; Apple Watch; iPad; iPhone; '
'Mac; Full list',
'Founders': 'Steve Jobs; Steve Wozniak; Ronald '
'Wayne; Mike Markkula'},
'siteli... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/google_serper.html |
dc38ca462716-4 | 'Ive Tim Cook Angela Ahrendts',
'Date': '1976 - present'},
'imageUrl': 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcS3liELlhrMz3Wpsox29U8jJ3L8qETR0hBWHXbFnwjwQc34zwZvFELst2E&s',
'position': 3},
{'title': 'AAPL: Apple Inc Stock Price Quote -... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/google_serper.html |
dc38ca462716-5 | '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': [{'question': 'What does Apple Inc do?',
... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/google_serper.html |
dc38ca462716-6 | 'title': 'Apple Inc Company Profile - Apple Inc Overview - '
'GlobalData',
'link': 'https://www.globaldata.com/company-profile/apple-inc/'},
{'question': 'Who runs Apple Inc?',
'snippet': 'Timothy Donald Cook (born November 1, 1960)... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/google_serper.html |
dc38ca462716-7 | '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,
'imageHeight': 900,
'thumbnailUrl': 'https://encrypted-tbn0.gstatic.com... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/google_serper.html |
dc38ca462716-8 | 'position': 2},
{'title': 'African lion, facts and photos',
'imageUrl': 'https://i.natgeofe.com/n/487a0d69-8202-406f-a6a0-939ed3704693/african-lion.JPG',
'imageWidth': 3072,
'imageHeight': 2043,
'thumbnailUrl': 'https://encrypted-tbn0.gstatic.com/images?q=... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/google_serper.html |
dc38ca462716-9 | 'thumbnailWidth': 225,
'thumbnailHeight': 225,
'source': 'St. Louis Zoo',
'domain': 'stlzoo.org',
'link': 'https://stlzoo.org/animals/mammals/carnivores/lion',
'position': 4},
{'title': 'How to Draw a Realistic Lion like an Artist - Studio '
... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/google_serper.html |
dc38ca462716-10 | 'imageWidth': 1600,
'imageHeight': 1085,
'thumbnailUrl': 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSCqaKY_THr0IBZN8c-2VApnnbuvKmnsWjfrwKoWHFR9w3eN5o&s',
'thumbnailWidth': 273,
'thumbnailHeight': 185,
'source': 'Encyclopedia Britannica',
... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/google_serper.html |
dc38ca462716-11 | 'thumbnailHeight': 168,
'source': 'USA Today',
'domain': 'www.usatoday.com',
'link': 'https://www.usatoday.com/story/news/2023/01/08/where-do-lions-live-habitat/10927718002/',
'position': 7},
{'title': 'Lion',
'imageUrl': 'https://i.natgeofe.c... | rtdocs_stable/api.python.langchain.com/en/stable/modules/agents/tools/examples/google_serper.html |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.