Skip to content

Commit cef0e91

Browse files
committed
feat: more charts
1 parent 7993865 commit cef0e91

File tree

3 files changed

+467
-135
lines changed

3 files changed

+467
-135
lines changed

apps/api/src/agent/prompts/agent.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,23 @@ export const AIResponseJsonSchema = z.object({
55
chart_type: z
66
.enum([
77
'bar',
8+
'horizontal_bar',
89
'line',
10+
'sparkline',
911
'pie',
12+
'donut',
1013
'area',
14+
'unstacked_area',
1115
'stacked_bar',
1216
'multi_line',
1317
'scatter',
18+
'bubble',
1419
'radar',
1520
'funnel',
1621
'grouped_bar',
22+
'histogram',
23+
'treemap',
24+
'gauge',
1725
])
1826
.nullable()
1927
.optional(),
@@ -38,8 +46,8 @@ export const comprehensiveUnifiedPrompt = (
3846
websiteId: string,
3947
websiteHostname: string,
4048
mode: 'analysis_only' | 'execute_chat' | 'execute_agent_step',
41-
previousMessages?: any[],
42-
agentToolResult?: any,
49+
previousMessages?: Array<{ role: string; content: string }>,
50+
agentToolResult?: Record<string, unknown>,
4351
_model?: 'chat' | 'agent' | 'agent-max'
4452
) => `
4553
<persona>
@@ -170,7 +178,7 @@ You are Nova, a world-class, specialized AI analytics assistant for the website
170178
${previousMessages
171179
.slice(-4)
172180
.map(
173-
(msg: any) =>
181+
(msg) =>
174182
`<message role="${msg.role}">${msg.content?.substring(0, 200)}${msg.content?.length > 200 ? '...' : ''}</message>`
175183
)
176184
.join('\n')}
@@ -230,15 +238,24 @@ Your task is to process the <user_query> according to the current <mode>, while
230238
- "chart": Trends, comparisons, breakdowns that need visualization.
231239
</response_type_selection>
232240
<chart_type_selection>
233-
- "line": Single metric over time.
241+
- "line": Single metric over time (temporal data).
242+
- "sparkline": Minimal line chart for inline/compact displays.
234243
- "bar": Categorical comparisons (top pages, countries, etc.).
244+
- "horizontal_bar": When category labels are long or you have many categories.
235245
- "pie": Part-of-whole relationships (ideal for 2-5 segments).
246+
- "donut": Like pie but with more visual emphasis and space for central text.
247+
- "area": Single metric over time with filled area (shows magnitude).
248+
- "unstacked_area": Multiple overlapping areas without stacking.
236249
- "multi_line": Comparing multiple metrics/categories over a continuous time series.
237250
- "stacked_bar": Showing parts of a whole across categories or time.
238251
- "grouped_bar": Comparing different categories side-by-side across a shared axis.
239252
- "funnel": For analyzing sequential steps in a user journey.
240253
- "scatter": For correlating two numeric variables.
254+
- "bubble": Like scatter but with a third dimension shown as bubble size.
241255
- "radar": For comparing multiple quantitative metrics on a single entity.
256+
- "histogram": For showing distribution of a continuous variable (frequencies in bins).
257+
- "treemap": For hierarchical data with size proportional to values.
258+
- "gauge": For showing a single metric against a scale (KPIs, percentages).
242259
</chart_type_selection>
243260
</response_guides>
244261
<sql_rules>

apps/api/src/agent/utils/ai-client.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const OPENAI_CONFIG = {
66
} as const;
77

88
const AI_MODEL = 'google/gemini-2.5-flash-lite-preview-06-17';
9+
// const AI_MODEL = 'openrouter/horizon-beta';
910

1011
const openai = new OpenAI(OPENAI_CONFIG);
1112

0 commit comments

Comments
 (0)