Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
from smolagents import CodeAgent, InferenceClientModel
|
| 2 |
from tools.party_menu import suggest_menu
|
| 3 |
from tools.party_song import suggest_party_music
|
|
@@ -11,6 +12,18 @@ agent = CodeAgent(
|
|
| 11 |
tools=[FinalAnswerTool(), suggest_menu, suggest_party_music, estimate_preparation_time],
|
| 12 |
)
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
if __name__ == "__main__":
|
| 15 |
-
|
| 16 |
-
GradioUI(agent).launch()
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
from smolagents import CodeAgent, InferenceClientModel
|
| 3 |
from tools.party_menu import suggest_menu
|
| 4 |
from tools.party_song import suggest_party_music
|
|
|
|
| 12 |
tools=[FinalAnswerTool(), suggest_menu, suggest_party_music, estimate_preparation_time],
|
| 13 |
)
|
| 14 |
|
| 15 |
+
# 定义 Gradio 接口
|
| 16 |
+
def chat_fn(message, history):
|
| 17 |
+
result = agent.run(message)
|
| 18 |
+
history = history + [(message, result)]
|
| 19 |
+
return history, history
|
| 20 |
+
|
| 21 |
+
demo = gr.ChatInterface(
|
| 22 |
+
fn=chat_fn,
|
| 23 |
+
chatbot=gr.Chatbot(),
|
| 24 |
+
textbox=gr.Textbox(placeholder="Ask Alfred to help plan your party..."),
|
| 25 |
+
title="Alfred Party Planner Agent",
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
if __name__ == "__main__":
|
| 29 |
+
demo.launch()
|
|
|