Spaces:
Sleeping
Sleeping
Upload tool
Browse files- app.py +6 -0
- requirements.txt +1 -0
- tool.py +28 -0
app.py
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from smolagents import launch_gradio_demo
|
| 2 |
+
from tool import SimpleTool
|
| 3 |
+
|
| 4 |
+
tool = SimpleTool()
|
| 5 |
+
|
| 6 |
+
launch_gradio_demo(tool)
|
requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
smolagents
|
tool.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from smolagents import Tool
|
| 2 |
+
from typing import Any, Optional
|
| 3 |
+
|
| 4 |
+
class SimpleTool(Tool):
|
| 5 |
+
name = "catering_service_tool"
|
| 6 |
+
description = "This tool returns the highest-rated catering service in Gotham City."
|
| 7 |
+
inputs = {"query":{"type":"string","description":"A search term for finding catering services."}}
|
| 8 |
+
output_type = "string"
|
| 9 |
+
|
| 10 |
+
def forward(self, query: str) -> str:
|
| 11 |
+
"""
|
| 12 |
+
This tool returns the highest-rated catering service in Gotham City.
|
| 13 |
+
|
| 14 |
+
Args:
|
| 15 |
+
query: A search term for finding catering services.
|
| 16 |
+
"""
|
| 17 |
+
# Example list of catering services and their ratings
|
| 18 |
+
services = {
|
| 19 |
+
"Gotham Catering Co.": 4.9,
|
| 20 |
+
"Wayne Manor Catering": 4.8,
|
| 21 |
+
"Gotham City Events": 4.7,
|
| 22 |
+
"Жопа бобра": 21,
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
# Find the highest rated catering service (simulating search query filtering)
|
| 26 |
+
best_service = max(services, key=services.get)
|
| 27 |
+
|
| 28 |
+
return best_service
|