Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -36,11 +36,12 @@ smol_agent = CodeAgent(model=smol_model, tools=[DuckDuckGoSearchTool()])
|
|
| 36 |
# UI LOGIC
|
| 37 |
# ==========================================
|
| 38 |
async def chat_llama(message, history):
|
|
|
|
| 39 |
result = await li_agent.run(user_msg=message)
|
| 40 |
return str(result)
|
| 41 |
|
| 42 |
def chat_smol(message, history):
|
| 43 |
-
#
|
| 44 |
yield [
|
| 45 |
ChatMessage(role="user", content=message),
|
| 46 |
ChatMessage(
|
|
@@ -62,48 +63,39 @@ def chat_smol(message, history):
|
|
| 62 |
# GRADIO 6.0 ENHANCED UI
|
| 63 |
# ==========================================
|
| 64 |
with gr.Blocks(fill_height=True) as demo:
|
| 65 |
-
# Sidebar replaces global config area
|
| 66 |
with gr.Sidebar():
|
| 67 |
gr.Markdown("# 🛠️ Workspace Settings")
|
| 68 |
-
gr.
|
| 69 |
|
| 70 |
-
gr.
|
|
|
|
| 71 |
|
| 72 |
-
gr.
|
| 73 |
-
gr.
|
| 74 |
-
|
| 75 |
-
gr.HTML("<hr>")
|
| 76 |
-
|
| 77 |
-
gr.Info("LlamaIndex is optimized for business logic. smolagents is built for raw tool execution.")
|
| 78 |
|
| 79 |
-
# Main Chat View
|
| 80 |
with gr.Column():
|
| 81 |
-
gr.Markdown(f"# 🤖 Multi-Agent Hub
|
| 82 |
|
| 83 |
with gr.Tabs():
|
| 84 |
with gr.Tab("🏗️ LlamaIndex (Workflow)"):
|
|
|
|
| 85 |
gr.ChatInterface(
|
| 86 |
fn=chat_llama,
|
| 87 |
-
type="messages",
|
| 88 |
examples=["How is the weather in Tokyo?"]
|
| 89 |
)
|
| 90 |
|
| 91 |
with gr.Tab("💻 smolagents (CodeAgent)"):
|
| 92 |
-
#
|
| 93 |
chatbot = gr.Chatbot(
|
| 94 |
label="Code Agent",
|
| 95 |
-
type="messages",
|
| 96 |
-
show_label=False,
|
| 97 |
avatar_images=(None, "https://raw.githubusercontent.com/huggingface/smolagents/main/docs/source/imgs/smolagents_logo.png")
|
| 98 |
)
|
| 99 |
msg = gr.Textbox(placeholder="Ask me to search or run code...", container=False)
|
| 100 |
|
|
|
|
| 101 |
msg.submit(chat_smol, [msg, chatbot], [chatbot])
|
| 102 |
msg.submit(lambda: "", None, [msg])
|
| 103 |
|
| 104 |
if __name__ == "__main__":
|
| 105 |
-
|
| 106 |
-
demo.launch(
|
| 107 |
-
theme=gr.themes.Soft(),
|
| 108 |
-
css=".gradio-container { max-width: 1200px !important; }"
|
| 109 |
-
)
|
|
|
|
| 36 |
# UI LOGIC
|
| 37 |
# ==========================================
|
| 38 |
async def chat_llama(message, history):
|
| 39 |
+
# History in Gradio 6 is already a list of dicts
|
| 40 |
result = await li_agent.run(user_msg=message)
|
| 41 |
return str(result)
|
| 42 |
|
| 43 |
def chat_smol(message, history):
|
| 44 |
+
# Using the new ChatMessage format for metadata thoughts
|
| 45 |
yield [
|
| 46 |
ChatMessage(role="user", content=message),
|
| 47 |
ChatMessage(
|
|
|
|
| 63 |
# GRADIO 6.0 ENHANCED UI
|
| 64 |
# ==========================================
|
| 65 |
with gr.Blocks(fill_height=True) as demo:
|
|
|
|
| 66 |
with gr.Sidebar():
|
| 67 |
gr.Markdown("# 🛠️ Workspace Settings")
|
| 68 |
+
gr.Separator() # Correct replacement for gr.Divider()
|
| 69 |
|
| 70 |
+
gr.Markdown("### 🤖 Framework Info")
|
| 71 |
+
gr.Info("LlamaIndex: Workflow-based.\nsmolagents: Code-based.")
|
| 72 |
|
| 73 |
+
gr.Separator()
|
| 74 |
+
gr.Markdown("Status: **Online**")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
|
|
|
|
| 76 |
with gr.Column():
|
| 77 |
+
gr.Markdown(f"# 🤖 Multi-Agent Hub")
|
| 78 |
|
| 79 |
with gr.Tabs():
|
| 80 |
with gr.Tab("🏗️ LlamaIndex (Workflow)"):
|
| 81 |
+
# REMOVED type="messages" as it is now default
|
| 82 |
gr.ChatInterface(
|
| 83 |
fn=chat_llama,
|
|
|
|
| 84 |
examples=["How is the weather in Tokyo?"]
|
| 85 |
)
|
| 86 |
|
| 87 |
with gr.Tab("💻 smolagents (CodeAgent)"):
|
| 88 |
+
# Manual Chatbot to allow for 'Thinking' metadata
|
| 89 |
chatbot = gr.Chatbot(
|
| 90 |
label="Code Agent",
|
| 91 |
+
type="messages", # Explicitly allowed here for the component
|
|
|
|
| 92 |
avatar_images=(None, "https://raw.githubusercontent.com/huggingface/smolagents/main/docs/source/imgs/smolagents_logo.png")
|
| 93 |
)
|
| 94 |
msg = gr.Textbox(placeholder="Ask me to search or run code...", container=False)
|
| 95 |
|
| 96 |
+
# Setup event handling
|
| 97 |
msg.submit(chat_smol, [msg, chatbot], [chatbot])
|
| 98 |
msg.submit(lambda: "", None, [msg])
|
| 99 |
|
| 100 |
if __name__ == "__main__":
|
| 101 |
+
demo.launch(theme=gr.themes.Soft())
|
|
|
|
|
|
|
|
|
|
|
|