rakesh-dvg commited on
Commit
6bbc64f
·
verified ·
1 Parent(s): 609a8af

Update tools.py

Browse files
Files changed (1) hide show
  1. tools.py +5 -2
tools.py CHANGED
@@ -1,12 +1,12 @@
1
  from langchain.tools import Tool
2
- from langchain_community.tools.tavily_search import TavilySearch
3
  from huggingface_hub import list_models
4
  import random
5
  import os
6
 
7
- # Directly get from environment variables, no dotenv needed since HF Secrets are set
8
  search_tool = TavilySearch(tavily_api_key=os.getenv("TAVILY_API_KEY"))
9
 
 
10
  def get_weather_info(location: str) -> str:
11
  weather_conditions = [
12
  {"condition": "Rainy", "temp_c": 15},
@@ -16,12 +16,14 @@ def get_weather_info(location: str) -> str:
16
  data = random.choice(weather_conditions)
17
  return f"Weather in {location}: {data['condition']}, {data['temp_c']}°C"
18
 
 
19
  weather_info_tool = Tool(
20
  name="get_weather_info",
21
  func=get_weather_info,
22
  description="Returns dummy weather information for a given location."
23
  )
24
 
 
25
  def get_hub_stats(author: str) -> str:
26
  try:
27
  models = list(list_models(author=author, sort="downloads", direction=-1, limit=1))
@@ -33,6 +35,7 @@ def get_hub_stats(author: str) -> str:
33
  except Exception as e:
34
  return f"Error: {str(e)}"
35
 
 
36
  hub_stats_tool = Tool(
37
  name="get_hub_stats",
38
  func=get_hub_stats,
 
1
  from langchain.tools import Tool
2
+ from langchain_tavily import TavilySearch
3
  from huggingface_hub import list_models
4
  import random
5
  import os
6
 
 
7
  search_tool = TavilySearch(tavily_api_key=os.getenv("TAVILY_API_KEY"))
8
 
9
+
10
  def get_weather_info(location: str) -> str:
11
  weather_conditions = [
12
  {"condition": "Rainy", "temp_c": 15},
 
16
  data = random.choice(weather_conditions)
17
  return f"Weather in {location}: {data['condition']}, {data['temp_c']}°C"
18
 
19
+
20
  weather_info_tool = Tool(
21
  name="get_weather_info",
22
  func=get_weather_info,
23
  description="Returns dummy weather information for a given location."
24
  )
25
 
26
+
27
  def get_hub_stats(author: str) -> str:
28
  try:
29
  models = list(list_models(author=author, sort="downloads", direction=-1, limit=1))
 
35
  except Exception as e:
36
  return f"Error: {str(e)}"
37
 
38
+
39
  hub_stats_tool = Tool(
40
  name="get_hub_stats",
41
  func=get_hub_stats,