Update tools.py
Browse files
tools.py
CHANGED
@@ -1,30 +1,35 @@
|
|
1 |
# Tool Section
|
2 |
|
3 |
-
from langchain_community.tools import DuckDuckGoSearchRun
|
4 |
from langchain.tools import Tool
|
5 |
from huggingface_hub import list_models
|
6 |
-
import
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
-
# Initialize the tool
|
24 |
weather_info_tool = Tool(
|
25 |
name="get_weather_info",
|
26 |
func=get_weather_info,
|
27 |
-
description="Fetches
|
28 |
)
|
29 |
|
30 |
def get_hub_stats(author: str) -> str:
|
|
|
1 |
# Tool Section
|
2 |
|
|
|
3 |
from langchain.tools import Tool
|
4 |
from huggingface_hub import list_models
|
5 |
+
import requests
|
6 |
+
import os
|
7 |
+
from tavily import TavilyClient
|
8 |
+
|
9 |
+
def internet_search_tool(query: str) -> str:
|
10 |
+
"""Fetches information, news, etc from internet."""
|
11 |
+
client = TavilyClient(os.getenv("TAVILY_API_KEY"))
|
12 |
+
response = client.search(query=query)
|
13 |
+
return response
|
14 |
+
|
15 |
+
search_tool = Tool(
|
16 |
+
name="internet_search_tool",
|
17 |
+
func=internet_search_tool,
|
18 |
+
description="Fetches information, news, etc from internet."
|
19 |
+
)
|
20 |
+
|
21 |
+
def get_weather_info(city: str) -> str:
|
22 |
+
"""Fetches the current weather information of specific city."""
|
23 |
+
weather_api = "http://api.weatherapi.com/v1/current.json?q={city}".format(city=city)
|
24 |
+
weather_api_response = requests.get(weather_api, headers={"key":os.getenv("WEATHER_API_KEY")})
|
25 |
+
if weather_api_response.status_code == 200:
|
26 |
+
return weather_api_response.text
|
27 |
+
return "Problem at moment with API requests, please try after some time"
|
28 |
|
|
|
29 |
weather_info_tool = Tool(
|
30 |
name="get_weather_info",
|
31 |
func=get_weather_info,
|
32 |
+
description="Fetches the current weather information of specific city."
|
33 |
)
|
34 |
|
35 |
def get_hub_stats(author: str) -> str:
|