Introduction #
Smart Q&A is SmartChart’s Text-to-SQL implementation. Users ask questions in natural language, the system first uses a routing agent to determine which business table the question belongs to, then the askdata skill dataset auto-generates SQL and queries the database, finally presenting results visually. The entire flow is implemented through two datasets (routing agent + Q&A skill) without additional programming frameworks.
Use Cases #
- Enter knowledge and data Q&A from homepage
Usage #
LLM connections are abstracted as data sources, see Basics -> First AI Scene
Agent development is abstracted as dataset development
- Create dataset, type: Agent, select LLM data source, name “Smart Q&A”
Based on user Q&A needs, respond as follows:
msg: Summarize user's Q&A need in no more than 100 words based on history
param:
- If asking about King of Glory, table is "smartdemo2", name is "Match Records"
- If asking about customer complaints, table is "smartdemo", name is "Lamp Complaint Table"
- If no relevant table, suggest what to ask
- If relevant table exists, respond strictly in JSON:
{"tool":"askdata","msg":"your summarized question","param":{"table":"table_name","name":"table_description"}}
## User question
$prompt
- Create “Q&A Scene” dataset, type: Skill, name: “askdata”
dataset={
"gpt":"smtgpt",
"question":"$prompt",
"table":"$table",
"name":"$name",
"vector":0
,"log":2
}
- question: User question
- table: Target table, view, or dataset ID
- name: Scene description
- vector: Vector relevance threshold (0-2), 0 disables vector
- log: Logging method
If you set specific table name and description, you can use the Q&A agent directly
Knowledge Base Technology #
To give LLM memory, introduce vector database queries
Vector database installation: see 7.AI Applications -> Vector Database
Smart Q&A Configuration Reference #
| Step | Dataset Type | Name | Purpose |
|---|---|---|---|
| 1 | Agent (LLM data source) | Custom (e.g., “Smart Q&A”) | Routing agent: determines which table, returns {"tool":"askdata",...} |
| 2 | Skill (same data source) | askdata |
Q&A skill: receives table name, question, auto-generates and executes SQL |
askdata dataset key config:
| Field | Description |
|---|---|
gpt |
LLM data source name (e.g., smtgpt) |
question |
User question, pass $prompt |
table |
Target data table name (passed by parent agent) |
name |
Business description of table, helps LLM understand data semantics |
vector |
Vector relevance threshold (0=no vector search) |
log |
Logging method (2=detailed) |