id
stringlengths
14
16
text
stringlengths
29
2.73k
source
stringlengths
49
117
d70d254758ea-3
Document(page_content='Toys come alive and have a blast doing so', metadata={'genre': 'animated', 'year': 1995.0}), Document(page_content='A psychologist / detective gets lost in a series of dreams within dreams within dreams and Inception reused the idea', metadata={'director': 'Satoshi Kon', 'rating': 8.6, 'year': 2...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/self_query.html
d70d254758ea-4
[Document(page_content='A bunch of normal-sized women are supremely wholesome and some men pine after them', metadata={'director': 'Greta Gerwig', 'rating': 8.3, 'year': 2019.0})] # This example specifies a composite filter retriever.get_relevant_documents("What's a highly rated (above 8.5) science fiction film?") quer...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/self_query.html
d70d254758ea-5
We can do this by passing enable_limit=True to the constructor. retriever = SelfQueryRetriever.from_llm( llm, vectorstore, document_content_description, metadata_field_info, enable_limit=True, verbose=True ) # This example only specifies a relevant query retriever.get_relevant_documents("Wha...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/self_query.html
320a672bf6e3-0
.ipynb .pdf ElasticSearch BM25 Contents Create New Retriever Add texts (if necessary) Use Retriever ElasticSearch BM25# Elasticsearch is a distributed, RESTful search and analytics engine. It provides a distributed, multitenant-capable full-text search engine with an HTTP web interface and schema-free JSON documents....
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/elastic_search_bm25.html
320a672bf6e3-1
# import elasticsearch # elasticsearch_url="http://localhost:9200" # retriever = ElasticSearchBM25Retriever(elasticsearch.Elasticsearch(elasticsearch_url), "langchain-index") Add texts (if necessary)# We can optionally add texts to the retriever (if they aren’t already in there) retriever.add_texts(["foo", "bar", "worl...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/elastic_search_bm25.html
30e2970208dc-0
.ipynb .pdf kNN Contents Create New Retriever with Texts Use Retriever kNN# In statistics, the k-nearest neighbors algorithm (k-NN) is a non-parametric supervised learning method first developed by Evelyn Fix and Joseph Hodges in 1951, and later expanded by Thomas Cover. It is used for classification and regression. ...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/knn.html
c6cba752147a-0
.ipynb .pdf Wikipedia Contents Installation Examples Running retriever Question Answering on facts Wikipedia# Wikipedia is a multilingual free online encyclopedia written and maintained by a community of volunteers, known as Wikipedians, through open collaboration and using a wiki-based editing system called MediaWik...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/wikipedia.html
c6cba752147a-1
'summary': '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 sin...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/wikipedia.html
c6cba752147a-2
with the first series having aired on the Funimation Channel in 2009 and the second series broadcast on Adult Swim\'s Toonami programming block from April 2016 to June 2019.\nHunter × Hunter has been a huge critical and financial success and has become one of the best-selling manga series of all time, having over 84 mi...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/wikipedia.html
c6cba752147a-3
docs[0].page_content[:400] # a content of the Document '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 mang...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/wikipedia.html
c6cba752147a-4
-> **Question**: What is Apify? **Answer**: Apify is a platform that allows you to easily automate web scraping, data extraction and web automation. It provides a cloud-based infrastructure for running web crawlers and other automation tasks, as well as a web-based tool for building and managing your crawlers. Additio...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/wikipedia.html
3cb90acfe782-0
.ipynb .pdf Self-querying with Chroma Contents Creating a Chroma vectorstore Creating our self-querying retriever Testing it out Filter k Self-querying with Chroma# Chroma is a database for building AI applications with embeddings. In the notebook we’ll demo the SelfQueryRetriever wrapped around a Chroma vector store...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/chroma_self_query.html
3cb90acfe782-1
Document(page_content="A bunch of normal-sized women are supremely wholesome and some men pine after them", metadata={"year": 2019, "director": "Greta Gerwig", "rating": 8.3}), Document(page_content="Toys come alive and have a blast doing so", metadata={"year": 1995, "genre": "animated"}), Document(page_content...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/chroma_self_query.html
3cb90acfe782-2
type="float" ), ] document_content_description = "Brief summary of a movie" llm = OpenAI(temperature=0) retriever = SelfQueryRetriever.from_llm(llm, vectorstore, document_content_description, metadata_field_info, verbose=True) Testing it out# And now we can try actually using our retriever! # This example only spec...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/chroma_self_query.html
3cb90acfe782-3
Document(page_content='Three men walk into the Zone, three men walk out of the Zone', metadata={'year': 1979, 'rating': 9.9, 'director': 'Andrei Tarkovsky', 'genre': 'science fiction'})] # This example specifies a query and a filter retriever.get_relevant_documents("Has Greta Gerwig directed any movies about women") qu...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/chroma_self_query.html
3cb90acfe782-4
query='toys' filter=Operation(operator=<Operator.AND: 'and'>, arguments=[Comparison(comparator=<Comparator.GT: 'gt'>, attribute='year', value=1990), Comparison(comparator=<Comparator.LT: 'lt'>, attribute='year', value=2005), Comparison(comparator=<Comparator.EQ: 'eq'>, attribute='genre', value='animated')]) [Document(p...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/chroma_self_query.html
3cb90acfe782-5
Document(page_content='Leo DiCaprio gets lost in a dream within a dream within a dream within a ...', metadata={'year': 2010, 'director': 'Christopher Nolan', 'rating': 8.2})] previous ChatGPT Plugin next Cohere Reranker Contents Creating a Chroma vectorstore Creating our self-querying retriever Testing it out Filt...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/chroma_self_query.html
5f84c37f5cce-0
.ipynb .pdf Cohere Reranker Contents Set up the base vector store retriever Doing reranking with CohereRerank Cohere Reranker# Cohere is a Canadian startup that provides natural language processing models that help companies improve human-machine interactions. This notebook shows how to use Cohere’s rerank endpoint i...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/cohere-reranker.html
5f84c37f5cce-1
texts = text_splitter.split_documents(documents) retriever = FAISS.from_documents(texts, OpenAIEmbeddings()).as_retriever(search_kwargs={"k": 20}) query = "What did the president say about Ketanji Brown Jackson" docs = retriever.get_relevant_documents(query) pretty_print_docs(docs) Document 1: One of the most serious c...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/cohere-reranker.html
5f84c37f5cce-2
Groups of citizens blocking tanks with their bodies. Everyone from students to retirees teachers turned soldiers defending their homeland. In this struggle as President Zelenskyy said in his speech to the European Parliament “Light will win over darkness.” The Ukrainian Ambassador to the United States is here tonight....
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/cohere-reranker.html
5f84c37f5cce-3
It’s exploitation—and it drives up prices. ---------------------------------------------------------------------------------------------------- Document 8: For the past 40 years we were told that if we gave tax breaks to those at the very top, the benefits would trickle down to everyone else. But that trickle-down the...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/cohere-reranker.html
5f84c37f5cce-4
The pandemic has been punishing. And so many families are living paycheck to paycheck, struggling to keep up with the rising cost of food, gas, housing, and so much more. I understand. ---------------------------------------------------------------------------------------------------- Document 12: Madam Speaker, Mada...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/cohere-reranker.html
5f84c37f5cce-5
Third, support our veterans. Veterans are the best of us. I’ve always believed that we have a sacred obligation to equip all those we send to war and care for them and their families when they come home. My administration is providing assistance with job training and housing, and now helping lower-income veterans ge...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/cohere-reranker.html
5f84c37f5cce-6
---------------------------------------------------------------------------------------------------- Document 19: I understand. I remember when my Dad had to leave our home in Scranton, Pennsylvania to find work. I grew up in a family where if the price of food went up, you felt it. That’s why one of the first things...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/cohere-reranker.html
5f84c37f5cce-7
And I did that 4 days ago, when I nominated Circuit Court of Appeals Judge Ketanji Brown Jackson. One of our nation’s top legal minds, who will continue Justice Breyer’s legacy of excellence. ---------------------------------------------------------------------------------------------------- Document 2: I spoke with th...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/cohere-reranker.html
5f84c37f5cce-8
previous Self-querying with Chroma next Contextual Compression Contents Set up the base vector store retriever Doing reranking with CohereRerank By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/cohere-reranker.html
41dd099b9667-0
.ipynb .pdf Weaviate Hybrid Search Weaviate Hybrid Search# Weaviate is an open source vector database. Hybrid search is a technique that combines multiple search algorithms to improve the accuracy and relevance of search results. It uses the best features of both keyword-based search algorithms with vector search techn...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/weaviate-hybrid.html
41dd099b9667-1
) Add some data: docs = [ Document( metadata={ "title": "Embracing The Future: AI Unveiled", "author": "Dr. Rebecca Simmons", }, page_content="A comprehensive analysis of the evolution of artificial intelligence, from its inception to its future prospects. Dr. Simmons...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/weaviate-hybrid.html
41dd099b9667-2
"author": "Prof. Jonathan K. Sterling", }, page_content="In his follow-up to 'Symbiosis', Prof. Sterling takes a look at the subtle, unnoticed presence and influence of AI in our everyday lives. It reveals how AI has become woven into our routines, often without our explicit realization.", ), ] retr...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/weaviate-hybrid.html
41dd099b9667-3
Document(page_content='Prof. Sterling explores the potential for harmonious coexistence between humans and artificial intelligence. The book discusses how AI can be integrated into society in a beneficial and non-disruptive manner.', metadata={})] Do a hybrid search with where filter: retriever.get_relevant_documents( ...
https://python.langchain.com/en/latest/modules/indexes/retrievers/examples/weaviate-hybrid.html
e2652b656f20-0
.rst .pdf Tools Tools# Note Conceptual Guide Tools are ways that an agent can use to interact with the outside world. For an overview of what a tool is, how to use them, and a full list of examples, please see the getting started documentation Getting Started Next, we have some examples of customizing and generically w...
https://python.langchain.com/en/latest/modules/agents/tools.html
1417741b00c2-0
.rst .pdf Agents Agents# Note Conceptual Guide In this part of the documentation we cover the different types of agents, disregarding which specific tools they are used with. For a high level overview of the different types of agents, see the below documentation. Agent Types For documentation on how to create a custom ...
https://python.langchain.com/en/latest/modules/agents/agents.html
70309837c16b-0
.rst .pdf Toolkits Toolkits# Note Conceptual Guide This section of documentation covers agents with toolkits - eg an agent applied to a particular use case. See below for a full list of agent toolkits Azure Cognitive Services Toolkit CSV Agent Gmail Toolkit Jira JSON Agent OpenAPI agents Natural Language APIs Pandas Da...
https://python.langchain.com/en/latest/modules/agents/toolkits.html
ef92c669d5fb-0
.rst .pdf Agent Executors Agent Executors# Note Conceptual Guide Agent executors take an agent and tools and use the agent to decide which tools to call and in what order. In this part of the documentation we cover other related functionality to agent executors How to combine agents and vectorstores How to use the asyn...
https://python.langchain.com/en/latest/modules/agents/agent_executors.html
2839187c2197-0
.ipynb .pdf Plan and Execute Contents Plan and Execute Imports Tools Planner, Executor, and Agent Run Example Plan and Execute# Plan and execute agents accomplish an objective by first planning what to do, then executing the sub tasks. This idea is largely inspired by BabyAGI and then the “Plan-and-Solve” paper. The ...
https://python.langchain.com/en/latest/modules/agents/plan_and_execute.html
2839187c2197-1
> Entering new PlanAndExecute chain... steps=[Step(value="Search for Leo DiCaprio's girlfriend on the internet."), Step(value='Find her current age.'), Step(value='Raise her current age to the 0.43 power using a calculator or programming language.'), Step(value='Output the result.'), Step(value="Given the above steps t...
https://python.langchain.com/en/latest/modules/agents/plan_and_execute.html
2839187c2197-2
Current objective: value='Find her current age.' Action: ``` { "action": "Search", "action_input": "What is Gigi Hadid's current age?" } ``` Observation: 28 years Thought:Previous steps: steps=[(Step(value="Search for Leo DiCaprio's girlfriend on the internet."), StepResponse(response='Leo DiCaprio is currently lin...
https://python.langchain.com/en/latest/modules/agents/plan_and_execute.html
2839187c2197-3
Response: Gigi Hadid's current age raised to the 0.43 power is approximately 4.19. > Entering new AgentExecutor chain... Action: ``` { "action": "Final Answer", "action_input": "The result is approximately 4.19." } ``` > Finished chain. ***** Step: Output the result. Response: The result is approximately 4.19. > En...
https://python.langchain.com/en/latest/modules/agents/plan_and_execute.html
63a1b6d429e0-0
.ipynb .pdf Getting Started Getting Started# Agents use an LLM to determine which actions to take and in what order. An action can either be using a tool and observing its output, or returning to the user. When used correctly agents can be extremely powerful. The purpose of this notebook is to show you how to easily us...
https://python.langchain.com/en/latest/modules/agents/getting_started.html
63a1b6d429e0-1
agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True) Now let’s test it out! 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 who Leo DiCaprio's girlfriend is and then calc...
https://python.langchain.com/en/latest/modules/agents/getting_started.html
cacd94c4a8bd-0
.ipynb .pdf Defining Custom Tools Contents Completely New Tools - String Input and Output Tool dataclass Subclassing the BaseTool class Using the tool decorator Custom Structured Tools StructuredTool dataclass Subclassing the BaseTool Using the decorator Modify existing tools Defining the priorities among Tools Using...
https://python.langchain.com/en/latest/modules/agents/tools/custom_tools.html
cacd94c4a8bd-1
Tool dataclass# The ‘Tool’ dataclass wraps functions that accept a single string input and returns a string output. # Load the tool configs that are needed. search = SerpAPIWrapper() llm_math_chain = LLMMathChain(llm=llm, verbose=True) tools = [ Tool.from_function( func=search.run, name = "Search", ...
https://python.langchain.com/en/latest/modules/agents/tools/custom_tools.html
cacd94c4a8bd-2
> Entering new AgentExecutor chain... I need to find out Leo DiCaprio's girlfriend's name and her age Action: Search Action Input: "Leo DiCaprio girlfriend" Observation: After rumours of a romance with Gigi Hadid, the Oscar winner has seemingly moved on. First being linked to the television personality in September 202...
https://python.langchain.com/en/latest/modules/agents/tools/custom_tools.html
cacd94c4a8bd-3
Subclassing the BaseTool class# You can also directly subclass BaseTool. This is useful if you want more control over the instance variables or if you want to propagate callbacks to nested chains or other tools. from typing import Optional, Type from langchain.callbacks.manager import AsyncCallbackManagerForToolRun, Ca...
https://python.langchain.com/en/latest/modules/agents/tools/custom_tools.html
cacd94c4a8bd-4
agent.run("Who is Leo DiCaprio's girlfriend? What is her current age raised to the 0.43 power?") > Entering new AgentExecutor chain... I need to use custom_search to find out who Leo DiCaprio's girlfriend is, and then use the Calculator to raise her age to the 0.43 power. Action: custom_search Action Input: "Leo DiCapr...
https://python.langchain.com/en/latest/modules/agents/tools/custom_tools.html
cacd94c4a8bd-5
'3.547023357958959' Using the tool decorator# To make it easier to define custom tools, a @tool decorator is provided. This decorator can be used to quickly create a Tool from a simple function. The decorator uses the function name as the tool name by default, but this can be overridden by passing a string as the first...
https://python.langchain.com/en/latest/modules/agents/tools/custom_tools.html
cacd94c4a8bd-6
"""Searches the API for the query.""" return "Results" search_api Tool(name='search', description='search(query: str) -> str - Searches the API for the query.', args_schema=<class '__main__.SearchInput'>, return_direct=True, verbose=False, callback_manager=<langchain.callbacks.shared.SharedCallbackManager object at...
https://python.langchain.com/en/latest/modules/agents/tools/custom_tools.html
cacd94c4a8bd-7
description = "useful for when you need to answer questions about current events" def _run(self, query: str, engine: str = "google", gl: str = "us", hl: str = "en", run_manager: Optional[CallbackManagerForToolRun] = None) -> str: """Use the tool.""" search_wrapper = SerpAPIWrapper(params={"engine": ...
https://python.langchain.com/en/latest/modules/agents/tools/custom_tools.html
cacd94c4a8bd-8
return search_wrapper.run(query) async def _arun(self, query: str, engine: str = "google", gl: str = "us", hl: str = "en", run_manager: Optional[AsyncCallbackManagerForToolRun] = None) -> str: """Use the tool asynchronously.""" raise NotImplementedError("custom_search does not support async") ...
https://python.langchain.com/en/latest/modules/agents/tools/custom_tools.html
cacd94c4a8bd-9
Action: Google Search Action Input: "Leo DiCaprio girlfriend" Observation: After rumours of a romance with Gigi Hadid, the Oscar winner has seemingly moved on. First being linked to the television personality in September 2022, it appears as if his "age bracket" has moved up. This follows his rumoured relationship with...
https://python.langchain.com/en/latest/modules/agents/tools/custom_tools.html
cacd94c4a8bd-10
An example is below. # Import things that are needed generically from langchain.agents import initialize_agent, Tool from langchain.agents import AgentType from langchain.llms import OpenAI from langchain import LLMMathChain, SerpAPIWrapper search = SerpAPIWrapper() tools = [ Tool( name = "Search", ...
https://python.langchain.com/en/latest/modules/agents/tools/custom_tools.html
cacd94c4a8bd-11
llm_math_chain = LLMMathChain(llm=llm) tools = [ Tool( name="Calculator", func=llm_math_chain.run, description="useful for when you need to answer questions about math", return_direct=True ) ] llm = OpenAI(temperature=0) agent = initialize_agent(tools, llm, agent=AgentType.ZERO_S...
https://python.langchain.com/en/latest/modules/agents/tools/custom_tools.html
cacd94c4a8bd-12
from langchain.chat_models import ChatOpenAI from langchain.tools import Tool from langchain.chat_models import ChatOpenAI def _handle_error(error:ToolException) -> str: return "The following errors occurred during tool execution:" + error.args[0]+ "Please try another tool." def search_tool1(s: str):raise ToolExce...
https://python.langchain.com/en/latest/modules/agents/tools/custom_tools.html
cacd94c4a8bd-13
Thought:I should try using Search_tool2 instead. Action: Search_tool2 Action Input: "Leo DiCaprio girlfriend" Observation: The following errors occurred during tool execution:The search tool2 is not available.Please try another tool. Thought:I should try using Search_tool3 as a last resort. Action: Search_tool3 Action ...
https://python.langchain.com/en/latest/modules/agents/tools/custom_tools.html
179a5e68878d-0
.ipynb .pdf Tool Input Schema Tool Input Schema# By default, tools infer the argument schema by inspecting the function signature. For more strict requirements, custom input schema can be specified, along with custom validation logic. from typing import Any, Dict from langchain.agents import AgentType, initialize_agent...
https://python.langchain.com/en/latest/modules/agents/tools/tool_input_validation.html
179a5e68878d-1
print(answer) The main title of langchain.com is "LANG CHAIN 🦜️🔗 Official Home Page" agent.run("What's the main title on google.com?") --------------------------------------------------------------------------- ValidationError Traceback (most recent call last) Cell In[7], line 1 ----> 1 agen...
https://python.langchain.com/en/latest/modules/agents/tools/tool_input_validation.html
179a5e68878d-2
114 except (KeyboardInterrupt, Exception) as e: 115 self.callback_manager.on_chain_error(e, verbose=self.verbose) File ~/code/lc/lckg/langchain/agents/agent.py:792, in AgentExecutor._call(self, inputs) 790 # We now enter the agent loop (until it returns something). 791 while self._should_continue(iterat...
https://python.langchain.com/en/latest/modules/agents/tools/tool_input_validation.html
179a5e68878d-3
107 **kwargs: Any, 108 ) -> str: 109 """Run the tool.""" --> 110 run_input = self._parse_input(tool_input) 111 if not self.verbose and verbose is not None: 112 verbose_ = verbose File ~/code/lc/lckg/langchain/tools/base.py:71, in BaseTool._parse_input(self, tool_input) 69 if...
https://python.langchain.com/en/latest/modules/agents/tools/tool_input_validation.html
95c9087d413a-0
.ipynb .pdf Multi-Input Tools Contents Multi-Input Tools with a string format Multi-Input Tools# This notebook shows how to use a tool that requires multiple inputs with an agent. The recommended way to do so is with the StructuredTool class. import os os.environ["LANGCHAIN_TRACING"] = "true" from langchain import Op...
https://python.langchain.com/en/latest/modules/agents/tools/multi_input_tool.html
95c9087d413a-1
'3 times 4 is 12' Multi-Input Tools with a string format# An alternative to the structured tool would be to use the regular Tool class and accept a single string. The tool would then have to handle the parsing logic to extract the relavent values from the text, which tightly couples the tool representation to the agent...
https://python.langchain.com/en/latest/modules/agents/tools/multi_input_tool.html
95c9087d413a-2
> Entering new AgentExecutor chain... I need to multiply two numbers Action: Multiplier Action Input: 3,4 Observation: 12 Thought: I now know the final answer Final Answer: 3 times 4 is 12 > Finished chain. '3 times 4 is 12' previous Defining Custom Tools next Tool Input Schema Contents Multi-Input Tools with a st...
https://python.langchain.com/en/latest/modules/agents/tools/multi_input_tool.html
da43b64b50a5-0
.md .pdf Getting Started Contents List of Tools Getting Started# Tools are functions that agents can use to interact with the world. These tools can be generic utilities (e.g. search), other chains, or even other agents. Currently, tools can be loaded with the following snippet: from langchain.agents import load_tool...
https://python.langchain.com/en/latest/modules/agents/tools/getting_started.html
da43b64b50a5-1
Requires LLM: No wolfram-alpha Tool Name: Wolfram Alpha Tool Description: A wolfram alpha search engine. Useful for when you need to answer questions about Math, Science, Technology, Culture, Society and Everyday Life. Input should be a search query. Notes: Calls the Wolfram Alpha API and then parses results. Requires ...
https://python.langchain.com/en/latest/modules/agents/tools/getting_started.html
da43b64b50a5-2
Requires LLM: Yes open-meteo-api Tool Name: Open Meteo API Tool Description: Useful for when you want to get weather information from the OpenMeteo API. The input should be a question in natural language that this API can answer. Notes: A natural language connection to the Open Meteo API (https://api.open-meteo.com/), ...
https://python.langchain.com/en/latest/modules/agents/tools/getting_started.html
da43b64b50a5-3
For more information on this, see this page searx-search Tool Name: Search Tool Description: A wrapper around SearxNG meta search engine. Input should be a search query. Notes: SearxNG is easy to deploy self-hosted. It is a good privacy friendly alternative to Google Search. Uses the SearxNG API. Requires LLM: No Extra...
https://python.langchain.com/en/latest/modules/agents/tools/getting_started.html
da43b64b50a5-4
Notes: A connection to the OpenWeatherMap API (https://api.openweathermap.org), specifically the /data/2.5/weather endpoint. Requires LLM: No Extra Parameters: openweathermap_api_key (your API key to access this endpoint) previous Tools next Defining Custom Tools Contents List of Tools By Harrison Chase ...
https://python.langchain.com/en/latest/modules/agents/tools/getting_started.html
234e27880150-0
.ipynb .pdf Google Search Contents Number of Results Metadata Results Google Search# This notebook goes over how to use the google search component. First, you need to set up the proper API keys and environment variables. To set it up, create the GOOGLE_API_KEY in the Google Cloud credential console (https://console....
https://python.langchain.com/en/latest/modules/agents/tools/examples/google_search.html
234e27880150-1
"STATE OF HAWAII. 1 Child's First Name. (Type or print). 2. Sex. BARACK. 3. This Birth. CERTIFICATE OF LIVE BIRTH. FILE. NUMBER 151 le. lb. Middle Name. Barack Hussein Obama II is an American former politician who served as the 44th president of the United States from 2009 to 2017. A member of the Democratic\xa0... Whe...
https://python.langchain.com/en/latest/modules/agents/tools/examples/google_search.html
234e27880150-2
Number of Results# You can use the k parameter to set the number of results search = GoogleSearchAPIWrapper(k=1) tool = Tool( name = "I'm Feeling Lucky", description="Search Google and return the first result.", func=search.run ) tool.run("python") 'The official home of the Python Programming Language.' ‘Th...
https://python.langchain.com/en/latest/modules/agents/tools/examples/google_search.html
33ac2ec8cc39-0
.ipynb .pdf Metaphor Search Contents Metaphor Search Call the API Use Metaphor as a tool Metaphor Search# This notebook goes over how to use Metaphor search. First, you need to set up the proper API keys and environment variables. Request an API key [here](Sign up for early access here). Then enter your API key as an...
https://python.langchain.com/en/latest/modules/agents/tools/examples/metaphor_search.html
33ac2ec8cc39-1
{'results': [{'url': 'https://www.anthropic.com/index/core-views-on-ai-safety', 'title': 'Core Views on AI Safety: When, Why, What, and How', 'dateCreated': '2023-03-08', 'author': None, 'score': 0.1998831331729889}, {'url': 'https://aisafety.wordpress.com/', 'title': 'Extinction Risk from Artificial Intelligence', 'da...
https://python.langchain.com/en/latest/modules/agents/tools/examples/metaphor_search.html
33ac2ec8cc39-2
'title': 'Planning for AGI and beyond', 'dateCreated': '2023-02-24', 'author': 'Authors', 'score': 0.18665121495723724}, {'url': 'https://waitbutwhy.com/2015/01/artificial-intelligence-revolution-1.html', 'title': 'The Artificial Intelligence Revolution: Part 1 - Wait But Why', 'dateCreated': '2015-01-22', 'author': 'T...
https://python.langchain.com/en/latest/modules/agents/tools/examples/metaphor_search.html
33ac2ec8cc39-3
[{'title': 'Core Views on AI Safety: When, Why, What, and How', 'url': 'https://www.anthropic.com/index/core-views-on-ai-safety', 'author': None, 'date_created': '2023-03-08'}, {'title': 'Extinction Risk from Artificial Intelligence', 'url': 'https://aisafety.wordpress.com/', 'author': None, 'date_created'...
https://python.langchain.com/en/latest/modules/agents/tools/examples/metaphor_search.html
33ac2ec8cc39-4
'date_created': '2023-02-24'}, {'title': 'The Artificial Intelligence Revolution: Part 1 - Wait But Why', 'url': 'https://waitbutwhy.com/2015/01/artificial-intelligence-revolution-1.html', 'author': 'Tim Urban', 'date_created': '2015-01-22'}, {'title': 'Anthropic: Core Views on AI Safety: When, Why, What, and H...
https://python.langchain.com/en/latest/modules/agents/tools/examples/metaphor_search.html
33ac2ec8cc39-5
) async_browser = create_async_playwright_browser() toolkit = PlayWrightBrowserToolkit.from_browser(async_browser=async_browser) tools = toolkit.get_tools() tools_by_name = {tool.name: tool for tool in tools} print(tools_by_name.keys()) navigate_tool = tools_by_name["navigate_browser"] extract_text = tools_by_name["ext...
https://python.langchain.com/en/latest/modules/agents/tools/examples/metaphor_search.html
33ac2ec8cc39-6
Observation: [{'title': 'Center for AI Safety', 'url': 'https://safe.ai/', 'author': None, 'date_created': '2022-01-01'}] Thought:I need to navigate to the URL provided in the search results to find the tweet. > Finished chain. 'I need to navigate to the URL provided in the search results to find the tweet.' previous I...
https://python.langchain.com/en/latest/modules/agents/tools/examples/metaphor_search.html
92ba802e4182-0
.ipynb .pdf Human as a tool Contents Configuring the Input Function Human as a tool# Human are AGI so they can certainly be used as a tool to help out AI agent when it is confused. from langchain.chat_models import ChatOpenAI from langchain.llms import OpenAI from langchain.agents import load_tools, initialize_agent ...
https://python.langchain.com/en/latest/modules/agents/tools/examples/human_tools.html
92ba802e4182-1
def get_input() -> str: print("Insert your text. Enter 'q' or press Ctrl-D (or Ctrl-Z on Windows) to end.") contents = [] while True: try: line = input() except EOFError: break if line == "q": break contents.append(line) return "\n".joi...
https://python.langchain.com/en/latest/modules/agents/tools/examples/human_tools.html
92ba802e4182-2
oh who said it q Observation: oh who said it Thought:I can use DuckDuckGo Search to find out who said the quote Action: DuckDuckGo Search Action Input: "Who said 'Veni, vidi, vici'?"
https://python.langchain.com/en/latest/modules/agents/tools/examples/human_tools.html
92ba802e4182-3
Observation: Updated on September 06, 2019. "Veni, vidi, vici" is a famous phrase said to have been spoken by the Roman Emperor Julius Caesar (100-44 BCE) in a bit of stylish bragging that impressed many of the writers of his day and beyond. The phrase means roughly "I came, I saw, I conquered" and it could be pronounc...
https://python.langchain.com/en/latest/modules/agents/tools/examples/human_tools.html
92ba802e4182-4
simple, strong meaning: I'm powerful and fast. But it's not just the meaning that makes the phrase so powerful. Caesar was a gifted writer, and the phrase makes use of Latin grammar to ... One of the best known and most frequently quoted Latin expression, veni, vidi, vici may be found hundreds of times throughout the c...
https://python.langchain.com/en/latest/modules/agents/tools/examples/human_tools.html
92ba802e4182-5
Thought:I now know the final answer Final Answer: Julius Caesar said the quote "Veni, vidi, vici" which means "I came, I saw, I conquered". > Finished chain. 'Julius Caesar said the quote "Veni, vidi, vici" which means "I came, I saw, I conquered".' previous HuggingFace Tools next IFTTT WebHooks Contents Configurin...
https://python.langchain.com/en/latest/modules/agents/tools/examples/human_tools.html
899066a092fb-0
.ipynb .pdf Google Places Google Places# This notebook goes through how to use Google Places API #!pip install googlemaps import os os.environ["GPLACES_API_KEY"] = "" from langchain.tools import GooglePlacesTool places = GooglePlacesTool() places.run("al fornos") "1. Delfina Restaurant\nAddress: 3621 18th St, San Franc...
https://python.langchain.com/en/latest/modules/agents/tools/examples/google_places.html
71c38d720a58-0
.ipynb .pdf File System Tools Contents The FileManagementToolkit Selecting File System Tools File System Tools# LangChain provides tools for interacting with a local file system out of the box. This notebook walks through some of them. Note: these tools are not recommended for use outside a sandboxed environment! Fir...
https://python.langchain.com/en/latest/modules/agents/tools/examples/filesystem.html
71c38d720a58-1
toolkit.get_tools() [CopyFileTool(name='copy_file', description='Create a copy of a file in a specified location', args_schema=<class 'langchain.tools.file_management.copy.FileCopyInput'>, return_direct=False, verbose=False, callback_manager=<langchain.callbacks.shared.SharedCallbackManager object at 0x1156f4350>, root...
https://python.langchain.com/en/latest/modules/agents/tools/examples/filesystem.html
71c38d720a58-2
MoveFileTool(name='move_file', description='Move or rename a file from one location to another', args_schema=<class 'langchain.tools.file_management.move.FileMoveInput'>, return_direct=False, verbose=False, callback_manager=<langchain.callbacks.shared.SharedCallbackManager object at 0x1156f4350>, root_dir='/var/folders...
https://python.langchain.com/en/latest/modules/agents/tools/examples/filesystem.html
71c38d720a58-3
Selecting File System Tools# If you only want to select certain tools, you can pass them in as arguments when initializing the toolkit, or you can individually initialize the desired tools. tools = FileManagementToolkit(root_dir=str(working_directory.name), selected_tools=["read_file", "write_file", "list_directory"])....
https://python.langchain.com/en/latest/modules/agents/tools/examples/filesystem.html
71c38d720a58-4
write_tool.run({"file_path": "example.txt", "text": "Hello World!"}) 'File written successfully to example.txt.' # List files in the working directory list_tool.run({}) 'example.txt' previous DuckDuckGo Search next Google Places Contents The FileManagementToolkit Selecting File System Tools By Harrison Chase ...
https://python.langchain.com/en/latest/modules/agents/tools/examples/filesystem.html
b03ef1a1ff44-0
.ipynb .pdf HuggingFace Tools HuggingFace Tools# Huggingface Tools supporting text I/O can be loaded directly using the load_huggingface_tool function. # Requires transformers>=4.29.0 and huggingface_hub>=0.14.1 !pip install --upgrade transformers huggingface_hub > /dev/null from langchain.agents import load_huggingfac...
https://python.langchain.com/en/latest/modules/agents/tools/examples/huggingface_tools.html
f42c0eef3424-0
.ipynb .pdf YouTubeSearchTool YouTubeSearchTool# This notebook shows how to use a tool to search YouTube Adapted from venuv/langchain_yt_tools #! pip install youtube_search from langchain.tools import YouTubeSearchTool tool = YouTubeSearchTool() tool.run("lex friedman") "['/watch?v=VcVfceTsD0A&pp=ygUMbGV4IGZyaWVkbWFu',...
https://python.langchain.com/en/latest/modules/agents/tools/examples/youtube.html
b1e781275043-0
.ipynb .pdf AWS Lambda API AWS Lambda API# This notebook goes over how to use the AWS Lambda Tool component. AWS Lambda is a serverless computing service provided by Amazon Web Services (AWS), designed to allow developers to build and run applications and services without the need for provisioning or managing servers. ...
https://python.langchain.com/en/latest/modules/agents/tools/examples/awslambda.html
b1e781275043-1
agent.run("Send an email to test@testing123.com saying hello world.") previous ArXiv API Tool next Shell Tool By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/modules/agents/tools/examples/awslambda.html
d654fc60a2ac-0
.ipynb .pdf Bing Search Contents Number of results Metadata Results Bing Search# This notebook goes over how to use the bing search component. First, you need to set up the proper API keys and environment variables. To set it up, follow the instructions found here. Then we will need to set some environment variables....
https://python.langchain.com/en/latest/modules/agents/tools/examples/bing_search.html
d654fc60a2ac-1
'Thanks to the flexibility of <b>Python</b> and the powerful ecosystem of packages, the Azure CLI supports features such as autocompletion (in shells that support it), persistent credentials, JMESPath result parsing, lazy initialization, network-less unit tests, and more. Building an open-source and cross-platform Azur...
https://python.langchain.com/en/latest/modules/agents/tools/examples/bing_search.html
d654fc60a2ac-2
self-contained, so the tutorial can be read off-line as well. For a description of standard objects and modules, see The <b>Python</b> Standard ... <b>Python</b> is a general-purpose, versatile, and powerful programming language. It&#39;s a great first language because <b>Python</b> code is concise and easy to read. Wh...
https://python.langchain.com/en/latest/modules/agents/tools/examples/bing_search.html
d654fc60a2ac-3
Number of results# You can use the k parameter to set the number of results search = BingSearchAPIWrapper(k=1) search.run("python") 'Thanks to the flexibility of <b>Python</b> and the powerful ecosystem of packages, the Azure CLI supports features such as autocompletion (in shells that support it), persistent credentia...
https://python.langchain.com/en/latest/modules/agents/tools/examples/bing_search.html
d654fc60a2ac-4
{'snippet': '<b>Apples</b> boast many vitamins and minerals, though not in high amounts. However, <b>apples</b> are usually a good source of vitamin C. Vitamin C. Also called ascorbic acid, this vitamin is a common ...', 'title': 'Apples 101: Nutrition Facts and Health Benefits', 'link': 'https://www.healthline.com...
https://python.langchain.com/en/latest/modules/agents/tools/examples/bing_search.html
d3109ed92431-0
.ipynb .pdf OpenWeatherMap API Contents Use the wrapper Use the tool OpenWeatherMap API# This notebook goes over how to use the OpenWeatherMap component to fetch weather information. First, you need to sign up for an OpenWeatherMap API key: Go to OpenWeatherMap and sign up for an API key here pip install pyowm Then w...
https://python.langchain.com/en/latest/modules/agents/tools/examples/openweathermap.html
d3109ed92431-1
agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True ) agent_chain.run("What's the weather like in London?") > Entering new AgentExecutor chain... I need to find out the current weather in London. Action: OpenWeatherMap Action Input: London,GB Observation: In London,GB, the current weather is as follows: Deta...
https://python.langchain.com/en/latest/modules/agents/tools/examples/openweathermap.html
ada135c29afc-0
.ipynb .pdf DuckDuckGo Search DuckDuckGo Search# This notebook goes over how to use the duck-duck-go search component. # !pip install duckduckgo-search from langchain.tools import DuckDuckGoSearchRun search = DuckDuckGoSearchRun() search.run("Obama's first name?")
https://python.langchain.com/en/latest/modules/agents/tools/examples/ddg.html