hibam1 commited on
Commit ·
2bc2afe
1
Parent(s): 066fbc2
add class tool SuperheroPartyThemeTool
Browse files- app.py +11 -1
- superhero_party_theme_tool.py +24 -0
app.py
CHANGED
|
@@ -3,6 +3,7 @@ import os
|
|
| 3 |
from dotenv import load_dotenv
|
| 4 |
from smolagents import CodeAgent, DuckDuckGoSearchTool, LiteLLMModel, OpenAIServerModel, tool
|
| 5 |
import datetime
|
|
|
|
| 6 |
|
| 7 |
load_dotenv() # reads MODEL_PROVIDER and OPENAI_API_KEY from .env
|
| 8 |
|
|
@@ -61,7 +62,7 @@ def main_v1() -> None:
|
|
| 61 |
menu_agent = CodeAgent(tools=[suggest_menu], model=model)
|
| 62 |
menu_agent.run("Prepare a formal menu for the party.")
|
| 63 |
|
| 64 |
-
def
|
| 65 |
agent = CodeAgent(tools=[], model=model, additional_authorized_imports=['datetime'])
|
| 66 |
|
| 67 |
agent.run(
|
|
@@ -76,6 +77,15 @@ def main() -> None:
|
|
| 76 |
"""
|
| 77 |
)
|
| 78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
|
| 80 |
if __name__ == "__main__":
|
| 81 |
main()
|
|
|
|
| 3 |
from dotenv import load_dotenv
|
| 4 |
from smolagents import CodeAgent, DuckDuckGoSearchTool, LiteLLMModel, OpenAIServerModel, tool
|
| 5 |
import datetime
|
| 6 |
+
from superhero_party_theme_tool import SuperheroPartyThemeTool
|
| 7 |
|
| 8 |
load_dotenv() # reads MODEL_PROVIDER and OPENAI_API_KEY from .env
|
| 9 |
|
|
|
|
| 62 |
menu_agent = CodeAgent(tools=[suggest_menu], model=model)
|
| 63 |
menu_agent.run("Prepare a formal menu for the party.")
|
| 64 |
|
| 65 |
+
def main_v2() -> None:
|
| 66 |
agent = CodeAgent(tools=[], model=model, additional_authorized_imports=['datetime'])
|
| 67 |
|
| 68 |
agent.run(
|
|
|
|
| 77 |
"""
|
| 78 |
)
|
| 79 |
|
| 80 |
+
def main() -> None:
|
| 81 |
+
agent = CodeAgent(tools=[SuperheroPartyThemeTool()], model=model)
|
| 82 |
+
|
| 83 |
+
agent.run(
|
| 84 |
+
"""
|
| 85 |
+
whats the theme for classic heroes party
|
| 86 |
+
"""
|
| 87 |
+
)
|
| 88 |
+
|
| 89 |
|
| 90 |
if __name__ == "__main__":
|
| 91 |
main()
|
superhero_party_theme_tool.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from smolagents import Tool
|
| 2 |
+
import random
|
| 3 |
+
|
| 4 |
+
class SuperheroPartyThemeTool(Tool):
|
| 5 |
+
name = "superhero_party_theme"
|
| 6 |
+
description = "Extract the party category it can be classic heroes, villain masquerade, futuristic Gotham and return the theme"
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
inputs = {
|
| 10 |
+
"category": {
|
| 11 |
+
"type": "string",
|
| 12 |
+
"description": "The type of superhero party (e.g., 'classic heroes', 'villain masquerade', 'futuristic Gotham').",
|
| 13 |
+
}
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
output_type = "string"
|
| 17 |
+
|
| 18 |
+
def forward(self, category: str) -> str:
|
| 19 |
+
themes = {
|
| 20 |
+
"classic heroes": "Superman, Batman, Wonder Woman, The Flash, Aquaman, Cyborg, Green Lantern",
|
| 21 |
+
"villain masquerade": "Joker, Lex Luthor, Catwoman, The Riddler, The Penguin, The Joker, The Riddler",
|
| 22 |
+
"futuristic Gotham": "Batman, Catwoman, The Joker, The Riddler, The Penguin, The Batman, The Catwoman, The Joker, The Riddler, The Penguin",
|
| 23 |
+
}
|
| 24 |
+
return themes.get(category.lower(), "Themed party idea not found. Try 'classic heroes', 'villain masquerade', or 'futuristic Gotham'.")
|