AI chat assistant
A conversation, not a screenshot
A mock chat with no model behind it. Click a slice of the donut and watch the click become the next message, then the next chart.
The loop, end to end
- The assistant answers with a donut spec.
ChartFromSpecdraws it inside the bubble withchrome="bare". - A click on a slice calls
onIntentwith a typedChartIntent. intentToPromptturns it into one line. Your app sends it as the next user message and the model replies with the next chart.
import { ChartFromSpec, intentToPrompt } from 'em-kit';
import type { ChartSpec } from 'em-kit';
type Props = {
message: { text: string; spec?: ChartSpec };
sendMessage: (text: string) => void;
};
export function AssistantMessage({ message, sendMessage }: Props) {
return (
<div className="bubble">
<p>{message.text}</p>
{message.spec && (
<ChartFromSpec
spec={message.spec}
chrome="bare"
height={260}
onIntent={(intent) => sendMessage(intentToPrompt(intent))}
/>
)}
</div>
);
}Click a slice in the chat to see the object your handler receives.
How did revenue split by region last quarter?
North America led last quarter with $421K, 36% of $1.2M. Click a slice to dig in.
Try your own spec
Paste whatever a model might send. Valid specs render with the real components; wrong ones still render something visible. The quickest way to test your prompts: copy the tool input from your logs and drop it in. Setting up the tool and the system prompt is covered in the charts from a model guide.
Edit the spec and the chart updates as you type. Try changing "chart" or removing a field.
Revenue by region
Last quarter
Intent log
Click a slice, bar, point or table row. Each click is one ChartIntent, followed by the line intentToPrompt would send to the model.