app.py
#179
by Mattesss - opened
app.py
CHANGED
|
@@ -9,14 +9,38 @@ from Gradio_UI import GradioUI
|
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
@tool
|
| 12 |
-
def
|
| 13 |
-
|
| 14 |
-
|
| 15 |
Args:
|
| 16 |
-
|
| 17 |
-
|
|
|
|
| 18 |
"""
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
@tool
|
| 22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
@tool
|
| 12 |
+
def search_hf_models(query: str, task: str = None) -> str:
|
| 13 |
+
"""
|
| 14 |
+
Vyhledává modely na Hugging Face podle klíčových slov nebo typu úlohy.
|
| 15 |
Args:
|
| 16 |
+
query: Hledaná fráze (např. 'text classification')
|
| 17 |
+
task: Filtr podle typu úlohy (např. 'text-classification')
|
| 18 |
+
Vrací formátované informace o modelech včetně odkazů
|
| 19 |
"""
|
| 20 |
+
try:
|
| 21 |
+
params = {"search": query, "filter": task} if task else {"search": query}
|
| 22 |
+
response = requests.get(
|
| 23 |
+
"https://huggingface.co/api/models",
|
| 24 |
+
params=params,
|
| 25 |
+
headers={"Accept": "application/json"}
|
| 26 |
+
)
|
| 27 |
+
response.raise_for_status()
|
| 28 |
+
|
| 29 |
+
results = []
|
| 30 |
+
for model in response.json()[:5]: # Top 5 výsledků
|
| 31 |
+
model_info = f"""
|
| 32 |
+
🧠 **{model['modelId']}**
|
| 33 |
+
- Autor: {model['author']}
|
| 34 |
+
- Stažení: {model['downloads']:,}
|
| 35 |
+
- Úlohy: {', '.join(model.get('tags', []))}
|
| 36 |
+
- Odkaz: https://huggingface.co/{model['modelId']}
|
| 37 |
+
"""
|
| 38 |
+
results.append(model_info)
|
| 39 |
+
|
| 40 |
+
return "\n\n".join(results) if results else "Nenalezeny žádné modely"
|
| 41 |
+
|
| 42 |
+
except Exception as e:
|
| 43 |
+
return f"Chyba při vyhledávání: {str(e)}"
|
| 44 |
|
| 45 |
@tool
|
| 46 |
def get_current_time_in_timezone(timezone: str) -> str:
|