Repository navigation
Richer GradioUI for debugging and vsualization #878
Replies: 1 comment
|
In That means:
For your own remarks, one way to use the existing UI is to collect them and append them to the completed action's observations: from smolagents import CodeAgent, GradioUI
from smolagents.memory import ActionStep
remarks = [] # Dedicated to this agent/session, not shared across users.
def publish_remarks(step: ActionStep, agent):
if remarks:
step.observations = (
(step.observations or "") + "\n" + "\n".join(remarks)
)
remarks.clear()
# In your own tool, replace print("...") with remarks.append("...").
agent = CodeAgent(
tools=tools,
model=model,
step_callbacks={ActionStep: publish_remarks},
)
GradioUI(agent).launch(share=False)This displays the remarks when the action step finishes, not continuously during a long-running tool. Also, observations are agent memory: the remarks will be included in later model requests. For UI-only diagnostics, keep them outside Verified with Python 3.12.14, smolagents 1.26.0, and Gradio 5.49.1 using a deterministic model stub and the actual Sources: Gradio observation rendering, step callback API. |
Uh oh!
There was an error while loading. Please reload this page.
Throughout the agent's run, I print several key remarks that I want to display in the Gradio UI. How can I connect them to the Gradio UI?
All reactions