Spaces:
Sleeping
Sleeping
Update Gradio_UI.py
Browse files- Gradio_UI.py +11 -12
Gradio_UI.py
CHANGED
|
@@ -153,29 +153,28 @@ def stream_to_gradio(
|
|
| 153 |
):
|
| 154 |
yield message
|
| 155 |
|
| 156 |
-
|
| 157 |
-
|
|
|
|
| 158 |
|
| 159 |
-
|
| 160 |
-
if isinstance(final_answer, AgentText):
|
| 161 |
-
content = final_answer.to_string().strip()
|
| 162 |
yield gr.ChatMessage(
|
| 163 |
role="assistant",
|
| 164 |
-
content=
|
| 165 |
)
|
| 166 |
-
elif isinstance(
|
| 167 |
yield gr.ChatMessage(
|
| 168 |
role="assistant",
|
| 169 |
-
content={"path":
|
| 170 |
)
|
| 171 |
-
elif isinstance(
|
| 172 |
yield gr.ChatMessage(
|
| 173 |
role="assistant",
|
| 174 |
-
content={"path":
|
| 175 |
)
|
| 176 |
else:
|
| 177 |
-
|
| 178 |
-
|
| 179 |
|
| 180 |
|
| 181 |
|
|
|
|
| 153 |
):
|
| 154 |
yield message
|
| 155 |
|
| 156 |
+
final_step = step_log # this is the final ActionStep
|
| 157 |
+
final_output = getattr(final_step, "tool_output", None)
|
| 158 |
+
final_output = handle_agent_output_types(final_output)
|
| 159 |
|
| 160 |
+
if isinstance(final_output, AgentText):
|
|
|
|
|
|
|
| 161 |
yield gr.ChatMessage(
|
| 162 |
role="assistant",
|
| 163 |
+
content=final_output.to_string().strip(),
|
| 164 |
)
|
| 165 |
+
elif isinstance(final_output, AgentImage):
|
| 166 |
yield gr.ChatMessage(
|
| 167 |
role="assistant",
|
| 168 |
+
content={"path": final_output.to_string(), "mime_type": "image/png"},
|
| 169 |
)
|
| 170 |
+
elif isinstance(final_output, AgentAudio):
|
| 171 |
yield gr.ChatMessage(
|
| 172 |
role="assistant",
|
| 173 |
+
content={"path": final_output.to_string(), "mime_type": "audio/wav"},
|
| 174 |
)
|
| 175 |
else:
|
| 176 |
+
yield gr.ChatMessage(role="assistant", content=str(final_output).strip())
|
| 177 |
+
|
| 178 |
|
| 179 |
|
| 180 |
|