NikitaKras commited on
Commit
19f14e1
·
verified ·
1 Parent(s): 8c5c24b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -1
app.py CHANGED
@@ -18,6 +18,32 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
18
  """
19
  return "What magic will you build ?"
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  @tool
22
  def get_current_time_in_timezone(timezone: str) -> str:
23
  """A tool that fetches the current local time in a specified timezone.
@@ -55,7 +81,7 @@ with open("prompts.yaml", 'r') as stream:
55
 
56
  agent = CodeAgent(
57
  model=model,
58
- tools=[final_answer], ## add your tools here (don't remove final answer)
59
  max_steps=6,
60
  verbosity_level=1,
61
  grammar=None,
 
18
  """
19
  return "What magic will you build ?"
20
 
21
+ @tool
22
+ def get_huggingface_model_info(model_id: str) -> str:
23
+ """Fetches information about a model from the Hugging Face Hub.
24
+ Args:
25
+ model_id: The model identifier (e.g., 'meta-llama/Llama-2-7b' or 'bert-base-uncased').
26
+ """
27
+ try:
28
+ url = f"https://huggingface.co/api/models/{model_id}"
29
+ response = requests.get(url, timeout=10)
30
+ if response.status_code == 404:
31
+ return f"Model '{model_id}' not found on Hugging Face Hub."
32
+ response.raise_for_status()
33
+ data = response.json()
34
+ downloads = data.get('downloads')
35
+
36
+ info = f"**{data.get('id', model_id)}**\n"
37
+ info += f"- Downloads: {downloads:,}\n" if downloads else "- Downloads: N/A\n"
38
+ info += f"- Likes: {data.get('likes', 'N/A')}\n"
39
+ info += f"- Pipeline: {data.get('pipeline_tag', 'N/A')}\n"
40
+ info += f"- Library: {data.get('library_name', 'N/A')}\n"
41
+ if data.get('tags'):
42
+ info += f"- Tags: {', '.join(data['tags'][:5])}\n"
43
+ return info
44
+ except Exception as e:
45
+ return f"Error fetching model info: {str(e)}"
46
+
47
  @tool
48
  def get_current_time_in_timezone(timezone: str) -> str:
49
  """A tool that fetches the current local time in a specified timezone.
 
81
 
82
  agent = CodeAgent(
83
  model=model,
84
+ tools=[final_answer, get_huggingface_model_info, get_current_time_in_timezone, image_generation_tool], ## add your tools here (don't remove final answer)
85
  max_steps=6,
86
  verbosity_level=1,
87
  grammar=None,