mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-07-24 21:41:08 +02:00
feat(x): inline charts in chat via a charts skill
The chat's markdown fence override now renders ```chart blocks (the same ChartBlockSchema notes use) as interactive recharts inline — the mermaid pattern. A new ChartRenderer handles line/bar/pie with multi-series support, light/dark theming, and a quiet placeholder while the fence body is still streaming. ChartBlockSchema.y widens to string | string[] for multi-series charts (notes chart block updated to map series too), with a chartSeries() helper in shared. A new 'charts' skill teaches the model the fence format, form selection (line/bar/pie, no mixed scales), and data honesty rules; loaded on demand like any skill.
This commit is contained in:
parent
efa6a0523c
commit
5acd825903
6 changed files with 256 additions and 4 deletions
|
|
@ -47,11 +47,18 @@ export const ChartBlockSchema = z.object({
|
|||
data: z.array(z.record(z.string(), z.unknown())).optional(),
|
||||
source: z.string().optional(),
|
||||
x: z.string(),
|
||||
y: z.string(),
|
||||
// One series (string) or several (array of data keys). Pie ignores all
|
||||
// but the first.
|
||||
y: z.union([z.string(), z.array(z.string()).min(1)]),
|
||||
});
|
||||
|
||||
export type ChartBlock = z.infer<typeof ChartBlockSchema>;
|
||||
|
||||
/** The y series list regardless of which form the block used. */
|
||||
export function chartSeries(block: ChartBlock): string[] {
|
||||
return Array.isArray(block.y) ? block.y : [block.y];
|
||||
}
|
||||
|
||||
export const TableBlockSchema = z.object({
|
||||
columns: z.array(z.string()),
|
||||
data: z.array(z.record(z.string(), z.unknown())),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue