update tools.py
Browse files
tools.py
CHANGED
|
@@ -1,21 +1,22 @@
|
|
| 1 |
|
| 2 |
|
| 3 |
-
from langchain_community.tools import WikipediaQueryRun, ArxivQueryRun
|
| 4 |
-
from langchain_community.utilities import WikipediaAPIWrapper,ArxivAPIWrapper
|
| 5 |
-
|
| 6 |
from langchain_core.tools import tool
|
| 7 |
from datetime import datetime
|
| 8 |
-
|
| 9 |
def wikipedia_tool() -> WikipediaQueryRun:
|
| 10 |
"""best search for biography, facts and history"""
|
| 11 |
return WikipediaQueryRun(
|
| 12 |
-
api_wrapper=WikipediaAPIWrapper(doc_content_chars_max= 4000)
|
| 13 |
)
|
| 14 |
-
|
| 15 |
-
def
|
| 16 |
-
"""
|
| 17 |
-
|
| 18 |
-
|
|
|
|
| 19 |
def arxiv_tool() -> ArxivQueryRun:
|
| 20 |
"""returns scientific and research papers"""
|
| 21 |
return ArxivQueryRun(
|
|
@@ -26,3 +27,5 @@ def arxiv_tool() -> ArxivQueryRun:
|
|
| 26 |
def get_current_year() -> str:
|
| 27 |
"""returns the current year"""
|
| 28 |
return str(datetime.now().year)
|
|
|
|
|
|
|
|
|
| 1 |
|
| 2 |
|
| 3 |
+
from langchain_community.tools import WikipediaQueryRun, ArxivQueryRun, DuckDuckGoSearchRun
|
| 4 |
+
from langchain_community.utilities import WikipediaAPIWrapper, ArxivAPIWrapper, DuckDuckGoSearchAPIWrapper
|
| 5 |
+
|
| 6 |
from langchain_core.tools import tool
|
| 7 |
from datetime import datetime
|
| 8 |
+
@tool
|
| 9 |
def wikipedia_tool() -> WikipediaQueryRun:
|
| 10 |
"""best search for biography, facts and history"""
|
| 11 |
return WikipediaQueryRun(
|
| 12 |
+
api_wrapper=WikipediaAPIWrapper(top_k_results=2, doc_content_chars_max= 4000)
|
| 13 |
)
|
| 14 |
+
@tool
|
| 15 |
+
def ddg_search_tool() -> DuckDuckGoSearchRun:
|
| 16 |
+
"""DuckDuckGo search"""
|
| 17 |
+
wrapper = DuckDuckGoSearchAPIWrapper(max_results=5)
|
| 18 |
+
return DuckDuckGoSearchRun(api_wrapper=wrapper)
|
| 19 |
+
@tool
|
| 20 |
def arxiv_tool() -> ArxivQueryRun:
|
| 21 |
"""returns scientific and research papers"""
|
| 22 |
return ArxivQueryRun(
|
|
|
|
| 27 |
def get_current_year() -> str:
|
| 28 |
"""returns the current year"""
|
| 29 |
return str(datetime.now().year)
|
| 30 |
+
|
| 31 |
+
|