Upload tool
Browse files- app.py +6 -0
- requirements.txt +1 -0
- tool.py +24 -0
app.py
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from smolagents import launch_gradio_demo
|
| 2 |
+
from tool import SuperheroPartyThemeTool
|
| 3 |
+
|
| 4 |
+
tool = SuperheroPartyThemeTool()
|
| 5 |
+
|
| 6 |
+
launch_gradio_demo(tool)
|
requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
smolagents
|
tool.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Any, Optional
|
| 2 |
+
from smolagents.tools import Tool
|
| 3 |
+
|
| 4 |
+
class SuperheroPartyThemeTool(Tool):
|
| 5 |
+
name = "superhero_party_theme_generator"
|
| 6 |
+
description = """
|
| 7 |
+
This tool suggests creative superhero-themed party ideas based on a category.
|
| 8 |
+
It returns a unique party theme idea."""
|
| 9 |
+
inputs = {'category': {'type': 'string', 'description': "The type of superhero party (e.g., 'classic heroes', 'villain masquerade', 'futuristic Gotham')."}}
|
| 10 |
+
output_type = "string"
|
| 11 |
+
|
| 12 |
+
def forward(self, category: str):
|
| 13 |
+
# 创建不同类别派对主题的字典
|
| 14 |
+
themes = {
|
| 15 |
+
"classic heroes": "Justice League Gala: Guests come dressed as their favorite DC heroes with themed cocktails like 'The Kryptonite Punch'.",
|
| 16 |
+
"villain masquerade": "Gotham Rogues' Ball: A mysterious masquerade where guests dress as classic Batman villains.",
|
| 17 |
+
"futuristic Gotham": "Neo-Gotham Night: A cyberpunk-style party inspired by Batman Beyond, with neon decorations and futuristic gadgets."
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
# 返回对应类别的主题,如果找不到则返回提示信息
|
| 21 |
+
return themes.get(category.lower(), "Themed party idea not found. Try 'classic heroes', 'villain masquerade', or 'futuristic Gotham'.")
|
| 22 |
+
|
| 23 |
+
def __init__(self, *args, **kwargs):
|
| 24 |
+
self.is_initialized = False
|