Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -33,6 +33,39 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 33 |
except Exception as e:
|
| 34 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
final_answer = FinalAnswerTool()
|
| 38 |
|
|
@@ -55,7 +88,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,
|
|
|
|
| 33 |
except Exception as e:
|
| 34 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 35 |
|
| 36 |
+
@tool
|
| 37 |
+
def check_hf_model(model_name: str) -> str:
|
| 38 |
+
"""A tool that checks if a Hugging Face model is available and gets basic information.
|
| 39 |
+
|
| 40 |
+
Args:
|
| 41 |
+
model_name: The name of the model on Hugging Face (e.g., 'google/bert-base-uncased')
|
| 42 |
+
"""
|
| 43 |
+
try:
|
| 44 |
+
# Construct the HF API URL
|
| 45 |
+
api_url = f"https://huggingface.co/api/models/{model_name}"
|
| 46 |
+
|
| 47 |
+
# Make the request
|
| 48 |
+
response = requests.get(api_url)
|
| 49 |
+
|
| 50 |
+
if response.status_code == 200:
|
| 51 |
+
data = response.json()
|
| 52 |
+
|
| 53 |
+
# Extract useful information
|
| 54 |
+
pipeline_tag = data.get('pipeline_tag', 'Not specified')
|
| 55 |
+
downloads = data.get('downloads', 'Not available')
|
| 56 |
+
likes = data.get('likes', 'Not available')
|
| 57 |
+
|
| 58 |
+
return f"""Model '{model_name}' is available:
|
| 59 |
+
- Task: {pipeline_tag}
|
| 60 |
+
- Downloads: {downloads}
|
| 61 |
+
- Likes: {likes}
|
| 62 |
+
- URL: https://huggingface.co/{model_name}"""
|
| 63 |
+
else:
|
| 64 |
+
return f"Model '{model_name}' not found or not accessible."
|
| 65 |
+
|
| 66 |
+
except Exception as e:
|
| 67 |
+
return f"Error checking model '{model_name}': {str(e)}"
|
| 68 |
+
|
| 69 |
|
| 70 |
final_answer = FinalAnswerTool()
|
| 71 |
|
|
|
|
| 88 |
|
| 89 |
agent = CodeAgent(
|
| 90 |
model=model,
|
| 91 |
+
tools=[final_answer,check_hf_model], ## add your tools here (don't remove final answer)
|
| 92 |
max_steps=6,
|
| 93 |
verbosity_level=1,
|
| 94 |
grammar=None,
|