Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -88,23 +88,4 @@ agent = CodeAgent(
|
|
| 88 |
)
|
| 89 |
|
| 90 |
|
| 91 |
-
|
| 92 |
-
# Launch Gradio UI
|
| 93 |
-
# -------------------------
|
| 94 |
-
# Custom wrapper to automatically unwrap BytesIO images from FinalAnswerStep
|
| 95 |
-
def gradio_output_wrapper(agent_output):
|
| 96 |
-
"""
|
| 97 |
-
Checks if agent_output.final_answer is a BytesIO image and returns it directly
|
| 98 |
-
for Gradio to display.
|
| 99 |
-
"""
|
| 100 |
-
try:
|
| 101 |
-
# If agent_output has final_answer attribute (FinalAnswerStep)
|
| 102 |
-
buffer = getattr(agent_output, "final_answer", None)
|
| 103 |
-
if isinstance(buffer, BytesIO):
|
| 104 |
-
buffer.seek(0)
|
| 105 |
-
return buffer # Gradio can render BytesIO as an image
|
| 106 |
-
return agent_output # fallback for text or other outputs
|
| 107 |
-
except Exception:
|
| 108 |
-
return agent_output
|
| 109 |
-
|
| 110 |
-
GradioUI(agent, output_wrapper=gradio_output_wrapper).launch()
|
|
|
|
| 88 |
)
|
| 89 |
|
| 90 |
|
| 91 |
+
GradioUI(agent).launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|