Spaces:
Sleeping
Sleeping
Luigi D'Addona
commited on
Commit
·
efb1996
1
Parent(s):
7a786af
aggiunto file tools.py dove vengono definiti i tools messi a disposizione dell'agent
Browse files
tools.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# DuckDuckGo
|
| 2 |
+
from langchain_community.tools import DuckDuckGoSearchRun
|
| 3 |
+
# Wikipedia tool components
|
| 4 |
+
from langchain_community.utilities import WikipediaAPIWrapper
|
| 5 |
+
from langchain_community.tools import WikipediaQueryRun
|
| 6 |
+
|
| 7 |
+
from langchain.tools import Tool
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def get_search_tool():
|
| 11 |
+
|
| 12 |
+
search_tool = DuckDuckGoSearchRun()
|
| 13 |
+
|
| 14 |
+
return search_tool
|
| 15 |
+
|
| 16 |
+
def get_wikipedia_tool():
|
| 17 |
+
|
| 18 |
+
# creates an instance of the Wikipedia API wrapper. top_k_results=1 means it will only fetch the top result from Wikipedia
|
| 19 |
+
wikipedia_api_wrapper = WikipediaAPIWrapper(top_k_results=1)
|
| 20 |
+
|
| 21 |
+
# converts the WikipediaAPIWrapper into a LangChain tool.
|
| 22 |
+
wikipedia_tool = WikipediaQueryRun(api_wrapper=wikipedia_api_wrapper)
|
| 23 |
+
|
| 24 |
+
return wikipedia_tool
|