Update tools.py
Browse files
tools.py
CHANGED
|
@@ -1,14 +1,16 @@
|
|
| 1 |
-
|
| 2 |
-
from
|
| 3 |
-
from langchain_community.tools import DuckDuckGoSearchRun
|
| 4 |
-
from langchain.tools import tool
|
| 5 |
import math
|
|
|
|
| 6 |
|
| 7 |
-
# Tool 1: Web Search
|
| 8 |
-
search =
|
|
|
|
|
|
|
|
|
|
| 9 |
search_tool = Tool(
|
| 10 |
name="web_search",
|
| 11 |
-
func=search.
|
| 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 |
|