mirror of
https://github.com/CopilotKit/CopilotKit.git
synced 2026-09-14 16:26:20 +08:00
c9a304ec4e
Root cause: gpt-4o-mini occasionally answered "Show me the sales
dashboard with metrics and a revenue chart" with a prose preamble
or clarifying question instead of the JSON spec the `@json-render`
renderer expects, which made the frontend fall back to
CopilotChatAssistantMessage (plain text) rather than a MetricCard +
BarChart tree. The single-component prompts (Revenue by category,
Expense trend) were terse enough that the model usually complied,
but the multi-component Sales Dashboard prompt was where it drifted.
Fix:
- Pass response_format={"type": "json_object"} via model_kwargs so
the OpenAI response is guaranteed to be a single JSON object,
removing any possibility of a plain-text fallback.
- Tighten the system prompt so every user turn is answered with JSON
(no clarifying questions, no prose) and components are referenced
by their exact case-sensitive names.
- Extend the Sales Dashboard worked example to include two MetricCards
plus a BarChart so the model has a concrete multi-component pattern
to mirror - the round-1 children forwarding in the registry wrapper
already supports arbitrarily many siblings under the root MetricCard.