Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ const dashboardViews = views({
});

const WELCOME_SUGGESTIONS = [
{ label: 'Render a dashboard', value: 'Show me a Q3 sales dashboard with three metrics.' },
{ label: 'Render a form', value: 'Create a contact form with name, email, and message.' },
{ label: 'Airline operations dashboard', value: 'Show me a dashboard of airline operations.' },
{ label: 'Filter to cancelled flights', value: 'Filter to only the cancelled flights.' },
] as const;

@Component({
Expand Down
4 changes: 2 additions & 2 deletions cockpit/chat/generative-ui/python/prompts/dashboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

You are a dashboard agent that builds interactive airline-operations KPI dashboards. You have five tools:

- `render_spec(spec)` — Author or update the dashboard layout. The spec is a JSON object describing component types, props, children, and state bindings. See the schema below.
- `render_spec(elements, root)` — Author or update the dashboard layout. `elements` is a dict keyed by component id (each value has `type`, optional `props`, optional `children`); `root` is the id of the top-level component. See the schema below.
- `query_airline_kpis()` — Snapshot of operational KPIs: on-time %, flights today, avg delay, load factor.
- `query_on_time_trend(months=12)` — On-time performance per month, for the line chart.
- `query_flights_by_airline(airlines=None)` — Daily flight counts per airline, for the bar chart.
Expand All @@ -14,7 +14,7 @@ You are a dashboard agent that builds interactive airline-operations KPI dashboa

1. Call `render_spec` ONCE with a complete dashboard layout — stat cards, charts, table — using `$state` bindings to the slots the data tools populate (see "State Path Conventions" below).
2. In the SAME turn (same tool_calls array), call EACH data tool that backs a component in your spec. Do NOT call tools whose data your spec doesn't reference.
3. After the tools return, return WITHOUT any further tool calls. A separate node will write a brief conversational summary.
3. After the tools return, return WITHOUT any further tool calls. A separate node will write a brief conversational summary. **Critical: if `render_spec` and the data tools have already been called this turn, you are DONE. Return with no tool_calls. Do NOT call `render_spec` again. Do NOT re-call the data tools.**

### When the dashboard exists (follow-up turn)

Expand Down
22 changes: 11 additions & 11 deletions cockpit/chat/generative-ui/python/src/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,27 @@ class DashboardState(MessagesState):


@tool
async def render_spec(spec: dict) -> str:
"""Render an interactive dashboard layout from a JSON spec.
async def render_spec(elements: dict, root: str) -> str:
"""Render an interactive dashboard layout.

Use this tool to author or update the dashboard layout. The spec is a
JSON object with `elements` (a dict keyed by component id) and `root`
(the id of the top-level component). See the system prompt for the full
schema and component catalog.
Use this tool to author or update the dashboard layout. See the system
prompt for the full component catalog and state binding conventions.

Call this tool FIRST on any turn where the layout needs to be created
or restructured. After calling render_spec, call the data tools needed
to populate the components you authored.
Call this tool AT MOST ONCE per turn — only when the layout needs to
be created (first turn) or restructured (follow-up structural change).
Do NOT call it again to refresh data; the data tools handle that.

Args:
spec: The dashboard JSON render spec.
elements: Dict keyed by component id. Each value has `type`, optional
`props`, and optional `children` (list of component ids).
root: The id of the top-level component (must be a key in `elements`).

Returns:
The spec serialized as JSON. A post-process node (wrap_spec_into_ai)
wraps this payload into the AI message content where the
chat-lib's content-classifier picks it up.
"""
return json.dumps(spec)
return json.dumps({"elements": elements, "root": root})


_ALL_TOOLS = [render_spec, *_DATA_TOOLS]
Expand Down
4 changes: 2 additions & 2 deletions cockpit/langgraph/streaming/python/prompts/dashboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

You are a dashboard agent that builds interactive airline-operations KPI dashboards. You have five tools:

- `render_spec(spec)` — Author or update the dashboard layout. The spec is a JSON object describing component types, props, children, and state bindings. See the schema below.
- `render_spec(elements, root)` — Author or update the dashboard layout. `elements` is a dict keyed by component id (each value has `type`, optional `props`, optional `children`); `root` is the id of the top-level component. See the schema below.
- `query_airline_kpis()` — Snapshot of operational KPIs: on-time %, flights today, avg delay, load factor.
- `query_on_time_trend(months=12)` — On-time performance per month, for the line chart.
- `query_flights_by_airline(airlines=None)` — Daily flight counts per airline, for the bar chart.
Expand All @@ -14,7 +14,7 @@ You are a dashboard agent that builds interactive airline-operations KPI dashboa

1. Call `render_spec` ONCE with a complete dashboard layout — stat cards, charts, table — using `$state` bindings to the slots the data tools populate (see "State Path Conventions" below).
2. In the SAME turn (same tool_calls array), call EACH data tool that backs a component in your spec. Do NOT call tools whose data your spec doesn't reference.
3. After the tools return, return WITHOUT any further tool calls. A separate node will write a brief conversational summary.
3. After the tools return, return WITHOUT any further tool calls. A separate node will write a brief conversational summary. **Critical: if `render_spec` and the data tools have already been called this turn, you are DONE. Return with no tool_calls. Do NOT call `render_spec` again. Do NOT re-call the data tools.**

### When the dashboard exists (follow-up turn)

Expand Down