Spaces:
Running
Running
Update ui/voice_agent_ui.py
Browse files- ui/voice_agent_ui.py +13 -10
ui/voice_agent_ui.py
CHANGED
|
@@ -139,7 +139,7 @@ def create_voice_agent_ui(agent):
|
|
| 139 |
|
| 140 |
# MAIN COMMAND PROCESSOR
|
| 141 |
async def process_audio_command(audio_file, text_command, files_list):
|
| 142 |
-
"""Process voice + text commands - FIXED for
|
| 143 |
|
| 144 |
# Step 1 β Identify user command
|
| 145 |
if audio_file and not text_command:
|
|
@@ -165,9 +165,8 @@ def create_voice_agent_ui(agent):
|
|
| 165 |
# Call agent (non-streaming)
|
| 166 |
final_answer, thoughts = await agent.execute(cmd, files_list)
|
| 167 |
|
| 168 |
-
# Convert AgentThought objects to Gradio
|
| 169 |
-
# MUST be
|
| 170 |
-
# Each tuple is ONE chat exchange
|
| 171 |
messages = []
|
| 172 |
|
| 173 |
for i, t in enumerate(thoughts):
|
|
@@ -201,10 +200,11 @@ def create_voice_agent_ui(agent):
|
|
| 201 |
icon = "β
"
|
| 202 |
title = "Answer"
|
| 203 |
|
| 204 |
-
#
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
|
|
|
| 208 |
|
| 209 |
# Show results
|
| 210 |
yield messages, "π Generating voice response...", final_answer, None, None
|
|
@@ -228,8 +228,11 @@ def create_voice_agent_ui(agent):
|
|
| 228 |
import traceback
|
| 229 |
err_msg = f"β οΈ Error: {str(e)}\n\nTraceback:\n{traceback.format_exc()}"
|
| 230 |
|
| 231 |
-
# Error message
|
| 232 |
-
error_messages = [
|
|
|
|
|
|
|
|
|
|
| 233 |
yield error_messages, f"β Error: {str(e)}", err_msg, None, None
|
| 234 |
|
| 235 |
# CONNECT EVENTS
|
|
|
|
| 139 |
|
| 140 |
# MAIN COMMAND PROCESSOR
|
| 141 |
async def process_audio_command(audio_file, text_command, files_list):
|
| 142 |
+
"""Process voice + text commands - FIXED for Gradio 6.0 dictionary format"""
|
| 143 |
|
| 144 |
# Step 1 β Identify user command
|
| 145 |
if audio_file and not text_command:
|
|
|
|
| 165 |
# Call agent (non-streaming)
|
| 166 |
final_answer, thoughts = await agent.execute(cmd, files_list)
|
| 167 |
|
| 168 |
+
# Convert AgentThought objects to Gradio 6.0 format
|
| 169 |
+
# MUST be list of dicts with "role" and "content" keys
|
|
|
|
| 170 |
messages = []
|
| 171 |
|
| 172 |
for i, t in enumerate(thoughts):
|
|
|
|
| 200 |
icon = "β
"
|
| 201 |
title = "Answer"
|
| 202 |
|
| 203 |
+
# Add as assistant message
|
| 204 |
+
messages.append({
|
| 205 |
+
"role": "assistant",
|
| 206 |
+
"content": f"{icon} **{title}**\n\n{t_content}"
|
| 207 |
+
})
|
| 208 |
|
| 209 |
# Show results
|
| 210 |
yield messages, "π Generating voice response...", final_answer, None, None
|
|
|
|
| 228 |
import traceback
|
| 229 |
err_msg = f"β οΈ Error: {str(e)}\n\nTraceback:\n{traceback.format_exc()}"
|
| 230 |
|
| 231 |
+
# Error message in dictionary format
|
| 232 |
+
error_messages = [{
|
| 233 |
+
"role": "assistant",
|
| 234 |
+
"content": f"β **Error**\n\n{str(e)}"
|
| 235 |
+
}]
|
| 236 |
yield error_messages, f"β Error: {str(e)}", err_msg, None, None
|
| 237 |
|
| 238 |
# CONNECT EVENTS
|