Teachables
Teachables are domain-specific knowledge fragments that improve Text2SQL accuracy by teaching the AI about your business terminology, data quirks, and query patterns.What Are Teachables?
Teachables bridge the gap between generic SQL knowledge and your specific domain. They help the AI:- Understand business terms - Define domain-specific terminology
- Follow business rules - Enforce data access policies and guardrails
- Learn query patterns - Provide examples of common queries
- Handle edge cases - Document data quirks and workarounds
- Apply style preferences - Enforce SQL coding standards
Teachable Types
Text2SQL supports 10 teachable types from@deepagents/context:
1. term - Business Terminology
Define domain-specific abbreviations and jargon.
2. hint - Helpful Guidance
Provide context-aware hints for query generation.
3. guardrail - Safety Rules
Enforce data access policies and prevent dangerous queries.
4. example - Query Examples
Provide question-answer pairs for common queries.
5. explain - Concept Explanations
Explain technical concepts and their implications.
6. clarification - Ambiguity Triggers
Define when to ask for clarification instead of guessing.
7. workflow - Multi-Step Tasks
Define procedural workflows for complex tasks.
8. quirk - Data Anomalies
Document known data issues and workarounds.
9. styleGuide - SQL Coding Standards
Enforce SQL style preferences.
10. analogy - Conceptual Relationships
Explain relationships between concepts using analogies.
Using Teachables
Basic Usage
Pass teachables viateachingsOptions:
Organizing Teachables
For larger projects, organize teachables by domain:domain-knowledge.ts
Auto-Generating Teachables
Generate teachables automatically from your schema:Date Clarification Behavior
Control when the system asks for date clarification:'strict'- Ask user to clarify date ranges (production default)false- Assume all matching data without asking (useful for evals/benchmarks)
Example: Strict Mode
Example: Permissive Mode
Best Practices
1. Start Small
Begin with high-impact teachables:2. Validate with Examples
For each term or hint, add an example:3. Document Data Conventions
Capture implicit knowledge:4. Protect Sensitive Data
5. Handle Ambiguity
6. Version Your Teachables
Track teachables alongside schema versions:Teachables in Practice
Here’s a real-world example for a SaaS business:saas-teachables.ts
Next Steps
Conversational
Build multi-turn conversations
Explainability
SQL to English explanations
Teachables API
Full teachables API reference