MCPcopy Create free account
hub / github.com/VersusControl/devops-ai-guidelines / StreamlitProgress

Class StreamlitProgress

03-ai-agent-for-devops/code/12/app.py:40–85  ·  view source on GitHub ↗

Callbacks that render live tool-call progress inside a st.status container.

Source from the content-addressed store, hash-verified

38
39
40class StreamlitProgress:
41 """Callbacks that render live tool-call progress inside a st.status container."""
42
43 def __init__(self, container):
44 self.status = container
45 self.tool_count = 0
46 self.steps = [] # saved into message history
47
48 def on_thinking(self):
49 self.status.update(label="Thinking...", state="running")
50
51 def on_reasoning(self, text: str):
52 if text:
53 self.status.write(f"_{text}_")
54 self.steps.append({"label": "Reasoning", "detail": text})
55
56 def on_tool_start(self, tool_name: str, tool_args: dict):
57 self.tool_count += 1
58 label = TOOL_LABELS.get(tool_name, tool_name)
59 self.status.update(label=f"{label}...", state="running")
60
61 def on_tool_end(self, tool_name: str, result: str, success: bool = True):
62 label = TOOL_LABELS.get(tool_name, tool_name)
63 marker = "OK" if success else "FAIL"
64 preview = _summarize_result(tool_name, result)
65 self.status.write(f"[{marker}] **{label}** — {preview}")
66 self.steps.append({"label": label, "detail": f"[{marker}] {preview}"})
67
68 def on_approval_skipped(self, tool_name: str, tool_args: dict):
69 label = TOOL_LABELS.get(tool_name, tool_name)
70 self.status.write(f"[BLOCKED] **{label}** — requires your approval")
71 self.steps.append({"label": label, "detail": "[BLOCKED] requires approval"})
72
73 def complete(self):
74 n = self.tool_count
75 if n:
76 self.status.update(
77 label=f"Done — {n} tool{'s' if n != 1 else ''} used",
78 state="complete", expanded=False,
79 )
80 else:
81 self.status.update(label="Done", state="complete", expanded=False)
82
83 def error(self, msg: str):
84 self.status.update(label="Error", state="error")
85 self.status.write(f"Error: {msg}")
86
87
88def _summarize_result(tool_name: str, result: str) -> str:

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected