Spaces:
Sleeping
Sleeping
FinalAswer
Browse files- Gradio_UI.py +8 -2
Gradio_UI.py
CHANGED
|
@@ -24,6 +24,7 @@ from smolagents.agent_types import AgentAudio, AgentImage, AgentText, handle_age
|
|
| 24 |
from smolagents.agents import ActionStep, MultiStepAgent
|
| 25 |
from smolagents.memory import MemoryStep
|
| 26 |
from smolagents.utils import _is_package_available
|
|
|
|
| 27 |
|
| 28 |
def debug_print(x):
|
| 29 |
print("DEBUG_FROM_GRADIO:", x)
|
|
@@ -171,8 +172,13 @@ def stream_to_gradio(
|
|
| 171 |
yield message, None
|
| 172 |
|
| 173 |
# Dernier log = final answer
|
| 174 |
-
|
| 175 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
|
| 177 |
# Valeurs par défaut
|
| 178 |
final_message = None
|
|
|
|
| 24 |
from smolagents.agents import ActionStep, MultiStepAgent
|
| 25 |
from smolagents.memory import MemoryStep
|
| 26 |
from smolagents.utils import _is_package_available
|
| 27 |
+
from smolagents.agents import FinalAnswerStep
|
| 28 |
|
| 29 |
def debug_print(x):
|
| 30 |
print("DEBUG_FROM_GRADIO:", x)
|
|
|
|
| 172 |
yield message, None
|
| 173 |
|
| 174 |
# Dernier log = final answer
|
| 175 |
+
final_output = step_log # le dernier step
|
| 176 |
+
# 1) si c'est un FinalAnswerStep, on en extrait l'output
|
| 177 |
+
if isinstance(final_output, FinalAnswerStep):
|
| 178 |
+
final_output = final_output.output
|
| 179 |
+
|
| 180 |
+
# 2) on applique la normalisation smolagents
|
| 181 |
+
final_answer = handle_agent_output_types(final_output)
|
| 182 |
|
| 183 |
# Valeurs par défaut
|
| 184 |
final_message = None
|