Update tools.py
Browse files
tools.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
from langchain_core.tools import tool
|
| 2 |
from langchain_community.tools import DuckDuckGoSearchRun
|
| 3 |
#from langchain_tavily import TavilySearch
|
| 4 |
-
import asyncio
|
| 5 |
import os
|
| 6 |
#from dotenv import load_dotenv
|
| 7 |
#load_dotenv()
|
|
@@ -9,7 +8,7 @@ import os
|
|
| 9 |
os.environ["TAVILY_API_KEY"] = os.getenv("TAVILY_API_KEY")
|
| 10 |
|
| 11 |
@tool
|
| 12 |
-
|
| 13 |
"""
|
| 14 |
Perform a web search using DuckDuckGo.
|
| 15 |
|
|
@@ -22,7 +21,7 @@ async def websearch(query: str) -> str:
|
|
| 22 |
"""
|
| 23 |
search_engine = DuckDuckGoSearchRun()
|
| 24 |
try:
|
| 25 |
-
response =
|
| 26 |
return response
|
| 27 |
except:
|
| 28 |
return f"No results found on the web for this query: {query}."
|
|
|
|
| 1 |
from langchain_core.tools import tool
|
| 2 |
from langchain_community.tools import DuckDuckGoSearchRun
|
| 3 |
#from langchain_tavily import TavilySearch
|
|
|
|
| 4 |
import os
|
| 5 |
#from dotenv import load_dotenv
|
| 6 |
#load_dotenv()
|
|
|
|
| 8 |
os.environ["TAVILY_API_KEY"] = os.getenv("TAVILY_API_KEY")
|
| 9 |
|
| 10 |
@tool
|
| 11 |
+
def websearch(query: str) -> str:
|
| 12 |
"""
|
| 13 |
Perform a web search using DuckDuckGo.
|
| 14 |
|
|
|
|
| 21 |
"""
|
| 22 |
search_engine = DuckDuckGoSearchRun()
|
| 23 |
try:
|
| 24 |
+
response = search_engine.invoke(query)
|
| 25 |
return response
|
| 26 |
except:
|
| 27 |
return f"No results found on the web for this query: {query}."
|