csv-charts-ai 1.3.1 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # csv-charts-ai
2
2
 
3
- AI-powered chart generation and visualization for tabular data, built on [Recharts](https://recharts.org/) and the [Vercel AI SDK](https://sdk.vercel.ai/).
3
+ AI-powered CSV analysis, chart generation, and interactive visualization. Built on the [Vercel AI SDK](https://sdk.vercel.ai/) and [Recharts](https://recharts.org/).
4
+
5
+ **Works with any LLM provider** — OpenAI, Anthropic, Google, Mistral, Ollama, or any OpenAI-compatible endpoint.
4
6
 
5
7
  ## Installation
6
8
 
@@ -8,75 +10,112 @@ AI-powered chart generation and visualization for tabular data, built on [Rechar
8
10
  pnpm add csv-charts-ai ai zod
9
11
  ```
10
12
 
11
- Peer dependencies: `react`, `recharts`, `lucide-react`, `ai`, `zod`.
12
-
13
- ## AI Chart Generation
13
+ **Peer dependencies:** `ai`, `zod` (required). `react`, `recharts`, `lucide-react` (optional — only needed for React chart components).
14
14
 
15
- ### Simple — OpenAI
15
+ ## Quick Start
16
16
 
17
17
  ```ts
18
- import { suggestCharts } from "csv-charts-ai";
18
+ import { parseCSV, analyzeData, suggestQuestions } from "csv-charts-ai";
19
19
 
20
- const charts = await suggestCharts({
20
+ // 1. Parse CSV string into structured data
21
+ const data = parseCSV(`name,age,city,salary
22
+ Alice,30,Paris,75000
23
+ Bob,25,London,62000
24
+ Charlie,35,Berlin,88000`);
25
+
26
+ // 2. Run full AI analysis (summary + anomalies + charts) in parallel
27
+ const result = await analyzeData({
21
28
  model: { apiKey: "sk-...", model: "gpt-4o" },
22
- data: myData,
23
- dataSummary: "10,000 rows, columns: date, category, revenue, quantity...",
29
+ data,
24
30
  });
25
- ```
26
31
 
27
- ### Custom endpoint — Ollama / vLLM / LM Studio
32
+ console.log(result.summary.keyInsights);
33
+ console.log(`Found ${result.anomalies.length} anomalies`);
34
+ console.log(`Generated ${result.charts.length} chart suggestions`);
28
35
 
29
- ```ts
30
- const charts = await suggestCharts({
31
- model: {
32
- apiKey: "",
33
- model: "llama3",
34
- baseURL: "http://localhost:11434/v1",
35
- },
36
- data: myData,
37
- dataSummary: "...",
36
+ // 3. Suggest questions the user could ask
37
+ const questions = await suggestQuestions({
38
+ model: { apiKey: "sk-...", model: "gpt-4o" },
39
+ data,
38
40
  });
41
+ questions.forEach(q => console.log(`[${q.category}] ${q.question}`));
39
42
  ```
40
43
 
41
- ### Other providers — Anthropic, Google, Mistral
44
+ ## CSV Parsing
45
+
46
+ Parse CSV strings into the `TabularData` format with automatic delimiter detection and column type inference.
42
47
 
43
48
  ```ts
44
- // Dynamic import install @ai-sdk/anthropic
45
- const charts = await suggestCharts({
46
- model: { apiKey: "sk-ant-...", model: "claude-sonnet-4-20250514", provider: "anthropic" },
47
- data: myData,
48
- dataSummary: "...",
49
+ import { parseCSV } from "csv-charts-ai";
50
+
51
+ // Auto-detects delimiter (comma, semicolon, tab, pipe)
52
+ const data = parseCSV(csvString);
53
+
54
+ // Explicit options
55
+ const data = parseCSV(csvString, {
56
+ delimiter: ";",
57
+ hasHeader: true,
58
+ skipEmpty: true,
49
59
  });
60
+
61
+ console.log(data.headers); // ["name", "age", "city"]
62
+ console.log(data.rowCount); // 100
63
+ console.log(data.columns); // [{ name: "name", type: "string", index: 0 }, ...]
50
64
  ```
51
65
 
52
- ### Advanced any LanguageModel
66
+ **Type inference** detects `string`, `number`, `date`, and `boolean` columns by sampling values. Handles quoted fields, escaped quotes, multi-line values, and BOM stripping (RFC 4180).
67
+
68
+ > For very large files or exotic encodings, consider using [PapaParse](https://www.papaparse.com/) and passing the result as `TabularData` directly.
69
+
70
+ ## AI Functions
71
+
72
+ All AI functions accept either a simple config object or a pre-built `LanguageModel` from the Vercel AI SDK. All support an optional `signal` (AbortSignal) for cancellation.
73
+
74
+ ### Chart Suggestions
53
75
 
54
76
  ```ts
55
77
  import { suggestCharts } from "csv-charts-ai";
56
- import { anthropic } from "@ai-sdk/anthropic";
57
78
 
79
+ // Simple — OpenAI
80
+ const charts = await suggestCharts({
81
+ model: { apiKey: "sk-...", model: "gpt-4o" },
82
+ data,
83
+ });
84
+
85
+ // Custom endpoint — Ollama / vLLM / LM Studio
86
+ const charts = await suggestCharts({
87
+ model: { apiKey: "", model: "llama3", baseURL: "http://localhost:11434/v1" },
88
+ data,
89
+ });
90
+
91
+ // Other providers — Anthropic, Google, Mistral
92
+ const charts = await suggestCharts({
93
+ model: { apiKey: "sk-ant-...", model: "claude-sonnet-4-20250514", provider: "anthropic" },
94
+ data,
95
+ });
96
+
97
+ // Advanced — any LanguageModel instance
98
+ import { anthropic } from "@ai-sdk/anthropic";
58
99
  const charts = await suggestCharts({
59
100
  model: anthropic("claude-sonnet-4-20250514"),
60
- data: myData,
61
- dataSummary: "...",
101
+ data,
62
102
  language: "French",
63
103
  });
64
104
  ```
65
105
 
66
- ### Generate a chart from a prompt
106
+ ### Custom Chart from Prompt
67
107
 
68
108
  ```ts
69
109
  import { suggestCustomChart } from "csv-charts-ai";
70
110
 
71
111
  const chart = await suggestCustomChart({
72
112
  model: { apiKey: "sk-...", model: "gpt-4o" },
73
- data: myData,
74
- dataSummary: "...",
113
+ data,
75
114
  prompt: "Show me a bar chart of revenue by category",
76
115
  });
77
116
  ```
78
117
 
79
- ### Repair a broken chart
118
+ ### Repair a Broken Chart
80
119
 
81
120
  ```ts
82
121
  import { repairChart } from "csv-charts-ai";
@@ -89,9 +128,130 @@ const fixed = await repairChart({
89
128
  });
90
129
  ```
91
130
 
131
+ ### Data Summary
132
+
133
+ ```ts
134
+ import { summarizeData } from "csv-charts-ai";
135
+
136
+ const result = await summarizeData({
137
+ model: { apiKey: "sk-...", model: "gpt-4o" },
138
+ data,
139
+ });
140
+
141
+ console.log(result.summary); // "This dataset contains sales records..."
142
+ console.log(result.keyInsights); // ["Revenue peaks in Q4", "Product A leads..."]
143
+ console.log(result.dataQuality); // "Good completeness, 2 missing values in..."
144
+ ```
145
+
146
+ ### Anomaly Detection
147
+
148
+ ```ts
149
+ import { detectAnomalies } from "csv-charts-ai";
150
+
151
+ const anomalies = await detectAnomalies({
152
+ model: { apiKey: "sk-...", model: "gpt-4o" },
153
+ data,
154
+ maxRows: 100, // default: 50
155
+ });
156
+
157
+ anomalies.forEach(a =>
158
+ console.log(`[${a.severity}] Row ${a.row}, ${a.column}: ${a.issue}`)
159
+ );
160
+ ```
161
+
162
+ ### Ask Questions About Data
163
+
164
+ ```ts
165
+ import { askAboutData, streamAskAboutData } from "csv-charts-ai";
166
+
167
+ // Non-streaming
168
+ const answer = await askAboutData({
169
+ model: { apiKey: "sk-...", model: "gpt-4o" },
170
+ data,
171
+ question: "What is the average revenue by region?",
172
+ history: [{ prompt: "How many rows?", response: "There are 1000 rows." }],
173
+ });
174
+
175
+ // Streaming
176
+ await streamAskAboutData({
177
+ model: { apiKey: "sk-...", model: "gpt-4o" },
178
+ data,
179
+ question: "What trends do you see?",
180
+ onChunk: (chunk) => process.stdout.write(chunk),
181
+ onComplete: (full) => console.log("\nDone:", full.length, "chars"),
182
+ });
183
+ ```
184
+
185
+ ### Suggest Questions
186
+
187
+ ```ts
188
+ import { suggestQuestions } from "csv-charts-ai";
189
+
190
+ const questions = await suggestQuestions({
191
+ model: { apiKey: "sk-...", model: "gpt-4o" },
192
+ data,
193
+ count: 5,
194
+ });
195
+
196
+ questions.forEach(q => console.log(`[${q.category}] ${q.question}`));
197
+ // [trend] How has revenue changed month over month?
198
+ // [comparison] Which region has the highest average order value?
199
+ // [correlation] Is there a relationship between marketing spend and sales?
200
+ ```
201
+
202
+ ### Full Analysis Pipeline
203
+
204
+ Runs summary, anomaly detection, and chart suggestions in parallel:
205
+
206
+ ```ts
207
+ import { analyzeData } from "csv-charts-ai";
208
+
209
+ const result = await analyzeData({
210
+ model: { apiKey: "sk-...", model: "gpt-4o" },
211
+ data,
212
+ detectAnomalies: true, // default: true
213
+ suggestCharts: true, // default: true
214
+ });
215
+
216
+ // result.summary — DataSummaryResult
217
+ // result.anomalies — AnomalyResult[]
218
+ // result.charts — ChartConfig[]
219
+ ```
220
+
221
+ ## Cancellation (AbortSignal)
222
+
223
+ All AI functions support `signal` for cancellation — essential for React cleanup and timeouts:
224
+
225
+ ```ts
226
+ const controller = new AbortController();
227
+
228
+ const charts = await suggestCharts({
229
+ model: { apiKey: "sk-...", model: "gpt-4o" },
230
+ data,
231
+ signal: controller.signal,
232
+ });
233
+
234
+ // Cancel from elsewhere
235
+ controller.abort();
236
+ ```
237
+
238
+ React example:
239
+
240
+ ```tsx
241
+ useEffect(() => {
242
+ const controller = new AbortController();
243
+ analyzeData({ model, data, signal: controller.signal })
244
+ .then(setResult)
245
+ .catch(() => {});
246
+ return () => controller.abort();
247
+ }, [data]);
248
+ ```
249
+
92
250
  ## React Components
93
251
 
94
- ### Display charts
252
+ > **Requires** `react`, `recharts`, `lucide-react`, and **Tailwind CSS** for styling.
253
+
254
+ ### Display Charts
95
255
 
96
256
  ```tsx
97
257
  import { ChartDisplay } from "csv-charts-ai";
@@ -99,7 +259,7 @@ import { ChartDisplay } from "csv-charts-ai";
99
259
  <ChartDisplay data={data} charts={charts} />
100
260
  ```
101
261
 
102
- ### With theme
262
+ ### With Theme
103
263
 
104
264
  ```tsx
105
265
  import { ChartDisplay, defaultLightTheme } from "csv-charts-ai";
@@ -107,32 +267,108 @@ import { ChartDisplay, defaultLightTheme } from "csv-charts-ai";
107
267
  <ChartDisplay data={data} charts={charts} theme={defaultLightTheme} />
108
268
  ```
109
269
 
110
- ## Components
270
+ ### Custom Card Wrapper
271
+
272
+ ```tsx
273
+ <ChartDisplay
274
+ data={data}
275
+ charts={charts}
276
+ cardWrapper={({ children, title }) => (
277
+ <div className="my-card">
278
+ <h2>{title}</h2>
279
+ {children}
280
+ </div>
281
+ )}
282
+ onRegenerate={async (chart) => {
283
+ const fixed = await repairChart({ model, failedChart: chart, columns: data.headers, errorContext: "Rendering failed" });
284
+ // update state with fixed chart
285
+ }}
286
+ />
287
+ ```
288
+
289
+ ### Unstyled Mode (No Tailwind Required)
290
+
291
+ Pass `unstyled` to strip all built-in Tailwind classes and style components yourself:
292
+
293
+ ```tsx
294
+ <ChartDisplay
295
+ data={data}
296
+ charts={charts}
297
+ unstyled
298
+ className="my-charts-container"
299
+ chartClassName="my-chart-card"
300
+ titleClassName="my-chart-title"
301
+ />
302
+ ```
303
+
304
+ You can also pass `className` to any component to add classes alongside the built-in ones:
305
+
306
+ ```tsx
307
+ <ChartDisplay data={data} charts={charts} className="my-extra-class" />
308
+ ```
309
+
310
+ ### Headless Usage (No React)
311
+
312
+ The AI functions and CSV parsing work without React — use them in Node.js scripts, APIs, or CLI tools:
313
+
314
+ ```ts
315
+ import { parseCSV, analyzeData } from "csv-charts-ai";
316
+ import { readFileSync } from "fs";
317
+
318
+ const csv = readFileSync("sales.csv", "utf-8");
319
+ const data = parseCSV(csv);
320
+
321
+ const result = await analyzeData({
322
+ model: { apiKey: process.env.OPENAI_API_KEY!, model: "gpt-4o" },
323
+ data,
324
+ });
325
+
326
+ console.log(result.summary.keyInsights);
327
+ ```
328
+
329
+ ## Components Reference
111
330
 
112
331
  | Export | Description |
113
332
  |--------|-------------|
114
333
  | `ChartDisplay` | Multi-chart container with optional card wrapper and theme |
115
334
  | `SingleChart` | Individual chart with toolbar (sort, zoom, trendline, CSV/PNG export) |
116
335
  | `ChartToolbar` | Standalone toolbar component |
117
- | `processChartData` | Data processing utility with aggregation |
118
- | `COLORS` | Default color palette |
119
336
  | `ChartThemeProvider` | React context for chart theming |
120
337
  | `defaultDarkTheme` / `defaultLightTheme` | Built-in themes |
121
338
 
122
- ## AI Functions
339
+ ## AI Functions Reference
123
340
 
124
341
  | Export | Description |
125
342
  |--------|-------------|
126
343
  | `suggestCharts(options)` | Generate 2-4 chart suggestions from data |
127
344
  | `suggestCustomChart(options)` | Generate a single chart from a text prompt |
128
345
  | `repairChart(options)` | Fix a chart config that failed to render |
346
+ | `summarizeData(options)` | AI-generated data summary with key insights |
347
+ | `detectAnomalies(options)` | Find outliers, missing values, type mismatches |
348
+ | `askAboutData(options)` | Ask natural language questions about data |
349
+ | `streamAskAboutData(options)` | Streaming version of askAboutData |
350
+ | `suggestQuestions(options)` | Suggest interesting questions to ask about the data |
351
+ | `analyzeData(options)` | Full pipeline: summary + anomalies + charts in parallel |
352
+
353
+ ## Utilities Reference
354
+
355
+ | Export | Description |
356
+ |--------|-------------|
357
+ | `parseCSV(csv, options?)` | Parse CSV string into `TabularData` |
358
+ | `createModel(config)` | Create a LanguageModel from an AIConfig |
359
+ | `resolveModel(input)` | Resolve AIConfig or LanguageModel to LanguageModel |
360
+ | `summarizeTabularData(data)` | Generate text summary for AI consumption |
361
+ | `getAIErrorMessage(error)` | Extract user-friendly error messages |
362
+ | `processChartData(data, chart)` | Process and aggregate chart data |
363
+ | `processChartDataMultiSeries(data, chart)` | Multi-series data processing |
364
+ | `COLORS` | Default 8-color palette |
129
365
 
130
366
  ## Validation Schemas
131
367
 
132
368
  | Export | Description |
133
369
  |--------|-------------|
134
370
  | `AIConfigSchema` | Zod schema for validating AI config objects |
135
- | `TabularDataSchema` | Zod schema for validating tabular data input |
371
+ | `TabularDataSchema` | Zod schema for validating TabularData input |
136
372
 
137
373
  ## Chart Types
138
374
 
package/dist/index.d.ts CHANGED
@@ -52,6 +52,51 @@ interface ChartTheme {
52
52
  declare const defaultDarkTheme: ChartTheme;
53
53
  declare const defaultLightTheme: ChartTheme;
54
54
 
55
+ interface ParseCSVOptions {
56
+ /** Column delimiter. Auto-detected if omitted (supports , ; \t |). */
57
+ delimiter?: string;
58
+ /** Whether the first row is a header row (default: true). */
59
+ hasHeader?: boolean;
60
+ /** Skip empty lines (default: true). */
61
+ skipEmpty?: boolean;
62
+ }
63
+ /**
64
+ * Parse a CSV string into TabularData with automatic delimiter detection
65
+ * and column type inference.
66
+ *
67
+ * Handles quoted fields (RFC 4180), escaped quotes, and mixed line endings.
68
+ *
69
+ * @example
70
+ * ```ts
71
+ * import { parseCSV } from "csv-charts-ai";
72
+ *
73
+ * const data = parseCSV(`name,age,city
74
+ * Alice,30,"New York"
75
+ * Bob,25,Paris`);
76
+ *
77
+ * console.log(data.headers); // ["name", "age", "city"]
78
+ * console.log(data.rowCount); // 2
79
+ * console.log(data.columns); // [{ name: "name", type: "string", ... }, ...]
80
+ * ```
81
+ *
82
+ * @example
83
+ * ```ts
84
+ * // Auto-detects semicolon delimiter
85
+ * const data = parseCSV("nom;age;ville\nAlice;30;Paris");
86
+ *
87
+ * // Explicit delimiter
88
+ * const data = parseCSV(tsv, { delimiter: "\t" });
89
+ *
90
+ * // No header row
91
+ * const data = parseCSV(raw, { hasHeader: false });
92
+ * ```
93
+ *
94
+ * For very complex CSV files (multi-line quoted fields with nested newlines,
95
+ * exotic encodings), consider using PapaParse and passing the result as
96
+ * TabularData directly to the AI functions.
97
+ */
98
+ declare function parseCSV(csv: string, options?: ParseCSVOptions): TabularData;
99
+
55
100
  interface ChartDisplayProps {
56
101
  data: TabularData;
57
102
  charts: ChartConfig[];
@@ -64,15 +109,29 @@ interface ChartDisplayProps {
64
109
  }>;
65
110
  /** Optional theme override */
66
111
  theme?: ChartTheme;
112
+ /** Additional CSS class for the outer container */
113
+ className?: string;
114
+ /** Additional CSS class for each chart card */
115
+ chartClassName?: string;
116
+ /** Additional CSS class for chart title */
117
+ titleClassName?: string;
118
+ /** Additional CSS class for chart description */
119
+ descriptionClassName?: string;
120
+ /** When true, removes all built-in Tailwind classes. You must style everything yourself. */
121
+ unstyled?: boolean;
67
122
  }
68
- declare function ChartDisplay({ data, charts, onRegenerate, cardWrapper: CardWrapper, theme, }: ChartDisplayProps): react_jsx_runtime.JSX.Element | null;
123
+ declare function ChartDisplay({ data, charts, onRegenerate, cardWrapper: CardWrapper, theme, className, chartClassName, titleClassName, descriptionClassName, unstyled, }: ChartDisplayProps): react_jsx_runtime.JSX.Element | null;
69
124
 
70
125
  interface SingleChartProps {
71
126
  data: TabularData;
72
127
  chart: ChartConfig;
73
128
  onRegenerate?: (chart: ChartConfig) => Promise<void>;
129
+ /** Additional CSS class for the chart container */
130
+ className?: string;
131
+ /** When true, removes all built-in Tailwind classes from toolbar and metadata tags */
132
+ unstyled?: boolean;
74
133
  }
75
- declare function SingleChart({ data, chart, onRegenerate }: SingleChartProps): react_jsx_runtime.JSX.Element;
134
+ declare function SingleChart({ data, chart, onRegenerate, className, unstyled }: SingleChartProps): react_jsx_runtime.JSX.Element;
76
135
 
77
136
  interface ChartToolbarProps {
78
137
  chartType: ChartType;
@@ -89,8 +148,12 @@ interface ChartToolbarProps {
89
148
  onExportCSV: () => void;
90
149
  onExportPNG: () => void;
91
150
  onRegenerate: () => void;
151
+ /** Additional CSS class for the toolbar container */
152
+ className?: string;
153
+ /** When true, removes all built-in Tailwind classes */
154
+ unstyled?: boolean;
92
155
  }
93
- declare function ChartToolbar({ chartType, sortOrder, limitResults, showBrush, showTrendline, isRegenerating, hasRegenerate, onToggleSort, onLimitChange, onToggleBrush, onToggleTrendline, onExportCSV, onExportPNG, onRegenerate, }: ChartToolbarProps): react_jsx_runtime.JSX.Element;
156
+ declare function ChartToolbar({ chartType, sortOrder, limitResults, showBrush, showTrendline, isRegenerating, hasRegenerate, onToggleSort, onLimitChange, onToggleBrush, onToggleTrendline, onExportCSV, onExportPNG, onRegenerate, className, unstyled, }: ChartToolbarProps): react_jsx_runtime.JSX.Element;
94
157
 
95
158
  declare function ChartThemeProvider({ theme, children, }: {
96
159
  theme: ChartTheme;
@@ -173,6 +236,8 @@ interface SuggestChartsOptions {
173
236
  language?: string;
174
237
  /** Temperature for AI generation (default: 0.5) */
175
238
  temperature?: number;
239
+ /** AbortSignal to cancel the request */
240
+ signal?: AbortSignal;
176
241
  }
177
242
  interface SuggestCustomChartOptions {
178
243
  /** The AI model — either a simple config or a LanguageModel instance */
@@ -187,6 +252,8 @@ interface SuggestCustomChartOptions {
187
252
  language?: string;
188
253
  /** Temperature (default: 0.5) */
189
254
  temperature?: number;
255
+ /** AbortSignal to cancel the request */
256
+ signal?: AbortSignal;
190
257
  }
191
258
  interface RepairChartOptions {
192
259
  /** The AI model — either a simple config or a LanguageModel instance */
@@ -201,6 +268,8 @@ interface RepairChartOptions {
201
268
  language?: string;
202
269
  /** Temperature (default: 0.3) */
203
270
  temperature?: number;
271
+ /** AbortSignal to cancel the request */
272
+ signal?: AbortSignal;
204
273
  }
205
274
  /**
206
275
  * Generate chart suggestions from tabular data using AI.
@@ -282,6 +351,8 @@ interface SummarizeDataOptions {
282
351
  dataSummary?: string;
283
352
  language?: string;
284
353
  temperature?: number;
354
+ /** AbortSignal to cancel the request */
355
+ signal?: AbortSignal;
285
356
  }
286
357
  /**
287
358
  * Generate an AI summary of tabular data.
@@ -306,6 +377,8 @@ interface DetectAnomaliesOptions {
306
377
  maxRows?: number;
307
378
  language?: string;
308
379
  temperature?: number;
380
+ /** AbortSignal to cancel the request */
381
+ signal?: AbortSignal;
309
382
  }
310
383
  /**
311
384
  * Detect anomalies in tabular data using AI.
@@ -332,6 +405,8 @@ interface AskAboutDataOptions {
332
405
  }>;
333
406
  language?: string;
334
407
  temperature?: number;
408
+ /** AbortSignal to cancel the request */
409
+ signal?: AbortSignal;
335
410
  }
336
411
  /**
337
412
  * Ask a question about the data and get a text response.
@@ -347,9 +422,11 @@ interface AskAboutDataOptions {
347
422
  * ```
348
423
  */
349
424
  declare function askAboutData(options: AskAboutDataOptions): Promise<string>;
350
- interface StreamAskAboutDataOptions extends AskAboutDataOptions {
425
+ interface StreamAskAboutDataOptions extends Omit<AskAboutDataOptions, "signal"> {
351
426
  onChunk: (chunk: string) => void;
352
427
  onComplete: (fullText: string) => void;
428
+ /** AbortSignal to cancel the stream */
429
+ signal?: AbortSignal;
353
430
  }
354
431
  /**
355
432
  * Ask a question with streaming response.
@@ -375,6 +452,8 @@ interface AnalyzeOptions {
375
452
  detectAnomalies?: boolean;
376
453
  /** Set to false to skip chart suggestions (default: true) */
377
454
  suggestCharts?: boolean;
455
+ /** AbortSignal to cancel all parallel requests */
456
+ signal?: AbortSignal;
378
457
  }
379
458
  /**
380
459
  * Run a complete AI analysis on tabular data in one call.
@@ -397,5 +476,38 @@ interface AnalyzeOptions {
397
476
  * ```
398
477
  */
399
478
  declare function analyzeData(options: AnalyzeOptions): Promise<AnalysisResult>;
479
+ interface SuggestQuestionsOptions {
480
+ model: ModelInput;
481
+ data: TabularData;
482
+ dataSummary?: string;
483
+ language?: string;
484
+ /** Number of questions to suggest (default: 6) */
485
+ count?: number;
486
+ temperature?: number;
487
+ /** AbortSignal to cancel the request */
488
+ signal?: AbortSignal;
489
+ }
490
+ interface SuggestedQuestion {
491
+ question: string;
492
+ category: "trend" | "comparison" | "correlation" | "anomaly" | "insight";
493
+ }
494
+ /**
495
+ * Suggest interesting questions a user could ask about their data.
496
+ * Great for onboarding users who don't know where to start with their dataset.
497
+ *
498
+ * @example
499
+ * ```ts
500
+ * const questions = await suggestQuestions({
501
+ * model: { apiKey: "sk-...", model: "gpt-4o" },
502
+ * data: myData,
503
+ * });
504
+ *
505
+ * questions.forEach(q => console.log(`[${q.category}] ${q.question}`));
506
+ * // [trend] How has revenue changed over the last 6 months?
507
+ * // [comparison] Which product category generates the most revenue?
508
+ * // [correlation] Is there a relationship between price and quantity sold?
509
+ * ```
510
+ */
511
+ declare function suggestQuestions(options: SuggestQuestionsOptions): Promise<SuggestedQuestion[]>;
400
512
 
401
- export { type AIConfig, AIConfigSchema, type AggregationType, type AnalysisResult, type AnalyzeOptions, type AnomalyResult, type AskAboutDataOptions, COLORS, type ChartConfig, type ChartDataPoint, ChartDisplay, type ChartDisplayProps, type ChartTheme, ChartThemeProvider, ChartToolbar, type ChartType, type DataSummaryResult, type DetectAnomaliesOptions, type ModelInput, type ProcessedChartResult, type RepairChartOptions, SingleChart, type SingleChartProps, type SortOrder, type StreamAskAboutDataOptions, type SuggestChartsOptions, type SuggestCustomChartOptions, type SummarizeDataOptions, type TabularData, TabularDataSchema, VERSION, analyzeData, askAboutData, createModel, defaultDarkTheme, defaultLightTheme, detectAnomalies, getAIErrorMessage, processChartData, processChartDataMultiSeries, repairChart, resolveModel, streamAskAboutData, suggestCharts, suggestCustomChart, summarizeData, summarizeTabularData, useChartTheme };
513
+ export { type AIConfig, AIConfigSchema, type AggregationType, type AnalysisResult, type AnalyzeOptions, type AnomalyResult, type AskAboutDataOptions, COLORS, type ChartConfig, type ChartDataPoint, ChartDisplay, type ChartDisplayProps, type ChartTheme, ChartThemeProvider, ChartToolbar, type ChartType, type DataSummaryResult, type DetectAnomaliesOptions, type ModelInput, type ParseCSVOptions, type ProcessedChartResult, type RepairChartOptions, SingleChart, type SingleChartProps, type SortOrder, type StreamAskAboutDataOptions, type SuggestChartsOptions, type SuggestCustomChartOptions, type SuggestQuestionsOptions, type SuggestedQuestion, type SummarizeDataOptions, type TabularData, TabularDataSchema, VERSION, analyzeData, askAboutData, createModel, defaultDarkTheme, defaultLightTheme, detectAnomalies, getAIErrorMessage, parseCSV, processChartData, processChartDataMultiSeries, repairChart, resolveModel, streamAskAboutData, suggestCharts, suggestCustomChart, suggestQuestions, summarizeData, summarizeTabularData, useChartTheme };