antonioschiro commited on
Commit
319a6d6
·
verified ·
1 Parent(s): bf4d9ee

Update tools.py

Browse files
Files changed (1) hide show
  1. tools.py +2 -3
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
- async def websearch(query: str) -> str:
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 = await search_engine.ainvoke(query)
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}."