Ayushi4 commited on
Commit
f7331ad
·
verified ·
1 Parent(s): 376f33e

Update tools.py

Browse files
Files changed (1) hide show
  1. tools.py +9 -7
tools.py CHANGED
@@ -1,14 +1,16 @@
1
-
2
- from langchain.tools import Tool
3
- from langchain_community.tools import DuckDuckGoSearchRun
4
- from langchain.tools import tool
5
  import math
 
6
 
7
- # Tool 1: Web Search
8
- search = DuckDuckGoSearchRun()
 
 
 
9
  search_tool = Tool(
10
  name="web_search",
11
- func=search.run,
12
  description="Useful for searching the internet for current events, facts, or any real-time information. Input should be a search query."
13
  )
14
 
 
1
+ from langchain.tools import Tool, tool
2
+ from langchain_community.tools.tavily_search import TavilySearchResults
 
 
3
  import math
4
+ import os
5
 
6
+ # Tool 1: Web Search (Tavily)
7
+ search = TavilySearchResults(
8
+ tavily_api_key=os.getenv("TAVILY_API_KEY"),
9
+ max_results=3
10
+ )
11
  search_tool = Tool(
12
  name="web_search",
13
+ func=lambda q: str(search.invoke(q)),
14
  description="Useful for searching the internet for current events, facts, or any real-time information. Input should be a search query."
15
  )
16