Preswald now includes a simple way to embed an AI-powered chat interface directly into your data app. With one line of code, you can let users ask natural language questions about your data — and get back intelligent answers powered by LLMs.
It’s like having a built-in data copilot — no need to train a custom model or build a RAG pipeline from scratch.

What It Does
The new chat()
component turns any supported data source into a conversational interface. Here’s what happens under the hood:
-
You pass in a source (CSV, Postgres, or ClickHouse).
-
Preswald loads and summarizes the data.
-
That summary, plus the user’s question, gets sent to GPT.
-
The AI responds with answers based on the data context.
-
The conversation appears as a full chat widget in your UI.
Quick Example
from preswald import chat
chat(source="iris_csv")
Or, with a specific table in a database:
chat("pg_db", "earthquake_events")
Now your app has a fully working AI chat box that knows how to talk about your data — with zero additional setup.

What Can You Ask?
Once the widget is live, users can ask questions like:
-
“What are the top 5 rows by value?”
-
“Which columns have missing data?”
-
“Are there any trends in this time series?”
-
“Summarize the data grouped by category.”
The underlying system uses prompt engineering and metadata analysis to guide the model’s answers. It’s optimized for tabular data exploration, not general-purpose Q&A.
Supported Data Sources
The chat()
component works with any source defined in your preswald.toml
, including:
-
CSV (local or remote)
-
Postgres
-
ClickHouse
-
S3 CSV (from Day 3!)
Just use the same source name in your call to chat()
and you’re good to go.
When to Use This
This is great for:
-
🧪 Rapid prototyping of internal data tools
-
🤝 Stakeholders who prefer asking questions over writing SQL
-
🧠 Embedding smart defaults and insights in dashboards
-
🧰 Building copilots over structured data
You can still use all the standard Preswald components — this is additive, not a replacement.
Example App Snippet
from preswald import chat, text
text("# Earthquake Events Explorer")
chat("pg_db", "earthquake_events")
This will render a full chat box where the user can explore the contents of the earthquake_events
table — without writing queries.
Powered by the Community
This feature was contributed by Arnav Jaiswal, and builds on the broader trend of RAG-style tooling in structured data workflows.
Let me know when you’re ready for Day 5 — we’ll wrap up the week with GPU-powered static charts using Fastplotlib.