Luigi D'Addona
aggiunto file tools.py dove vengono definiti i tools messi a disposizione dell'agent
efb1996
raw
history blame
724 Bytes
# DuckDuckGo
from langchain_community.tools import DuckDuckGoSearchRun
# Wikipedia tool components
from langchain_community.utilities import WikipediaAPIWrapper
from langchain_community.tools import WikipediaQueryRun
from langchain.tools import Tool
def get_search_tool():
search_tool = DuckDuckGoSearchRun()
return search_tool
def get_wikipedia_tool():
# creates an instance of the Wikipedia API wrapper. top_k_results=1 means it will only fetch the top result from Wikipedia
wikipedia_api_wrapper = WikipediaAPIWrapper(top_k_results=1)
# converts the WikipediaAPIWrapper into a LangChain tool.
wikipedia_tool = WikipediaQueryRun(api_wrapper=wikipedia_api_wrapper)
return wikipedia_tool