CSV Insight Lab
Paste or upload CSV (max 50 rows) - parse locally, then generateObject insights and chartReady aggregates without inventing rows.
Run this experiment yourself
Demos are not embedded on this site. Deploy a standalone copy on Vercel or run the experiment app locally.
Local development
cd apps/experiments/csv-insight-lab pnpm install pnpm dev
Then open http://localhost:3010.
This is an experimental demo. Use it as a starting point for your own projects.
CSV Insight Lab parses CSV in logic.ts (max 50 data rows), builds chartReady aggregates from numeric columns, then calls generateObject for insights grounded only in those rows. The model is instructed never to invent rows. Missing AI keys return 503.
Features
- Local CSV parse – quoted fields, row cap.
- chartReady aggregates – from parsed numeric columns only.
- Insights + caveats – generateObject schema.
- Sample sales CSV – product / units / revenue.
- Honest
503when AI is unavailable.
Server Reference
POST /api/insights
JSON { "csv": "..." } or multipart with csv + optional file.
Success (200)
{
"insights": ["Units peak on Blob Drop"],
"caveats": ["Only 5 rows"],
"chartReady": [{ "label": "Blob Drop", "value": 200 }],
"rowCount": 5,
"provider": "ai-gateway"
}| Status | Cause |
|---|---|
503 | No AI provider |
400 | Missing header/data rows |
Implementation Details
parseCsv + numericColumnAggregates
Pure helpers; aggregates never invent values.
generateObject
Prompt includes the parsed preview only.
Use Cases
- Learn composition patterns for this lab’s stack.
- Prototype before wiring production auth and quotas.
- Deploy the standalone app as a reference implementation.
Limitations
- Demo-scale caps on input size and output counts.
- No auth / rate limits on public deploys.
- Model quality depends on input clarity.
Use in your project
Copy the Route Handler and logic.ts helpers from apps/experiments/csv-insight-lab/. Wire your own persistence and auth as needed.
Deployment
Local Development
cd apps/experiments/csv-insight-lab
pnpm install
pnpm devConfiguration
| Variable | Required | Purpose |
|---|---|---|
AI_GATEWAY_API_KEY | Yes (or OPENAI_API_KEY) | Preferred provider |
OPENAI_API_KEY | No | Fallback |
AI_MODEL | No | Model override |
Vercel / Next.js Features Used
- AI SDK
generateObject - Route Handlers
- Zod