Spaces:
Sleeping
Sleeping
Upload agent
Browse files- agent.json +1 -0
- app.py +3 -1
- tools/suggest_menu.py +27 -0
agent.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
{
|
| 2 |
"class": "CodeAgent",
|
| 3 |
"tools": [
|
|
|
|
| 4 |
"final_answer"
|
| 5 |
],
|
| 6 |
"model": {
|
|
|
|
| 1 |
{
|
| 2 |
"class": "CodeAgent",
|
| 3 |
"tools": [
|
| 4 |
+
"suggest_menu",
|
| 5 |
"final_answer"
|
| 6 |
],
|
| 7 |
"model": {
|
app.py
CHANGED
|
@@ -5,6 +5,7 @@ from smolagents import GradioUI, CodeAgent, InferenceClientModel
|
|
| 5 |
# Get current directory path
|
| 6 |
CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
|
| 7 |
|
|
|
|
| 8 |
from tools.final_answer import FinalAnswerTool as FinalAnswer
|
| 9 |
|
| 10 |
|
|
@@ -13,6 +14,7 @@ model = InferenceClientModel(
|
|
| 13 |
model_id='Qwen/Qwen2.5-Coder-32B-Instruct',
|
| 14 |
)
|
| 15 |
|
|
|
|
| 16 |
final_answer = FinalAnswer()
|
| 17 |
|
| 18 |
|
|
@@ -21,7 +23,7 @@ with open(os.path.join(CURRENT_DIR, "prompts.yaml"), 'r') as stream:
|
|
| 21 |
|
| 22 |
agent = CodeAgent(
|
| 23 |
model=model,
|
| 24 |
-
tools=[],
|
| 25 |
managed_agents=[],
|
| 26 |
max_steps=20,
|
| 27 |
verbosity_level=1,
|
|
|
|
| 5 |
# Get current directory path
|
| 6 |
CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
|
| 7 |
|
| 8 |
+
from tools.suggest_menu import SimpleTool as SuggestMenu
|
| 9 |
from tools.final_answer import FinalAnswerTool as FinalAnswer
|
| 10 |
|
| 11 |
|
|
|
|
| 14 |
model_id='Qwen/Qwen2.5-Coder-32B-Instruct',
|
| 15 |
)
|
| 16 |
|
| 17 |
+
suggest_menu = SuggestMenu()
|
| 18 |
final_answer = FinalAnswer()
|
| 19 |
|
| 20 |
|
|
|
|
| 23 |
|
| 24 |
agent = CodeAgent(
|
| 25 |
model=model,
|
| 26 |
+
tools=[suggest_menu],
|
| 27 |
managed_agents=[],
|
| 28 |
max_steps=20,
|
| 29 |
verbosity_level=1,
|
tools/suggest_menu.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from smolagents import Tool
|
| 2 |
+
from typing import Any, Optional
|
| 3 |
+
|
| 4 |
+
class SimpleTool(Tool):
|
| 5 |
+
name = "suggest_menu"
|
| 6 |
+
description = "Suggests a menu based on the occasion."
|
| 7 |
+
inputs = {'occasion': {'type': 'string', 'description': 'The type of occasion for the party. Allowed values are: - "casual": Menu for casual party. - "formal": Menu for formal party. - "superhero": Menu for superhero party. - "custom": Custom menu.'}}
|
| 8 |
+
output_type = "string"
|
| 9 |
+
|
| 10 |
+
def forward(self, occasion: str) -> str:
|
| 11 |
+
"""
|
| 12 |
+
Suggests a menu based on the occasion.
|
| 13 |
+
Args:
|
| 14 |
+
occasion (str): The type of occasion for the party. Allowed values are:
|
| 15 |
+
- "casual": Menu for casual party.
|
| 16 |
+
- "formal": Menu for formal party.
|
| 17 |
+
- "superhero": Menu for superhero party.
|
| 18 |
+
- "custom": Custom menu.
|
| 19 |
+
"""
|
| 20 |
+
if occasion == "casual":
|
| 21 |
+
return "Pizza, snacks, and drinks."
|
| 22 |
+
elif occasion == "formal":
|
| 23 |
+
return "3-course dinner with wine and dessert."
|
| 24 |
+
elif occasion == "superhero":
|
| 25 |
+
return "Buffet with high-energy and healthy food."
|
| 26 |
+
else:
|
| 27 |
+
return "Custom menu for the butler."
|