id
stringlengths
14
16
text
stringlengths
45
2.73k
source
stringlengths
49
114
6c9972219f70-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/), specifically the /v1/forecast endpoint. Requires LLM: Yes news-api Tool Name: News API Tool Description: Use this when you want to get information about the top headlines of current news stories. The input should be a question in natural language that this API can answer. Notes: A natural language connection to the News API (https://newsapi.org), specifically the /v2/top-headlines endpoint. Requires LLM: Yes Extra Parameters: news_api_key (your API key to access this endpoint) tmdb-api Tool Name: TMDB API Tool Description: Useful for when you want to get information from The Movie Database. The input should be a question in natural language that this API can answer. Notes: A natural language connection to the TMDB API (https://api.themoviedb.org/3), specifically the /search/movie endpoint. Requires LLM: Yes Extra Parameters: tmdb_bearer_token (your Bearer Token to access this endpoint - note that this is different from the API key) 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 this page searx-search Tool Name: Search
https://python.langchain.com/en/latest/modules/agents/tools/getting_started.html
6c9972219f70-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 Parameters: searx_host google-serper Tool Name: Search Tool Description: A low-cost Google Search API. Useful for when you need to answer questions about current events. Input should be a search query. Notes: Calls the serper.dev Google Search API and then parses results. Requires LLM: No Extra Parameters: serper_api_key For more information on this, see this page wikipedia Tool Name: Wikipedia Tool Description: A wrapper around Wikipedia. Useful for when you need to answer general questions about people, places, companies, historical events, or other subjects. Input should be a search query. Notes: Uses the wikipedia Python package to call the MediaWiki API and then parses results. Requires LLM: No Extra Parameters: top_k_results podcast-api Tool Name: Podcast API Tool Description: Use the Listen Notes Podcast API to search all podcasts or episodes. The input should be a question in natural language that this API can answer. 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 API. Useful for fetching current weather information for a specified location. Input should be a location string (e.g. ‘London,GB’).
https://python.langchain.com/en/latest/modules/agents/tools/getting_started.html
6c9972219f70-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 © Copyright 2023, Harrison Chase. Last updated on Apr 21, 2023.
https://python.langchain.com/en/latest/modules/agents/tools/getting_started.html
146dd9e4d909-0
.ipynb .pdf Multi-Input Tools Multi-Input Tools# This notebook shows how to use a tool that requires multiple inputs with an agent. The difficulty in doing so comes from the fact that an agent decides its next step from a language model, which outputs a string. So if that step requires multiple inputs, they need to be parsed from that. Therefore, the currently supported way to do this is to write a smaller wrapper function that parses a string into multiple inputs. For a concrete example, let’s work on giving an agent access to a multiplication function, which takes as input two integers. In order to use this, we will tell the agent to generate the “Action Input” as a comma-separated list of length two. We will then write a thin wrapper that takes a string, splits it into two around a comma, and passes both parsed sides as integers to the multiplication function. from langchain.llms import OpenAI from langchain.agents import initialize_agent, Tool from langchain.agents import AgentType Here is the multiplication function, as well as a wrapper to parse a string as input. def multiplier(a, b): return a * b def parsing_multiplier(string): a, b = string.split(",") return multiplier(int(a), int(b)) llm = OpenAI(temperature=0) tools = [ Tool( name = "Multiplier", func=parsing_multiplier, description="useful for when you need to multiply two numbers together. The input to this tool should be a comma separated list of numbers of length two, representing the two numbers you want to multiply together. For example, `1,2` would be the input if you wanted to multiply 1 by 2." ) ]
https://python.langchain.com/en/latest/modules/agents/tools/multi_input_tool.html
146dd9e4d909-1
) ] mrkl = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True) mrkl.run("What is 3 times 4") > 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 By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 21, 2023.
https://python.langchain.com/en/latest/modules/agents/tools/multi_input_tool.html
1fdff0f5e65c-0
.ipynb .pdf Defining Custom Tools Contents Completely New Tools Tool dataclass Subclassing the BaseTool class Using the tool decorator Modify existing tools Defining the priorities among Tools Using tools to return directly Multi-argument tools Defining Custom Tools# When constructing your own agent, you will need to provide it with a list of Tools that it can use. Besides the actual function that is called, the Tool consists of several components: name (str), is required and must be unique within a set of tools provided to an agent description (str), is optional but recommended, as it is used by an agent to determine tool use return_direct (bool), defaults to False args_schema (Pydantic BaseModel), is optional but recommended, can be used to provide more information or validation for expected parameters. The function that should be called when the tool is selected should return a single string. There are two ways to define a tool, we will cover both in the example below. # Import things that are needed generically from langchain import LLMMathChain, SerpAPIWrapper from langchain.agents import AgentType, Tool, initialize_agent, tool from langchain.chat_models import ChatOpenAI from langchain.tools import BaseTool Initialize the LLM to use for the agent. llm = ChatOpenAI(temperature=0) Completely New Tools# First, we show how to create completely new tools from scratch. There are two ways to do this: either by using the Tool dataclass, or by subclassing the BaseTool class. Tool dataclass# # Load the tool configs that are needed. search = SerpAPIWrapper() llm_math_chain = LLMMathChain(llm=llm, verbose=True) tools = [ Tool( name = "Search",
https://python.langchain.com/en/latest/modules/agents/tools/custom_tools.html
1fdff0f5e65c-1
tools = [ Tool( name = "Search", func=search.run, description="useful for when you need to answer questions about current events" ), ] # You can also define an args_schema to provide more information about inputs from pydantic import BaseModel, Field class CalculatorInput(BaseModel): question: str = Field() tools.append( Tool( name="Calculator", func=llm_math_chain.run, description="useful for when you need to answer questions about math", args_schema=CalculatorInput ) ) # Construct the agent. We will use the default agent type here. # See documentation for a full list of options. agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True) 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 find out Leo DiCaprio's girlfriend's name and her age Action: Search Action Input: "Leo DiCaprio girlfriend"DiCaprio broke up with girlfriend Camila Morrone, 25, in the summer of 2022, after dating for four years.I need to find out Camila Morrone's current age Action: Calculator Action Input: 25^(0.43) > Entering new LLMMathChain chain... 25^(0.43)```text 25**(0.43) ``` ...numexpr.evaluate("25**(0.43)")... Answer: 3.991298452658078 > Finished chain. Answer: 3.991298452658078I now know the final answer Final Answer: 3.991298452658078
https://python.langchain.com/en/latest/modules/agents/tools/custom_tools.html
1fdff0f5e65c-2
Final Answer: 3.991298452658078 > Finished chain. '3.991298452658078' Subclassing the BaseTool class# class CustomSearchTool(BaseTool): name = "Search" description = "useful for when you need to answer questions about current events" def _run(self, query: str) -> str: """Use the tool.""" return search.run(query) async def _arun(self, query: str) -> str: """Use the tool asynchronously.""" raise NotImplementedError("BingSearchRun does not support async") class CustomCalculatorTool(BaseTool): name = "Calculator" description = "useful for when you need to answer questions about math" args_schema=CalculatorInput def _run(self, query: str) -> str: """Use the tool.""" return llm_math_chain.run(query) async def _arun(self, query: str) -> str: """Use the tool asynchronously.""" raise NotImplementedError("BingSearchRun does not support async") tools = [CustomSearchTool(), CustomCalculatorTool()] agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True) 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 find out Leo DiCaprio's girlfriend's name and her age Action: Search Action Input: "Leo DiCaprio girlfriend"DiCaprio broke up with girlfriend Camila Morrone, 25, in the summer of 2022, after dating for four years.I need to find out Camila Morrone's current age Action: Calculator
https://python.langchain.com/en/latest/modules/agents/tools/custom_tools.html
1fdff0f5e65c-3
Action: Calculator Action Input: 25^(0.43) > Entering new LLMMathChain chain... 25^(0.43)```text 25**(0.43) ``` ...numexpr.evaluate("25**(0.43)")... Answer: 3.991298452658078 > Finished chain. Answer: 3.991298452658078I now know the final answer Final Answer: 3.991298452658078 > Finished chain. '3.991298452658078' 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 argument. Additionally, the decorator will use the function’s docstring as the tool’s description. from langchain.agents import tool @tool def search_api(query: str) -> str: """Searches the API for the query.""" return f"Results for query {query}" search_api Tool(name='search_api', description='search_api(query: str) -> str - Searches the API for the query.', args_schema=<class 'pydantic.main.SearchApi'>, return_direct=False, verbose=False, callback_manager=<langchain.callbacks.shared.SharedCallbackManager object at 0x12748c4c0>, func=<function search_api at 0x16bd664c0>, coroutine=None) You can also provide arguments like the tool name and whether to return directly. @tool("search", return_direct=True) def search_api(query: str) -> str: """Searches the API for the query.""" return "Results" search_api
https://python.langchain.com/en/latest/modules/agents/tools/custom_tools.html
1fdff0f5e65c-4
"""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 'pydantic.main.SearchApi'>, return_direct=True, verbose=False, callback_manager=<langchain.callbacks.shared.SharedCallbackManager object at 0x12748c4c0>, func=<function search_api at 0x16bd66310>, coroutine=None) You can also provide args_schema to provide more information about the argument class SearchInput(BaseModel): query: str = Field(description="should be a search query") @tool("search", return_direct=True, args_schema=SearchInput) def search_api(query: str) -> str: """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 0x12748c4c0>, func=<function search_api at 0x16bcf0ee0>, coroutine=None) Modify existing tools# Now, we show how to load existing tools and just modify them. In the example below, we do something really simple and change the Search tool to have the name Google Search. from langchain.agents import load_tools tools = load_tools(["serpapi", "llm-math"], llm=llm) tools[0].name = "Google Search" agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True)
https://python.langchain.com/en/latest/modules/agents/tools/custom_tools.html
1fdff0f5e65c-5
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 find out Leo DiCaprio's girlfriend's name and her age. Action: Google Search Action Input: "Leo DiCaprio girlfriend"I draw the lime at going to get a Mohawk, though." DiCaprio broke up with girlfriend Camila Morrone, 25, in the summer of 2022, after dating for four years. He's since been linked to another famous supermodel – Gigi Hadid.Now I need to find out Camila Morrone's current age. Action: Calculator Action Input: 25^0.43Answer: 3.991298452658078I now know the final answer. Final Answer: Camila Morrone's current age raised to the 0.43 power is approximately 3.99. > Finished chain. "Camila Morrone's current age raised to the 0.43 power is approximately 3.99." Defining the priorities among Tools# When you made a Custom tool, you may want the Agent to use the custom tool more than normal tools. For example, you made a custom tool, which gets information on music from your database. When a user wants information on songs, You want the Agent to use the custom tool more than the normal Search tool. But the Agent might prioritize a normal Search tool. This can be accomplished by adding a statement such as Use this more than the normal search if the question is about Music, like 'who is the singer of yesterday?' or 'what is the most popular song in 2022?' to the description. An example is below. # Import things that are needed generically from langchain.agents import initialize_agent, Tool from langchain.agents import AgentType
https://python.langchain.com/en/latest/modules/agents/tools/custom_tools.html
1fdff0f5e65c-6
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", 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 Music search engine. Use this more than the normal search if the question is about Music, like 'who is the singer of yesterday?' or 'what is the most popular song in 2022?'", ) ] agent = initialize_agent(tools, OpenAI(temperature=0), agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True) agent.run("what is the most famous song of christmas") > Entering new AgentExecutor chain... I should use a music search engine to find the answer Action: Music Search Action Input: most famous song of christmas'All I Want For Christmas Is You' by Mariah Carey. I now know the final answer Final Answer: 'All I Want For Christmas Is You' by Mariah Carey. > Finished chain. "'All I Want For Christmas Is You' by Mariah Carey." Using tools to return directly# Often, it can be desirable to have a tool output returned directly to the user, if it’s called. You can do this easily with LangChain by setting the return_direct flag for a tool to be True. llm_math_chain = LLMMathChain(llm=llm) tools = [ Tool( name="Calculator",
https://python.langchain.com/en/latest/modules/agents/tools/custom_tools.html
1fdff0f5e65c-7
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_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 chain. 'Answer: 1.086734862526058' Multi-argument tools# Many functions expect structured inputs. These can also be supported using the Tool decorator or by directly subclassing BaseTool! We have to modify the LLM’s OutputParser to map its string output to a dictionary to pass to the action, however. from typing import Optional, Union @tool def custom_search(k: int, query: str, other_arg: Optional[str] = None): """The custom search function.""" return f"Here are the results for the custom search: k={k}, query={query}, other_arg={other_arg}" import re from langchain.schema import ( AgentAction, AgentFinish, ) from langchain.agents import AgentOutputParser # We will add a custom parser to map the arguments to a dictionary class CustomOutputParser(AgentOutputParser): def parse_tool_input(self, action_input: str) -> dict: # Regex pattern to match arguments and their values pattern = r"(\w+)\s*=\s*(None|\"[^\"]*\"|\d+)" matches = re.findall(pattern, action_input)
https://python.langchain.com/en/latest/modules/agents/tools/custom_tools.html
1fdff0f5e65c-8
matches = re.findall(pattern, action_input) if not matches: raise ValueError(f"Could not parse action input: `{action_input}`") # Create a dictionary with the parsed arguments and their values parsed_input = {} for arg, value in matches: if value == "None": parsed_value = None elif value.isdigit(): parsed_value = int(value) else: parsed_value = value.strip('"') parsed_input[arg] = parsed_value return parsed_input def parse(self, llm_output: str) -> Union[AgentAction, AgentFinish]: # Check if agent should finish if "Final Answer:" in llm_output: return AgentFinish( # Return values is generally always a dictionary with a single `output` key # It is not recommended to try anything else at the moment :) return_values={"output": llm_output.split("Final Answer:")[-1].strip()}, log=llm_output, ) # Parse out the action and action input regex = r"Action\s*\d*\s*:(.*?)\nAction\s*\d*\s*Input\s*\d*\s*:[\s]*(.*)" match = re.search(regex, llm_output, re.DOTALL) if not match: raise ValueError(f"Could not parse LLM output: `{llm_output}`") action = match.group(1).strip() action_input = match.group(2) tool_input = self.parse_tool_input(action_input) # Return the action and action return AgentAction(tool=action, tool_input=tool_input, log=llm_output) llm = OpenAI(temperature=0)
https://python.langchain.com/en/latest/modules/agents/tools/custom_tools.html
1fdff0f5e65c-9
llm = OpenAI(temperature=0) agent = initialize_agent([custom_search], llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True, agent_kwargs={"output_parser": CustomOutputParser()}) agent.run("Search for me and tell me whatever it says") > Entering new AgentExecutor chain... I need to use a search function to find the answer Action: custom_search Action Input: k=1, query="me"Here are the results for the custom search: k=1, query=me, other_arg=None I now know the final answer Final Answer: The results of the custom search for k=1, query=me, other_arg=None. > Finished chain. 'The results of the custom search for k=1, query=me, other_arg=None.' previous Getting Started next Multi-Input Tools Contents Completely New Tools Tool dataclass Subclassing the BaseTool class Using the tool decorator Modify existing tools Defining the priorities among Tools Using tools to return directly Multi-argument tools By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 21, 2023.
https://python.langchain.com/en/latest/modules/agents/tools/custom_tools.html
d2f4aa242d2d-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 from langchain.llms import OpenAI from langchain.tools.requests.tool import RequestsGetTool, TextRequestsWrapper from pydantic import BaseModel, Field, root_validator llm = OpenAI(temperature=0) !pip install tldextract > /dev/null [notice] A new release of pip is available: 23.0.1 -> 23.1 [notice] To update, run: pip install --upgrade pip import tldextract _APPROVED_DOMAINS = { "langchain", "wikipedia", } class ToolInputSchema(BaseModel): url: str = Field(...) @root_validator def validate_query(cls, values: Dict[str, Any]) -> Dict: url = values["url"] domain = tldextract.extract(url).domain if domain not in _APPROVED_DOMAINS: raise ValueError(f"Domain {domain} is not on the approved list:" f" {sorted(_APPROVED_DOMAINS)}") return values tool = RequestsGetTool(args_schema=ToolInputSchema, requests_wrapper=TextRequestsWrapper()) 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)
https://python.langchain.com/en/latest/modules/agents/tools/tool_input_validation.html
d2f4aa242d2d-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 Traceback (most recent call last) Cell In[7], line 1 ----> 1 agent.run("What's the main title on google.com?") File ~/code/lc/lckg/langchain/chains/base.py:213, in Chain.run(self, *args, **kwargs) 211 if len(args) != 1: 212 raise ValueError("`run` supports only one positional argument.") --> 213 return self(args[0])[self.output_keys[0]] 215 if kwargs and not args: 216 return self(kwargs)[self.output_keys[0]] File ~/code/lc/lckg/langchain/chains/base.py:116, in Chain.__call__(self, inputs, return_only_outputs) 114 except (KeyboardInterrupt, Exception) as e: 115 self.callback_manager.on_chain_error(e, verbose=self.verbose) --> 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( 108 {"name": self.__class__.__name__}, 109 inputs, 110 verbose=self.verbose, 111 ) 112 try: --> 113 outputs = self._call(inputs)
https://python.langchain.com/en/latest/modules/agents/tools/tool_input_validation.html
d2f4aa242d2d-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 something). 791 while self._should_continue(iterations, time_elapsed): --> 792 next_step_output = self._take_next_step( 793 name_to_tool_map, color_mapping, inputs, intermediate_steps 794 ) 795 if isinstance(next_step_output, AgentFinish): 796 return self._return(next_step_output, intermediate_steps) 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( 696 agent_action.tool_input, 697 verbose=self.verbose, 698 color=color, 699 **tool_run_kwargs, 700 ) 701 else: 702 tool_run_kwargs = self.agent.tool_run_logging_kwargs() File ~/code/lc/lckg/langchain/tools/base.py:110, in BaseTool.run(self, tool_input, verbose, start_color, color, **kwargs) 101 def run( 102 self, 103 tool_input: Union[str, Dict], (...)
https://python.langchain.com/en/latest/modules/agents/tools/tool_input_validation.html
d2f4aa242d2d-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 BaseTool._parse_input(self, tool_input) 69 if issubclass(input_args, BaseModel): 70 key_ = next(iter(input_args.__fields__.keys())) ---> 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/.venv/lib/python3.11/site-packages/pydantic/main.py:341, in pydantic.main.BaseModel.__init__() ValidationError: 1 validation error for ToolInputSchema __root__ Domain google is not on the approved list: ['langchain', 'wikipedia'] (type=value_error) previous Multi-Input Tools next Apify By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 21, 2023.
https://python.langchain.com/en/latest/modules/agents/tools/tool_input_validation.html
c09692104077-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 will need to set some environment variables: Save your APP ID into WOLFRAM_ALPHA_APPID env variable pip install wolframalpha import os os.environ["WOLFRAM_ALPHA_APPID"] = "" from langchain.utilities.wolfram_alpha import WolframAlphaAPIWrapper wolfram = WolframAlphaAPIWrapper() wolfram.run("What is 2x+5 = -3x + 7?") 'x = 2/5' previous Wikipedia API next Zapier Natural Language Actions API By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 21, 2023.
https://python.langchain.com/en/latest/modules/agents/tools/examples/wolfram_alpha.html
1d3bf4f4758e-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 requests = TextRequestsWrapper() requests.get("https://www.google.com")
https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html
1d3bf4f4758e-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"><meta content="text/html; charset=UTF-8" http-equiv="Content-Type"><meta content="/logos/doodles/2023/international-womens-day-2023-6753651837109578-l.png" itemprop="image"><meta content="International Women\'s Day 2023" property="twitter:title"><meta content="International Women\'s Day 2023! #GoogleDoodle" property="twitter:description"><meta content="International Women\'s Day 2023! #GoogleDoodle" property="og:description"><meta content="summary_large_image" property="twitter:card"><meta content="@GoogleDoodles" property="twitter:site"><meta content="https://www.google.com/logos/doodles/2023/international-womens-day-2023-6753651837109578-2x.png" property="twitter:image"><meta content="https://www.google.com/logos/doodles/2023/international-womens-day-2023-6753651837109578-2x.png" property="og:image"><meta content="1000" property="og:image:width"><meta content="400" property="og:image:height"><title>Google</title><script
https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html
1d3bf4f4758e-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,11323,2652,4,1528,2304,29062,9871,3194,11443,2215,2980,10815,7428,5821,2536,4094,
https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html
1d3bf4f4758e-3
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,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,223
https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html
1d3bf4f4758e-4
974,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,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,15
https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html
1d3bf4f4758e-5
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,5738,12560,1540,1218,146,1415332\',kBL:\'Td3a\'};google.sn=\'webhp\';google.kHL=\'en\';})();(function(){\nvar
https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html
1d3bf4f4758e-6
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("&lei=")&&(d=m(d))&&(e+="&lei="+d));d="";!c&&f._cshid&&-1===b.search("&cshid=")&&"slh"!==a&&(d="&cshid="+f._cshid);c=c||"/"+(g||"gen_204")+"?atyp=i&ct="+a+"&cad="+b+e+"&zx="+Date.now()+d;/^http:/i.test(c)&&"https:"===window.location.protocol&&(google.ml&&google.ml(Error("a"),!1,{src:c,glmm:1}),c="");return 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(a)var c=a.id;else{do
https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html
1d3bf4f4758e-7
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=!1;google.lx=function(){};}).call(this);google.f={};(function(){\ndocument.documentElement.addEventListener("submit",function(b){var a;if(a=b.target){var c=a.getAttribute("data-submitfalse");a="1"===c||"q"===c&&!a.elements.q.value?!0:!1}else a=!1;a&&(b.preventDefault(),b.stopPropagation())},!0);document.documentElement.addEventListener("click",function(b){var 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: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
https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html
1d3bf4f4758e-8
!important}a.gb1,a.gb4{color:#00c !important}.gbi .gb4{color:#dd8e27 !important}.gbf .gb4{color:#900 !important}\n</style><style>body,td,a,p,.h{font-family:arial,sans-serif}body{margin:0;overflow-y:scroll}#gog{padding:3px 8px 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-family:inherit}body{background:#fff;color:#000}a{color:#4b11a8;text-decoration:none}a:hover,a:active{text-decoration:underline}.fl a{color:#1558d6}a:visited{color:#4b11a8}.sblc{padding-top:5px}.sblc 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
https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html
1d3bf4f4758e-9
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!=(k=h.mei)?k:1,n,p=null!=(n=h.sdo)?n:!0,q=0,r,t=google.erd,v=t.jsr;google.ml=function(a,b,d,m,e){e=void 0===e?2:e;b&&(r=a&&a.message);if(google.dl)return google.dl(a,e,d),null;if(0>v){window.console&&console.error(a,d);if(-2===v)throw a;b=!1}else b=!a||!a.message||"Error loading script"===a.message||q>=l&&!m?!1:!0;if(!b)return 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
https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html
1d3bf4f4758e-10
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.documentElement.outerHTML.split("\\n")[f],c+="&cad="+b(f?f.substring(0,300):"No script found.")));c+="&jsel="+e;for(var u in d)c+="&",c+=b(u),c+="=",c+=b(d[u]);c=c+"&emsg="+b(a.name+": "+a.message);c=c+"&jsst="+b(a.stack||"N/A");12288<=c.length&&(c=c.substr(0,12288));a=c;m||google.log(0,"",a);return a};window.onerror=function(a,b,d,m,e){r!==a&&(a=e 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 bgcolor="#fff"><script nonce="skA52jTjrFARNMkurZZTjQ">(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
https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html
1d3bf4f4758e-11
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=gbar><nobr><b class=gb1>Search</b> <a class=gb1 href="https://www.google.com/imghp?hl=en&tab=wi">Images</a> <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">Gmail</a> <a class=gb1 href="https://drive.google.com/?tab=wo">Drive</a> <a class=gb1 style="text-decoration:none" href="https://www.google.com/intl/en/about/products?tab=wh"><u>More</u> &raquo;</a></nobr></div><div id=guser width=100%><nobr><span id=gbn class=gbi></span><span id=gbf class=gbf></span><span id=gbe></span><a href="http://www.google.com/history/optout?hl=en" class=gb4>Web History</a> | <a
https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html
1d3bf4f4758e-12
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></div><center><br clear="all" id="lgpd"><div id="lga"><a href="/search?ie=UTF-8&amp;q=International+Women%27s+Day&amp;oi=ddle&amp;ct=207425752&amp;hl=en&amp;si=AEcPFx5y3cpWB8t3QIlw940Bbgd-HLN-aNYSTraERzz0WyAsdPcV8QlbA9KRIH1_r1H1b32dXlTjZQe5B0MVNeLogkXOiBOkfs-S-hFQywzzxlKEI54jx7H2iV6NSfskfTE00IkUfobnZU0dHdFeGABAmixr9Gj6a8WKVaZeEhYyauqHyAnlpd4%3D&amp;sa=X&amp;ved=0ahUKEwi9zuH2gM39AhWFh-4BHZjODXEQPQgD"><img alt="International Women\'s Day 2023" border="0" height="200"
https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html
1d3bf4f4758e-13
Women\'s Day 2023" border="0" height="200" src="/logos/doodles/2023/international-womens-day-2023-6753651837109578-l.png" title="International Women\'s Day 2023" width="500" id="hplogo"><br></a><br></div><form action="/search" name="f"><table cellpadding="0" cellspacing="0"><tr valign="top"><td width="25%">&nbsp;</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="hidden"><div class="ds" style="height:32px;margin:4px 0"><input class="lst" style="margin:0;padding:5px 8px 0 6px;vertical-align:top;color:#000" autocomplete="off" value="" title="Google Search" maxlength="2048" name="q" size="57"></div><br style="line-height:0"><span 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
https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html
1d3bf4f4758e-14
Feeling Lucky" name="btnI" type="submit"><script nonce="skA52jTjrFARNMkurZZTjQ">(function(){var id=\'tsuid_1\';document.getElementById(id).onclick = function(){if (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="/advanced_search?hl=en&amp;authuser=0">Advanced search</a></td></tr></table><input id="gbv" name="gbv" type="hidden" value="1"><script nonce="skA52jTjrFARNMkurZZTjQ">(function(){var a,b="1";if(document&&document.getElementById)if("undefined"!=typeof XMLHttpRequest)b="2";else if("undefined"!=typeof ActiveXObject){var c,d,e=["MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"];for(c=0;d=e[c++];)try{new ActiveXObject(d),b="2"}catch(h){}}a=b;if("2"==a&&-1==location.search.indexOf("&gbv=2")){var
https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html
1d3bf4f4758e-15
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="prm"><style>.szppmdbYutt__middle-slot-promo{font-size:small;margin-bottom:32px}.szppmdbYutt__middle-slot-promo a.ZIeIlb{display:inline-block;text-decoration:none}.szppmdbYutt__middle-slot-promo img{border:none;margin-right:5px;vertical-align:middle}</style><div class="szppmdbYutt__middle-slot-promo" data-ved="0ahUKEwi9zuH2gM39AhWFh-4BHZjODXEQnIcBCAQ"><span>Celebrate </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&amp;source=hpp&amp;id=19034031&amp;ct=3&amp;usg=AOvVaw1Q51Nb9U7JNUznM352o8BF&amp;sa=X&amp;ved=0ahUKEwi9zuH2gM39AhWFh-4BHZjODXEQ8IcBCAU" rel="nofollow">International Women\'s Day</a><span> with Google</span></div></div></div><span id="footer"><div style="font-size:10pt"><div
https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html
1d3bf4f4758e-16
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 style="font-size:8pt;color:#70757a">&copy; 2023 - <a href="/intl/en/policies/privacy/">Privacy</a> - <a href="/intl/en/policies/terms/">Terms</a></p></span></center><script 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.log("","","/client_204?&atyp=i&biw="+a+"&bih="+b+"&ei="+google.kEI);}).call(this);})();</script> <script nonce="skA52jTjrFARNMkurZZTjQ">(function(){google.xjs={ck:\'xjs.hp.Y2W3KAJ0Jco.L.X.O\',cs:\'ACT90oEk9pJxm1OOdkVmpGo-yLFc4v5z8w\',excm:[]};})();</script> <script nonce="skA52jTjrFARNMkurZZTjQ">(function(){var
https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html
1d3bf4f4758e-17
nonce="skA52jTjrFARNMkurZZTjQ">(function(){var 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;google.lx=function(){p(a);google.lx=function(){}};google.bx||google.lx()}\nfunction p(a){google.timers&&google.timers.load&&google.tick&&google.tick("load","xjsls");var b=document;var c="SCRIPT";"application/xhtml+xml"===b.contentType&&(c=c.toLowerCase());c=b.createElement(c);a=null===a?"null":void 0===a?"undefined":a;if(void 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";var
https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html
1d3bf4f4758e-18
l&&a.constructor===l?a.g:"type_error:TrustedResourceUrl";var f,n;(f=(a=null==(n=(f=(c.ownerDocument&&c.ownerDocument.defaultView||window).document).querySelector)?void 0:n.call(f,"script[nonce]"))?a.nonce||a.getAttribute("nonce")||"":"")&&c.setAttribute("nonce",f);document.body.appendChild(c);google.psa=!0};google.xjsu=u;setTimeout(function(){0<amd?google.caft(function(){return m()},amd):m()},0);})();function _DumpException(e){throw e;}\nfunction _F_installCss(c){}\n(function(){google.jl={blt:\'none\',chnk:0,dw:false,dwu:true,emtn:0,end:0,ico:false,ikb:0,ine:false,injs:\'none\',injt:0,injth:0,injv2:false,lls:\'default\',pdt:0,rep:0,snet:true,strt:0,ubm:false,uwp:true};})();(function(){var pmc=\'{\\x22d\\x22:{},\\x22sb_he\\x22:{\\x22agen\\x22:true,\\x22cgen\\x22:true,\\x22client\\x22:\\x22heirloom-hp\\x22,\\x22dh\\x22:true,\\x22ds\\x22:\\x22\\x22,\\x22fl\\x22:true,\\x22host\\x22:\\x22google.com\\x22,\\x22jsonp\\x22:true,\\x22msgs\\x22:{\\x22cibl\\x22:\\x22Clear Search\\x22,\\x22dym\\x22:\\x22Did you
https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html
1d3bf4f4758e-19
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,\\x22sbit\\x22:\\x22Search by image\\x22,\\x22srch\\x22:\\x22Google Search\\x22},\\x22ovr\\x22:{},\\x22pq\\x22:\\x22\\x22,\\x22rfs\\x22:[],\\x22sbas\\x22:\\x220 3px 8px 0 rgba(0,0,0,0.2),0 0 0 1px rgba(0,0,0,0.08)\\x22,\\x22stok\\x22:\\x222J2TpqBbW29n4YEWhckcWkIgvqM\\x22}}\';google.pmc=JSON.parse(pmc);})();</script> </body></html>'
https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html
1d3bf4f4758e-20
previous Python REPL next Search Tools By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 21, 2023.
https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html
ae0d019faa0d-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 large language model (LLM)-based agent to complete its task. For example, an LLM could use a Gradio tool to transcribe a voice recording it finds online and then summarize it for you. Or it could use a different Gradio tool to apply OCR to a document on your Google Drive and then answer questions about it. It’s very easy to create you own tool if you want to use a space that’s not one of the pre-built tools. Please see this section of the gradio-tools documentation for information on how to do that. All contributions are welcome! # !pip install gradio_tools Using a tool# from gradio_tools.tools import StableDiffusionTool StableDiffusionTool().langchain.run("Please create a photo of a dog riding a skateboard") Loaded as API: https://gradio-client-demos-stable-diffusion.hf.space ✔ Job Status: Status.STARTING eta: None '/Users/harrisonchase/workplace/langchain/docs/modules/agents/tools/examples/b61c1dd9-47e2-46f1-a47c-20d27640993d/tmp4ap48vnm.jpg' 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#
https://python.langchain.com/en/latest/modules/agents/tools/examples/gradio_tools.html
ae0d019faa0d-1
display(im) Using within an agent# 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) memory = ConversationBufferMemory(memory_key="chat_history") tools = [StableDiffusionTool().langchain, ImageCaptioningTool().langchain, StableDiffusionPromptGeneratorTool().langchain, TextToVideoTool().langchain] agent = initialize_agent(tools, llm, memory=memory, agent="conversational-react-description", verbose=True) output = agent.run(input=("Please create a photo of a dog riding a skateboard " "but improve my prompt prior to using an image generator." "Please caption the generated image and create a video for it using the improved prompt.")) Loaded as API: https://gradio-client-demos-stable-diffusion.hf.space ✔ Loaded as API: https://taesiri-blip-2.hf.space ✔ 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: None Observation: A dog riding a skateboard, digital painting, artstation, concept art, smooth, sharp focus, illustration, art by artgerm and greg rutkowski and alphonse mucha Thought: Do I need to use a tool? Yes Action: StableDiffusion
https://python.langchain.com/en/latest/modules/agents/tools/examples/gradio_tools.html
ae0d019faa0d-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 Observation: /Users/harrisonchase/workplace/langchain/docs/modules/agents/tools/examples/2e280ce4-4974-4420-8680-450825c31601/tmpfmiz2g1c.jpg Thought: Do I need to use a tool? Yes Action: ImageCaptioner Action Input: /Users/harrisonchase/workplace/langchain/docs/modules/agents/tools/examples/2e280ce4-4974-4420-8680-450825c31601/tmpfmiz2g1c.jpg 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 approximately 73 seconds.For faster predictions without waiting in queue, you may duplicate the space using: Client.duplicate(damo-vilab/modelscope-text-to-video-synthesis) Job Status: Status.IN_QUEUE eta: 73.89824726581574 Due to heavy traffic on this app, the prediction will take approximately 42 seconds.For faster predictions without waiting in queue, you may duplicate the space using: Client.duplicate(damo-vilab/modelscope-text-to-video-synthesis) Job Status: Status.IN_QUEUE eta: 42.49370198879602
https://python.langchain.com/en/latest/modules/agents/tools/examples/gradio_tools.html
ae0d019faa0d-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 Google Serper API next Human as a tool Contents Using a tool Using within an agent By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 21, 2023.
https://python.langchain.com/en/latest/modules/agents/tools/examples/gradio_tools.html
b96ac82690f0-0
.ipynb .pdf Arxiv API Arxiv API# This notebook goes over how to use the arxiv component. First, you need to install arxiv python package. !pip install arxiv from langchain.utilities import ArxivAPIWrapper arxiv = ArxivAPIWrapper() docs = arxiv.run("1605.08386") docs 'Published: 2016-05-26\nTitle: Heat-bath random walks with Markov bases\nAuthors: Caprice Stanley, Tobias Windisch\nSummary: Graphs on lattice points are studied whose edges come from a finite set of\nallowed moves of arbitrary length. We show that the diameter of these graphs on\nfibers of a fixed integer matrix can be bounded from above by a constant. We\nthen study the mixing behaviour of heat-bath random walks on these graphs. We\nalso state explicit conditions on the set of moves so that the heat-bath random\nwalk, a generalization of the Glauber dynamics, is an expander in fixed\ndimension.' docs = arxiv.run("Caprice Stanley") docs
https://python.langchain.com/en/latest/modules/agents/tools/examples/arxiv.html
b96ac82690f0-1
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}$ generated by a linear recurrence\nrelation. Fourier analysis provides explicit formulas to compute the\neigenvalues of the transition matrices and we use this to bound the mixing time\nof the random walks.\n\nPublished: 2016-05-26\nTitle: Heat-bath random walks with Markov bases\nAuthors: Caprice Stanley, Tobias Windisch\nSummary: Graphs on lattice points are studied whose edges come from a finite set of\nallowed moves of arbitrary length. We show that the diameter of these graphs on\nfibers of a fixed integer matrix can be bounded from above by a constant. We\nthen study the mixing behaviour of heat-bath random walks on these graphs. We\nalso state explicit conditions on the set of moves so that the heat-bath random\nwalk, a generalization of the Glauber dynamics, is an expander in fixed\ndimension.\n\nPublished: 2003-03-18\nTitle: Calculation of fluxes of charged particles and neutrinos from atmospheric showers\nAuthors: V. Plyaskin\nSummary: The results on the fluxes of charged particles and neutrinos from a\n3-dimensional (3D) simulation of atmospheric showers are presented. An\nagreement of calculated fluxes with data on charged particles from the AMS and\nCAPRICE detectors is demonstrated. Predictions on neutrino fluxes at different\nexperimental sites are compared with results from other calculations.' docs = arxiv.run("1605.08386WWW") docs
https://python.langchain.com/en/latest/modules/agents/tools/examples/arxiv.html
b96ac82690f0-2
docs = arxiv.run("1605.08386WWW") docs 'No good Arxiv Result was found' previous Apify next Bash By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 21, 2023.
https://python.langchain.com/en/latest/modules/agents/tools/examples/arxiv.html
2b0b522b16ab-0
.ipynb .pdf Search Tools Contents Google Serper API Wrapper SerpAPI GoogleSearchAPIWrapper SearxNG Meta Search Engine Search Tools# This notebook shows off usage of various search tools. from langchain.agents import load_tools from langchain.agents import initialize_agent from langchain.agents import AgentType from langchain.llms import OpenAI llm = OpenAI(temperature=0) Google Serper API Wrapper# First, let’s try to use the Google Serper API tool. tools = load_tools(["google-serper"], llm=llm) agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True) agent.run("What is the weather in Pomfret?") > Entering new AgentExecutor chain... I should look up the current weather conditions. Action: Search Action Input: "weather in Pomfret" Observation: 37°F Thought: I now know the current temperature in Pomfret. Final Answer: The current temperature in Pomfret is 37°F. > Finished chain. 'The current temperature in Pomfret is 37°F.' SerpAPI# Now, let’s use the SerpAPI tool. tools = load_tools(["serpapi"], llm=llm) agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True) agent.run("What is the weather in Pomfret?") > Entering new AgentExecutor chain... I need to find out what the current weather is in Pomfret. Action: Search Action Input: "weather in Pomfret"
https://python.langchain.com/en/latest/modules/agents/tools/examples/search_tools.html
2b0b522b16ab-1
Action: Search Action Input: "weather in Pomfret" Observation: Partly cloudy skies during the morning hours will give way to cloudy skies with light rain and snow developing in the afternoon. High 42F. Winds WNW at 10 to 15 ... Thought: I now know the current weather in Pomfret. Final Answer: Partly cloudy skies during the morning hours will give way to cloudy skies with light rain and snow developing in the afternoon. High 42F. Winds WNW at 10 to 15 mph. > Finished chain. 'Partly cloudy skies during the morning hours will give way to cloudy skies with light rain and snow developing in the afternoon. High 42F. Winds WNW at 10 to 15 mph.' GoogleSearchAPIWrapper# Now, let’s use the official Google Search API Wrapper. tools = load_tools(["google-search"], llm=llm) agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True) agent.run("What is the weather in Pomfret?") > Entering new AgentExecutor chain... I should look up the current weather conditions. Action: Google Search Action Input: "weather in Pomfret"
https://python.langchain.com/en/latest/modules/agents/tools/examples/search_tools.html
2b0b522b16ab-2
Action: Google Search Action Input: "weather in Pomfret" Observation: Showers early becoming a steady light rain later in the day. Near record high temperatures. High around 60F. Winds SW at 10 to 15 mph. Chance of rain 60%. Pomfret, CT Weather Forecast, with current conditions, wind, air quality, and what to expect for the next 3 days. Hourly Weather-Pomfret, CT. As of 12:52 am EST. Special Weather Statement +2 ... Hazardous Weather Conditions. Special Weather Statement ... Pomfret CT. Tonight ... National Digital Forecast Database Maximum Temperature Forecast. Pomfret Center Weather Forecasts. Weather Underground provides local & long-range weather forecasts, weatherreports, maps & tropical weather conditions for ... Pomfret, CT 12 hour by hour weather forecast includes precipitation, temperatures, sky conditions, rain chance, dew-point, relative humidity, wind direction ... North Pomfret Weather Forecasts. Weather Underground provides local & long-range weather forecasts, weatherreports, maps & tropical weather conditions for ... Today's Weather - Pomfret, CT. Dec 31, 2022 4:00 PM. Putnam MS. --. Weather forecast icon. Feels like --. Hi --. Lo --. Pomfret, CT temperature trend for the next 14 Days. Find daytime highs and nighttime lows from TheWeatherNetwork.com. Pomfret, MD Weather Forecast Date: 332 PM EST Wed Dec 28 2022. The area/counties/county of: Charles, including the cites of: St. Charles and Waldorf. Thought: I now know the current weather conditions in Pomfret. Final Answer: Showers early becoming a steady light rain later in the day. Near record high temperatures. High around 60F. Winds SW at 10 to 15 mph. Chance of rain 60%.
https://python.langchain.com/en/latest/modules/agents/tools/examples/search_tools.html
2b0b522b16ab-3
> Finished AgentExecutor chain. 'Showers early becoming a steady light rain later in the day. Near record high temperatures. High around 60F. Winds SW at 10 to 15 mph. Chance of rain 60%.' SearxNG Meta Search Engine# Here we will be using a self hosted SearxNG meta search engine. tools = load_tools(["searx-search"], searx_host="http://localhost:8888", llm=llm) agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True) agent.run("What is the weather in Pomfret") > Entering new AgentExecutor chain... I should look up the current weather Action: SearX Search Action Input: "weather in Pomfret" Observation: Mainly cloudy with snow showers around in the morning. High around 40F. Winds NNW at 5 to 10 mph. Chance of snow 40%. Snow accumulations less than one inch. 10 Day Weather - Pomfret, MD As of 1:37 pm EST Today 49°/ 41° 52% Mon 27 | Day 49° 52% SE 14 mph Cloudy with occasional rain showers. High 49F. Winds SE at 10 to 20 mph. Chance of rain 50%.... 10 Day Weather - Pomfret, VT As of 3:51 am EST Special Weather Statement Today 39°/ 32° 37% Wed 01 | Day 39° 37% NE 4 mph Cloudy with snow showers developing for the afternoon. High 39F....
https://python.langchain.com/en/latest/modules/agents/tools/examples/search_tools.html
2b0b522b16ab-4
Pomfret, CT ; Current Weather. 1:06 AM. 35°F · RealFeel® 32° ; TODAY'S WEATHER FORECAST. 3/3. 44°Hi. RealFeel® 50° ; TONIGHT'S WEATHER FORECAST. 3/3. 32°Lo. Pomfret, MD Forecast Today Hourly Daily Morning 41° 1% Afternoon 43° 0% Evening 35° 3% Overnight 34° 2% Don't Miss Finally, Here’s Why We Get More Colds and Flu When It’s Cold Coast-To-Coast... Pomfret, MD Weather Forecast | AccuWeather Current Weather 5:35 PM 35° F RealFeel® 36° RealFeel Shade™ 36° Air Quality Excellent Wind E 3 mph Wind Gusts 5 mph Cloudy More Details WinterCast... Pomfret, VT Weather Forecast | AccuWeather Current Weather 11:21 AM 23° F RealFeel® 27° RealFeel Shade™ 25° Air Quality Fair Wind ESE 3 mph Wind Gusts 7 mph Cloudy More Details WinterCast... Pomfret Center, CT Weather Forecast | AccuWeather Daily Current Weather 6:50 PM 39° F RealFeel® 36° Air Quality Fair Wind NW 6 mph Wind Gusts 16 mph Mostly clear More Details WinterCast... 12:00 pm · Feels Like36° · WindN 5 mph · Humidity43% · UV Index3 of 10 · Cloud Cover65% · Rain Amount0 in ... Pomfret Center, CT Weather Conditions | Weather Underground star Popular Cities San Francisco, CA 49 °F Clear Manhattan, NY 37 °F Fair Schiller Park, IL (60176) warning39 °F Mostly Cloudy...
https://python.langchain.com/en/latest/modules/agents/tools/examples/search_tools.html
2b0b522b16ab-5
Thought: I now know the final answer Final Answer: The current weather in Pomfret is mainly cloudy with snow showers around in the morning. The temperature is around 40F with winds NNW at 5 to 10 mph. Chance of snow is 40%. > Finished chain. 'The current weather in Pomfret is mainly cloudy with snow showers around in the morning. The temperature is around 40F with winds NNW at 5 to 10 mph. Chance of snow is 40%.' previous Requests next SearxNG Search API Contents Google Serper API Wrapper SerpAPI GoogleSearchAPIWrapper SearxNG Meta Search Engine By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 21, 2023.
https://python.langchain.com/en/latest/modules/agents/tools/examples/search_tools.html
30e14901b8dd-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 langchain.chat_models import ChatOpenAI from langchain.agents import load_tools, initialize_agent from langchain.agents import AgentType from langchain.tools import AIPluginTool tool = AIPluginTool.from_plugin_url("https://www.klarna.com/.well-known/ai-plugin.json") llm = ChatOpenAI(temperature=0) tools = load_tools(["requests_all"] ) tools += [tool] agent_chain = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True) agent_chain.run("what t shirts are available in klarna?") > Entering new AgentExecutor chain... I need to check the Klarna Shopping API to see if it has information on available t shirts. Action: KlarnaProducts Action Input: None Observation: Usage Guide: Use the Klarna plugin to get relevant product suggestions for any shopping or researching purpose. The query to be sent should not include stopwords like articles, prepositions and determinants. The api works best when searching for words that are related to products, like their name, brand, model or category. Links will always be returned and should be shown to the user.
https://python.langchain.com/en/latest/modules/agents/tools/examples/chatgpt_plugins.html
30e14901b8dd-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': {'tags': ['open-ai-product-endpoint'], 'summary': 'API for fetching Klarna product information', 'operationId': 'productsUsingGET', 'parameters': [{'name': 'q', 'in': 'query', 'description': 'query, must be between 2 and 100 characters', 'required': True, 'schema': {'type': 'string'}}, {'name': 'size', 'in': 'query', 'description': 'number of products returned', 'required': False, 'schema': {'type': 'integer'}}, {'name': 'budget', 'in': 'query', 'description': 'maximum price of the matching product in local currency, filters results', 'required': False, 'schema': {'type': 'integer'}}], 'responses': {'200': {'description': 'Products found', 'content': {'application/json': {'schema': {'$ref': '#/components/schemas/ProductResponse'}}}},
https://python.langchain.com/en/latest/modules/agents/tools/examples/chatgpt_plugins.html
30e14901b8dd-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'}, 'price': {'type': 'string'}, 'url': {'type': 'string'}}, 'title': 'Product'}, 'ProductResponse': {'type': 'object', 'properties': {'products': {'type': 'array', 'items': {'$ref': '#/components/schemas/Product'}}}, 'title': 'ProductResponse'}}}}
https://python.langchain.com/en/latest/modules/agents/tools/examples/chatgpt_plugins.html
30e14901b8dd-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
30e14901b8dd-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 Ultimate 6pk. Crewneck T-Shirts","url":"https://www.klarna.com/us/shopping/pl/cl10001/3201808270/Clothing/Hanes-Men-s-Ultimate-6pk.-Crewneck-T-Shirts/?utm_source=openai","price":"$13.82","attributes":["Material:Cotton","Target Group:Man","Color:White"]},{"name":"Nike Boy's Jordan Stretch T-shirts","url":"https://www.klarna.com/us/shopping/pl/cl359/3201863202/Children-s-Clothing/Nike-Boy-s-Jordan-Stretch-T-shirts/?utm_source=openai","price":"$14.99","attributes":["Material:Cotton","Color:White,Green","Model:Boy","Size (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"]},{"name":"adidas Comfort T-shirts Men's
https://python.langchain.com/en/latest/modules/agents/tools/examples/chatgpt_plugins.html
30e14901b8dd-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
30e14901b8dd-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 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. > Finished chain. "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." previous Bing Search next DuckDuckGo Search By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 21, 2023.
https://python.langchain.com/en/latest/modules/agents/tools/examples/chatgpt_plugins.html
a4ee2869708f-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 commands in. This interface will only return things that are printed - therefor, if you want to use it to calculate an answer, make sure to have it print out the answer. from langchain.utilities import PythonREPL python_repl = PythonREPL() python_repl.run("print(1+1)") '2\n' previous OpenWeatherMap API next Requests By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 21, 2023.
https://python.langchain.com/en/latest/modules/agents/tools/examples/python.html
0d7b125173af-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 Configuring the “If This”# Click on the “If This” button in the IFTTT interface. Search for “Webhooks” in the search bar. Choose the first option for “Receive a web request with a JSON payload.” Choose an Event Name that is specific to the service you plan to connect to. This will make it easier for you to manage the webhook URL. For example, if you’re connecting to Spotify, you could use “Spotify” as your Event Name. Click the “Create Trigger” button to save your settings and create your webhook. Configuring the “Then That”# Tap on the “Then That” button in the IFTTT interface. Search for the service you want to connect, such as Spotify. Choose an action from the service, such as “Add track to a playlist”. Configure the action by specifying the necessary details, such as the playlist name, e.g., “Songs from AI”. Reference the JSON Payload received by the Webhook in your action. For the Spotify scenario, choose “{{JsonPayload}}” as your search query. Tap the “Create Action” button to save your action settings. Once you have finished configuring your action, click the “Finish” button to 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 🎉
https://python.langchain.com/en/latest/modules/agents/tools/examples/ifttt.html
0d7b125173af-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.ifttt import IFTTTWebhook import os key = os.environ["IFTTTKey"] url = f"https://maker.ifttt.com/trigger/spotify/json/with/key/{key}" tool = IFTTTWebhook(name="Spotify", description="Add a song to spotify playlist", url=url) tool.run("taylor swift") "Congratulations! You've fired the spotify JSON event" previous Human as a tool next OpenWeatherMap API Contents Creating a webhook Configuring the “If This” Configuring the “Then That” Finishing up By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 21, 2023.
https://python.langchain.com/en/latest/modules/agents/tools/examples/ifttt.html
e5170741dc19-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. import os os.environ["BING_SUBSCRIPTION_KEY"] = "" os.environ["BING_SEARCH_URL"] = "" from langchain.utilities import BingSearchAPIWrapper search = BingSearchAPIWrapper() search.run("python")
https://python.langchain.com/en/latest/modules/agents/tools/examples/bing_search.html
e5170741dc19-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 Azure CLI with <b>Python</b> by Dan Taylor. <b>Python</b> releases by version number: Release version Release date Click for more. <b>Python</b> 3.11.1 Dec. 6, 2022 Download Release Notes. <b>Python</b> 3.10.9 Dec. 6, 2022 Download Release Notes. <b>Python</b> 3.9.16 Dec. 6, 2022 Download Release Notes. <b>Python</b> 3.8.16 Dec. 6, 2022 Download Release Notes. <b>Python</b> 3.7.16 Dec. 6, 2022 Download Release Notes. In this lesson, we will look at the += operator in <b>Python</b> and see how it works with several simple examples.. The operator ‘+=’ is a shorthand for the addition assignment operator.It adds two values and assigns the sum
https://python.langchain.com/en/latest/modules/agents/tools/examples/bing_search.html
e5170741dc19-2
assignment operator.It adds two values and assigns the sum to a variable (left operand). W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, <b>Python</b>, SQL, Java, and many, many more. This tutorial introduces the reader informally to the basic concepts and features 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-purpose, versatile, and powerful programming language. It&#39;s a great first language because <b>Python</b> code is concise and easy to read. Whatever you want to do, <b>python</b> can do it. From web development to machine learning to data science, <b>Python</b> is the language for you. To install <b>Python</b> using the Microsoft Store:
https://python.langchain.com/en/latest/modules/agents/tools/examples/bing_search.html
e5170741dc19-3
To install <b>Python</b> using the Microsoft Store: Go to your Start menu (lower left Windows icon), type &quot;Microsoft Store&quot;, select the link to open the store. Once the store is open, select Search from the upper-right menu and enter &quot;<b>Python</b>&quot;. Select which version of <b>Python</b> you would like to use from the results under Apps. Under the “<b>Python</b> Releases for Mac OS X” heading, click the link for the Latest <b>Python</b> 3 Release - <b>Python</b> 3.x.x. As of this writing, the latest version was <b>Python</b> 3.8.4. Scroll to the bottom and click macOS 64-bit installer to start the download. When the installer is finished downloading, move on to the next step. Step 2: Run the Installer'
https://python.langchain.com/en/latest/modules/agents/tools/examples/bing_search.html
e5170741dc19-4
Number of results# You can use the k parameter to set the number of results search = BingSearchAPIWrapper(k=1) search.run("python") 'Thanks to the flexibility of <b>Python</b> and the powerful ecosystem of packages, the Azure CLI supports features such as autocompletion (in shells that support it), persistent credentials, JMESPath result parsing, lazy initialization, network-less unit tests, and more. Building an open-source and cross-platform Azure CLI with <b>Python</b> by Dan Taylor.' Metadata Results# Run query through BingSearch and return snippet, title, and link metadata. Snippet: The description of the result. Title: The title of the result. Link: The link to the result. search = BingSearchAPIWrapper() search.results("apples", 5) [{'snippet': 'Lady Alice. Pink Lady <b>apples</b> aren’t the only lady in the apple family. Lady Alice <b>apples</b> were discovered growing, thanks to bees pollinating, in Washington. They are smaller and slightly more stout in appearance than other varieties. Their skin color appears to have red and yellow stripes running from stem to butt.', 'title': '25 Types of Apples - Jessica Gavin', 'link': 'https://www.jessicagavin.com/types-of-apples/'}, {'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 &amp; Health Benefits - WebMD', 'link': 'https://www.webmd.com/food-recipes/benefits-apples'},
https://python.langchain.com/en/latest/modules/agents/tools/examples/bing_search.html
e5170741dc19-5
{'snippet': '<b>Apples</b> boast many vitamins and minerals, though not in high amounts. However, <b>apples</b> are usually a good source of vitamin C. Vitamin C. Also called ascorbic acid, this vitamin is a common ...', 'title': 'Apples 101: Nutrition Facts and Health Benefits', 'link': 'https://www.healthline.com/nutrition/foods/apples'}, {'snippet': 'Weight management. The fibers in <b>apples</b> can slow digestion, helping one to feel greater satisfaction after eating. After following three large prospective cohorts of 133,468 men and women for 24 years, researchers found that higher intakes of fiber-rich fruits with a low glycemic load, particularly <b>apples</b> and pears, were associated with the least amount of weight gain over time.', 'title': 'Apples | The Nutrition Source | Harvard T.H. Chan School of Public Health', 'link': 'https://www.hsph.harvard.edu/nutritionsource/food-features/apples/'}] previous Bash next ChatGPT Plugins Contents Number of results Metadata Results By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 21, 2023.
https://python.langchain.com/en/latest/modules/agents/tools/examples/bing_search.html
991e16165ebc-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 wrapper with arbitrary parameters. For example, in the below example we will use bing instead of google. params = { "engine": "bing", "gl": "us", "hl": "en", } search = SerpAPIWrapper(params=params) search.run("Obama's first name?") 'Barack Hussein Obama II is an American politician who served as the 44th president of the United States from 2009 to 2017. A member of the Democratic Party, Obama was the first African-American presi…New content will be added above the current area of focus upon selectionBarack Hussein Obama II is an American politician who served as the 44th president of the United States from 2009 to 2017. A member of the Democratic Party, Obama was the first African-American president of the United States. He previously served as a U.S. senator from Illinois from 2005 to 2008 and as an Illinois state senator from 1997 to 2004, and previously worked as a civil rights lawyer before entering politics.Wikipediabarackobama.com' previous SearxNG Search API next Wikipedia API Contents Custom Parameters By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 21, 2023.
https://python.langchain.com/en/latest/modules/agents/tools/examples/serpapi.html
71930782226f-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 SearxSearchWrapper search = SearxSearchWrapper(searx_host="http://127.0.0.1:8888") For some engines, if a direct answer is available the warpper will print the answer instead of the full list of search results. You can use the results method of the wrapper if you want to obtain all the results. search.run("What is the capital of France") 'Paris is the capital of France, the largest country of Europe with 550 000 km2 (65 millions inhabitants). Paris has 2.234 million inhabitants end 2011. She is the core of Ile de France region (12 million people).' Custom Parameters# SearxNG supports up to 139 search engines. You can also customize the Searx wrapper with arbitrary named parameters that will be passed to the Searx search API . In the below example we will making a more interesting use of custom search parameters from searx search api. In this example we will be using the engines parameters to query wikipedia search = SearxSearchWrapper(searx_host="http://127.0.0.1:8888", k=5) # k is for max number of items search.run("large language model ", engines=['wiki'])
https://python.langchain.com/en/latest/modules/agents/tools/examples/searx_search.html
71930782226f-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 capabilities.\n\nGPT-3 can translate language, write essays, generate computer code, and more — all with limited to no supervision. In July 2020, OpenAI unveiled GPT-3, a language model that was easily the largest known at the time. Put simply, GPT-3 is trained to predict the next word in a sentence, much like how a text message autocomplete feature works.\n\nA large language model, or LLM, is a deep learning algorithm that can recognize, summarize, translate, predict and generate text and other content based on knowledge gained from massive datasets. Large language models are among the most successful applications of transformer models.\n\nAll of today’s well-known language models—e.g., GPT-3 from OpenAI, PaLM or LaMDA from Google, Galactica or OPT from Meta, Megatron-Turing from Nvidia/Microsoft, Jurassic-1 from AI21 Labs—are...\n\nLarge language models (LLMs) such as GPT-3are increasingly being used to generate text. These tools should be used with care, since they can generate content that is biased, non-verifiable, constitutes original research, or violates copyrights.' 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'])
https://python.langchain.com/en/latest/modules/agents/tools/examples/searx_search.html
71930782226f-2
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) que intenta modelar abstracciones de alto nivel en datos usando arquitecturas computacionales que admiten transformaciones no lineales múltiples e iterativas de datos expresados en forma matricial o tensorial. 1' Obtaining results with metadata# In this example we will be looking for scientific paper using the categories parameter and limiting the results to a time_range (not all engines support the time range option). We also would like to obtain the results in a structured way including metadata. For this we will be using the results method of the wrapper. search = SearxSearchWrapper(searx_host="http://127.0.0.1:8888") results = search.results("Large Language Model prompt", num_results=5, categories='science', time_range='year') pprint.pp(results) [{'snippet': '… on natural language instructions, large language models (… the ' 'prompt used to steer the model, and most effective prompts … to ' 'prompt engineering, we propose Automatic Prompt …', 'title': 'Large language models are human-level prompt engineers', 'link': 'https://arxiv.org/abs/2211.01910', '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: Chaining large language model prompts through '
https://python.langchain.com/en/latest/modules/agents/tools/examples/searx_search.html
71930782226f-3
'title': 'Promptchainer: Chaining large language model prompts through ' 'visual programming', 'link': 'https://dl.acm.org/doi/abs/10.1145/3491101.3519729', 'engines': ['google scholar'], 'category': 'science'}, {'snippet': '… can introspect the large prompt model. We derive the view ' 'ϕ0(X) and the model h0 from T01. However, instead of fully ' 'fine-tuning T0 during co-training, we focus on soft prompt ' 'tuning, …', 'title': 'Co-training improves prompt-based learning for large language ' 'models', 'link': 'https://proceedings.mlr.press/v162/lang22a.html', 'engines': ['google scholar'], 'category': 'science'}, {'snippet': '… With the success of large language models (LLMs) of code and ' 'their use as … prompt design process become important. In this ' 'work, we propose a framework called Repo-Level Prompt …', 'title': 'Repository-level prompt generation for large language models of ' '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 point estimates the ' 'unique …', 'title': 'Can language models learn from explanations in context?', 'link': 'https://arxiv.org/abs/2204.02329',
https://python.langchain.com/en/latest/modules/agents/tools/examples/searx_search.html
71930782226f-4
'link': 'https://arxiv.org/abs/2204.02329', 'engines': ['google scholar'], 'category': 'science'}] Get papers from arxiv results = search.results("Large Language Model prompt", num_results=5, engines=['arxiv']) pprint.pp(results) [{'snippet': 'Thanks to the advanced improvement of large pre-trained language ' 'models, prompt-based fine-tuning is shown to be effective on a ' 'variety of downstream tasks. Though many prompting methods have ' 'been investigated, it remains unknown which type of prompts are ' 'the most effective among three types of prompts (i.e., ' 'human-designed prompts, schema prompts and null prompts). In ' 'this work, we empirically compare the three types of prompts ' 'under both few-shot and fully-supervised settings. Our ' 'experimental results show that schema prompts are the most ' '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-prompt automated essay scoring (AES) requires the system ' 'to use non target-prompt essays to award scores to a ' 'target-prompt essay. Since obtaining a large quantity of ' 'pre-graded essays to a particular prompt is often difficult and ' 'unrealistic, the task of cross-prompt AES is vital for the ' 'development of real-world AES systems, yet it remains an '
https://python.langchain.com/en/latest/modules/agents/tools/examples/searx_search.html
71930782226f-5
'development of real-world AES systems, yet it remains an ' 'under-explored area of research. Models designed for ' 'prompt-specific AES rely heavily on prompt-specific knowledge ' 'and perform poorly in the cross-prompt setting, whereas current ' 'approaches to cross-prompt AES either require a certain quantity ' 'of labelled target-prompt essays or require a large quantity of ' 'unlabelled target-prompt essays to perform transfer learning in ' 'a multi-step manner. To address these issues, we introduce ' 'Prompt Agnostic Essay Scorer (PAES) for cross-prompt AES. Our ' 'method requires no access to labelled or unlabelled ' '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 Approach to ' 'Cross-prompt Automated Essay Scoring', 'link': 'http://arxiv.org/abs/2008.01441v1', 'engines': ['arxiv'], 'category': 'science'}, {'snippet': 'Research on prompting has shown excellent performance with ' 'little or even no supervised training across many tasks. ' 'However, prompting for machine translation is still ' 'under-explored in the literature. We fill this gap by offering a ' 'systematic study on prompting strategies for translation, ' 'examining various factors for prompt template and demonstration ' 'example selection. We further explore the use of monolingual '
https://python.langchain.com/en/latest/modules/agents/tools/examples/searx_search.html
71930782226f-6
'example selection. We further explore the use of monolingual ' 'data and the feasibility of cross-lingual, cross-domain, and ' 'sentence-to-document transfer learning in prompting. Extensive ' 'experiments with GLM-130B (Zeng et al., 2022) as the testbed ' 'show that 1) the number and the quality of prompt examples ' 'matter, where using suboptimal examples degenerates translation; ' '2) several features of prompt examples, such as semantic ' 'similarity, show significant Spearman correlation with their ' '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 knowledge from prompt examples selected in other ' 'settings. We finally provide an analysis on the model outputs ' 'and discuss several problems that prompting still suffers from.', 'title': 'Prompting Large Language Model for Machine Translation: A Case ' 'Study', 'link': 'http://arxiv.org/abs/2301.07069v2', 'engines': ['arxiv'], 'category': 'science'}, {'snippet': 'Large language models can perform new tasks in a zero-shot ' 'fashion, given natural language prompts that specify the desired ' 'behavior. Such prompts are typically hand engineered, but can ' 'also be learned with gradient-based methods from labeled data. ' 'However, it is underexplored what factors make the prompts ' 'effective, especially when the prompts are natural language. In '
https://python.langchain.com/en/latest/modules/agents/tools/examples/searx_search.html
71930782226f-7
'effective, especially when the prompts are natural language. In ' 'this paper, we investigate common attributes shared by effective ' 'prompts. We first propose a human readable prompt tuning method ' '(F LUENT P ROMPT) based on Langevin dynamics that incorporates a ' 'fluency constraint to find a diverse distribution of effective ' 'and fluent prompts. Our analysis reveals that effective prompts ' 'are topically related to the task domain and calibrate the prior ' '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 The Shining is a " 'good movie, and a good prompt too?', 'link': 'http://arxiv.org/abs/2212.10539v1', 'engines': ['arxiv'], 'category': 'science'}, {'snippet': 'Prevailing methods for mapping large generative language models ' "to supervised tasks may fail to sufficiently probe models' novel " 'capabilities. Using GPT-3 as a case study, we show that 0-shot ' 'prompts can significantly outperform few-shot prompts. We ' 'suggest that the function of few-shot examples in these cases is ' 'better described as locating an already learned task rather than ' 'meta-learning. This analysis motivates rethinking the role of ' 'prompts in controlling and evaluating powerful language models. ' 'In this work, we discuss methods of prompt programming, '
https://python.langchain.com/en/latest/modules/agents/tools/examples/searx_search.html
71930782226f-8
'In this work, we discuss methods of prompt programming, ' 'emphasizing the usefulness of considering prompts through the ' 'lens of natural language. We explore techniques for exploiting ' 'the capacity of narratives and cultural anchors to encode ' 'nuanced intentions and techniques for encouraging deconstruction ' 'of a problem into components before producing a verdict. ' '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 ' 'interacting with language models can be incorporated into ' 'existing and future benchmarks and practical applications.', 'title': 'Prompt Programming for Large Language Models: Beyond the Few-Shot ' 'Paradigm', 'link': 'http://arxiv.org/abs/2102.07350v1', 'engines': ['arxiv'], 'category': 'science'}] In this example we query for large language models under the it category. We then filter the results that come from github. results = search.results("large language model", num_results = 20, categories='it') pprint.pp(list(filter(lambda r: r['engines'][0] == 'github', results))) [{'snippet': 'Guide to using pre-trained large language models of source code', 'title': 'Code-LMs', 'link': 'https://github.com/VHellendoorn/Code-LMs', 'engines': ['github'], 'category': 'it'}, {'snippet': 'Dramatron uses large language models to generate coherent ' 'scripts and screenplays.',
https://python.langchain.com/en/latest/modules/agents/tools/examples/searx_search.html
71930782226f-9
'scripts and screenplays.', 'title': 'dramatron', '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 'A Watermark for Large Language Models' paper " 'by Kirchenbauer & Geiping et. al.', 'title': 'Peutlefaire / LMWatermark', 'link': 'https://gitlab.com/BrianPulfer/LMWatermark', 'engines': ['gitlab'], 'category': 'it'}, {'snippet': 'Guide to using pre-trained large language models of source code', 'title': 'Code-LMs', 'link': 'https://github.com/VHellendoorn/Code-LMs', 'engines': ['github'], 'category': 'it'}, {'snippet': '', 'title': 'Simen Burud / Large-scale Language Models for Conversational ' 'Speech Recognition', 'link': 'https://gitlab.com/BrianPulfer', 'engines': ['gitlab'], 'category': 'it'}, {'snippet': 'Dramatron uses large language models to generate coherent ' 'scripts and screenplays.', 'title': 'dramatron', 'link': 'https://github.com/deepmind/dramatron', 'engines': ['github'], 'category': 'it'},
https://python.langchain.com/en/latest/modules/agents/tools/examples/searx_search.html
71930782226f-10
'engines': ['github'], 'category': 'it'}, {'snippet': 'Code for loralib, an implementation of "LoRA: Low-Rank ' 'Adaptation of Large Language Models"', 'title': 'LoRA', 'link': 'https://github.com/microsoft/LoRA', 'engines': ['github'], 'category': 'it'}, {'snippet': 'Code for the paper "Evaluating Large Language Models Trained on ' 'Code"', 'title': 'human-eval', 'link': 'https://github.com/openai/human-eval', 'engines': ['github'], 'category': 'it'}, {'snippet': 'A trend starts from "Chain of Thought Prompting Elicits ' 'Reasoning in Large Language Models".', 'title': 'Chain-of-ThoughtsPapers', 'link': 'https://github.com/Timothyxxx/Chain-of-ThoughtsPapers', 'engines': ['github'], 'category': 'it'}, {'snippet': 'Mistral: A strong, northwesterly wind: Framework for transparent ' '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 ' 'show inverse scaling', 'title': 'prize', 'link': 'https://github.com/inverse-scaling/prize', 'engines': ['github'],
https://python.langchain.com/en/latest/modules/agents/tools/examples/searx_search.html
71930782226f-11
'engines': ['github'], 'category': 'it'}, {'snippet': 'Optimus: the first large-scale pre-trained VAE language model', 'title': 'Optimus', 'link': 'https://github.com/ChunyuanLI/Optimus', 'engines': ['github'], 'category': 'it'}, {'snippet': 'Seminar on Large Language Models (COMP790-101 at UNC Chapel ' 'Hill, Fall 2022)', 'title': 'llm-seminar', 'link': 'https://github.com/craffel/llm-seminar', 'engines': ['github'], 'category': 'it'}, {'snippet': 'A central, open resource for data and tools related to ' 'chain-of-thought reasoning in large language models. Developed @ ' '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, codes, and related ' 'websites', 'title': 'Awesome-LLM-Robotics', 'link': 'https://github.com/GT-RIPL/Awesome-LLM-Robotics', 'engines': ['github'], 'category': 'it'}, {'snippet': 'Tools for curating biomedical training data for large-scale ' 'language modeling', 'title': 'biomedical', 'link': 'https://github.com/bigscience-workshop/biomedical',
https://python.langchain.com/en/latest/modules/agents/tools/examples/searx_search.html
71930782226f-12
'link': 'https://github.com/bigscience-workshop/biomedical', 'engines': ['github'], 'category': 'it'}, {'snippet': 'ChatGPT @ Home: Large Language Model (LLM) chatbot application, ' 'written by ChatGPT', 'title': 'ChatGPT-at-Home', 'link': 'https://github.com/Sentdex/ChatGPT-at-Home', 'engines': ['github'], 'category': 'it'}, {'snippet': 'Design and Deploy Large Language Model Apps', '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'], 'category': 'it'}, {'snippet': 'Code release for "Learning Video Representations from Large ' 'Language Models"', 'title': 'LaViLa', 'link': 'https://github.com/facebookresearch/LaViLa', 'engines': ['github'], 'category': 'it'}, {'snippet': 'SmoothQuant: Accurate and Efficient Post-Training Quantization ' 'for Large Language Models', 'title': 'smoothquant', 'link': 'https://github.com/mit-han-lab/smoothquant', 'engines': ['github'], 'category': 'it'},
https://python.langchain.com/en/latest/modules/agents/tools/examples/searx_search.html
71930782226f-13
'engines': ['github'], 'category': 'it'}, {'snippet': 'This repository contains the code, data, and models of the paper ' 'titled "XL-Sum: Large-Scale Multilingual Abstractive ' 'Summarization for 44 Languages" published in Findings of the ' 'Association for Computational Linguistics: ACL-IJCNLP 2021.', '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 21, 2023.
https://python.langchain.com/en/latest/modules/agents/tools/examples/searx_search.html
cfb1cc5bb357-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.cloud.google.com/apis/credentials) and a GOOGLE_CSE_ID using the Programmable Search Enginge (https://programmablesearchengine.google.com/controlpanel/create). Next, it is good to follow the instructions found here. Then we will need to set some environment variables. import os os.environ["GOOGLE_CSE_ID"] = "" os.environ["GOOGLE_API_KEY"] = "" from langchain.utilities import GoogleSearchAPIWrapper search = GoogleSearchAPIWrapper() search.run("Obama's first name?")
https://python.langchain.com/en/latest/modules/agents/tools/examples/google_search.html
cfb1cc5bb357-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 the “II” is simply because he was named for his father, his last name is Obama. Feb 9, 2015 ... Michael Jordan misspelled Barack Obama\'s first name on 50th-birthday gift ... Knowing Obama is a Chicagoan and huge basketball fan,\xa0... Aug 18, 2017 ... It took him several seconds and multiple clues to remember former President Barack Obama\'s first name. Miller knew that every answer had to end\xa0... First Lady Michelle LaVaughn Robinson Obama is a lawyer, writer, and the wife of the 44th President, Barack Obama. She is the first African-American First\xa0... 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\xa0... When Barack Obama was elected president in 2008, he became the first African American to hold ... The Middle East remained a key foreign policy challenge. Feb 27, 2020 ... President Barack Obama was born Barack Hussein Obama, II, as shown here on his birth certificate here . As reported by Reuters here , his\xa0... Jan 16, 2007 ... 4, 1961, in Honolulu. His first name means "one who is blessed" in Swahili. While Obama\'s father, Barack Hussein Obama Sr., was from Kenya, his\xa0...'
https://python.langchain.com/en/latest/modules/agents/tools/examples/google_search.html
cfb1cc5bb357-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, and link metadata. Snippet: The description of the result. Title: The title of the result. Link: The link to the result. search = GoogleSearchAPIWrapper() search.results("apples", 5) [{'snippet': 'Discover the innovative world of Apple and shop everything iPhone, iPad, Apple Watch, Mac, and Apple TV, plus explore accessories, entertainment,\xa0...', 'title': 'Apple', 'link': 'https://www.apple.com/'}, {'snippet': "Jul 10, 2022 ... Whether or not you're up on your apple trivia, no doubt you know how delicious this popular fruit is, and how nutritious. Apples are rich in\xa0...", 'title': '25 Types of Apples and What to Make With Them - Parade ...', 'link': 'https://parade.com/1330308/bethlipton/types-of-apples/'}, {'snippet': 'An apple is an edible fruit produced by an apple tree (Malus domestica). Apple trees are cultivated worldwide and are the most widely grown species in the\xa0...', 'title': 'Apple - Wikipedia', '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',
https://python.langchain.com/en/latest/modules/agents/tools/examples/google_search.html
cfb1cc5bb357-3
'title': 'Apples: Benefits, nutrition, and tips', 'link': 'https://www.medicalnewstoday.com/articles/267290'}, {'snippet': "An apple is a crunchy, bright-colored fruit, one of the most popular in the United States. You've probably heard the age-old saying, “An apple a day keeps\xa0...", 'title': 'Apples: Nutrition & Health Benefits', 'link': 'https://www.webmd.com/food-recipes/benefits-apples'}] previous Google Places next Google Serper API Contents Number of Results Metadata Results By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 21, 2023.
https://python.langchain.com/en/latest/modules/agents/tools/examples/google_search.html
54d76554f292-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?")
https://python.langchain.com/en/latest/modules/agents/tools/examples/ddg.html
54d76554f292-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 h uː ˈ s eɪ n oʊ ˈ b ɑː m ə / bə-RAHK hoo-SAYN oh-BAH-mə; born August 4, 1961) is an American former politician who served as the 44th president of the United States from 2009 to 2017. A member of the Democratic Party, he was the first African-American president of the United States. Obama previously served as a U.S. senator representing ... Barack Obama was the first African American president of the United States (2009-17). He oversaw the recovery of the U.S. economy (from the Great Recession of 2008-09) and the enactment of landmark health care reform (the Patient Protection and Affordable Care Act ). In 2009 he was awarded the Nobel Peace Prize. His birth certificate lists his first name as Barack: That\'s how Obama has spelled his name throughout his life. His name derives from a Hebrew name which means "lightning.". The Hebrew word has been transliterated into English in various spellings, including Barak, Buraq, Burack, and Barack. Most common names of U.S. presidents 1789-2021. Published by. Aaron O\'Neill , Jun 21, 2022. The most common first name for a U.S. president is James, followed by John and then William. Six U.S ...' previous ChatGPT Plugins
https://python.langchain.com/en/latest/modules/agents/tools/examples/ddg.html
54d76554f292-2
previous ChatGPT Plugins next Google Places By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 21, 2023.
https://python.langchain.com/en/latest/modules/agents/tools/examples/ddg.html
55af05ea7773-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, you can use it to extract Google Search results, Instagram and Facebook profiles, products from Amazon or Shopify, Google Maps reviews, etc. etc. In this example, we’ll use the Website Content Crawler Actor, which can deeply crawl websites such as documentation, knowledge bases, help centers, or blogs, and extract text content from the web pages. Then we feed the documents into a vector index and answer questions from it. First, import ApifyWrapper into your source code: from langchain.document_loaders.base import Document from langchain.indexes import VectorstoreIndexCreator from langchain.utilities import ApifyWrapper Initialize it using your Apify API token and for the purpose of this example, also with your OpenAI API key: import os os.environ["OPENAI_API_KEY"] = "Your OpenAI API key" os.environ["APIFY_API_TOKEN"] = "Your Apify API token" apify = ApifyWrapper() Then run the Actor, wait for it to finish, and fetch its results from the Apify dataset into a LangChain document loader. 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. loader = apify.call_actor( actor_id="apify/website-content-crawler",
https://python.langchain.com/en/latest/modules/agents/tools/examples/apify.html
55af05ea7773-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 from the crawled documents: index = VectorstoreIndexCreator().from_loaders([loader]) And finally, query the vector index: query = "What is LangChain?" result = index.query_with_sources(query) print(result["answer"]) print(result["sources"]) LangChain is a standard interface through which you can interact with a variety of large language models (LLMs). It provides modules that can be used to build language model applications, and it also provides chains and agents with memory capabilities. https://python.langchain.com/en/latest/modules/models/llms.html, https://python.langchain.com/en/latest/getting_started/getting_started.html previous Tool Input Schema next Arxiv API By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 21, 2023.
https://python.langchain.com/en/latest/modules/agents/tools/examples/apify.html
d8acc12f7e2f-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 AgentType llm = ChatOpenAI(temperature=0.0) math_llm = OpenAI(temperature=0.0) tools = load_tools( ["human", "llm-math"], llm=math_llm, ) agent_chain = initialize_agent( tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True, ) In the above code you can see the tool takes input directly from command line. You can customize prompt_func and input_func according to your need. agent_chain.run("What is Eric Zhu's birthday?") # Answer with "last week" > Entering new AgentExecutor chain... I don't know Eric Zhu, so I should ask a human for guidance. Action: Human Action Input: "Do you know when Eric Zhu's birthday is?" Do you know when Eric Zhu's birthday is? last week Observation: last week Thought:That's not very helpful. I should ask for more information. Action: Human Action Input: "Do you know the specific date of Eric Zhu's birthday?" Do you know the specific date of Eric Zhu's birthday? august 1st Observation: august 1st Thought:Now that I have the date, I can check if it's a leap year or not. Action: Calculator Action Input: "Is 2021 a leap year?"
https://python.langchain.com/en/latest/modules/agents/tools/examples/human_tools.html
d8acc12f7e2f-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 year in 2021." previous Gradio Tools next IFTTT WebHooks By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 21, 2023.
https://python.langchain.com/en/latest/modules/agents/tools/examples/human_tools.html
678dc8d1c5e7-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 langchain.utilities import GoogleSerperAPIWrapper search = GoogleSerperAPIWrapper() search.run("Obama's first name?") 'Barack Hussein Obama II' As part of a Self Ask With Search Chain# os.environ['OPENAI_API_KEY'] = "" from langchain.utilities import GoogleSerperAPIWrapper from langchain.llms.openai import OpenAI from langchain.agents import initialize_agent, Tool from langchain.agents import AgentType llm = OpenAI(temperature=0) search = GoogleSerperAPIWrapper() tools = [ Tool( name="Intermediate Answer", func=search.run, description="useful for when you need to ask with search" ) ] self_ask_with_search = initialize_agent(tools, llm, agent=AgentType.SELF_ASK_WITH_SEARCH, verbose=True) self_ask_with_search.run("What is the hometown of the reigning men's U.S. Open champion?") > Entering new AgentExecutor chain... Yes. Follow up: Who is the reigning men's U.S. Open champion? Intermediate answer: Current champions Carlos Alcaraz, 2022 men's singles champion. 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
https://python.langchain.com/en/latest/modules/agents/tools/examples/google_serper.html
678dc8d1c5e7-1
'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. Last updated on Apr 21, 2023.
https://python.langchain.com/en/latest/modules/agents/tools/examples/google_serper.html
ff75455b44e6-0
.ipynb .pdf Wikipedia API Wikipedia API# This notebook goes over how to use the wikipedia component. First, you need to install wikipedia python package. pip install wikipedia from langchain.utilities import WikipediaAPIWrapper wikipedia = WikipediaAPIWrapper() wikipedia.run('HUNTER X HUNTER')
https://python.langchain.com/en/latest/modules/agents/tools/examples/wikipedia.html
ff75455b44e6-1
'Page: Hunter × Hunter\nSummary: Hunter × Hunter (stylized as HUNTER×HUNTER and pronounced "hunter hunter") is a Japanese manga series written and illustrated by Yoshihiro Togashi. It has been serialized in Shueisha\'s shōnen manga magazine Weekly Shōnen Jump since March 1998, although the manga has frequently gone on extended hiatuses since 2006. Its chapters have been collected in 37 tankōbon volumes as of November 2022. The story focuses on a young boy named Gon Freecss who discovers that his father, who left him at a young age, is actually a world-renowned Hunter, a licensed professional who specializes in fantastical pursuits such as locating rare or unidentified animal species, treasure hunting, surveying unexplored enclaves, or hunting down lawless individuals. Gon departs on a journey to become a Hunter and eventually find his father. Along the way, Gon meets various other Hunters and encounters the paranormal.\nHunter × Hunter was adapted into a 62-episode
https://python.langchain.com/en/latest/modules/agents/tools/examples/wikipedia.html