Teachings Generator
Current guidance for building schema-aware fragment bundles
The current public Text2SQL package does not export a TeachingsGenerator class
or a text2sql.teach() convenience method. If you want schema-aware fragment
bundles today, use one of the supported patterns below.
Option 1: Build a Manual Fragment Bundle
Create a fragment array with the domain terms, hints, guardrails, and examples you want to keep stable:
import { example, guardrail, hint, term } from '@deepagents/context';
const teachings = [
term('NPL', 'non-performing loan - loan past due 90+ days'),
hint("Always exclude accounts where account_type = 'test'"),
guardrail({
rule: 'Never expose full account numbers',
reason: 'Sensitive financial data',
action: 'Return masked or aggregated results instead',
}),
example({
question: 'show me delinquent loans by region',
answer: `SELECT region, COUNT(*) AS delinquent_loans
FROM loans
WHERE days_past_due >= 30
GROUP BY region
ORDER BY delinquent_loans DESC`,
}),
];Set this array on your ContextEngine for chat(), or pass it to the
lower-level toSql({ fragments }) helper for direct SQL generation.
Option 2: Feed Teachings into SchemaSynthesizer
If you are generating synthetic training data, SchemaSynthesizer accepts a
teachings array directly:
import { SchemaSynthesizer } from '@deepagents/text2sql/synthesis';
const pairs = await new SchemaSynthesizer(adapter, {
count: 10,
complexity: 'medium',
teachings,
}).toPairs();Suggested Workflow
- Start with a small manual bundle based on real product terminology.
- Test it against
chat()or the low-leveltoSql({ fragments })helper. - Refine vague or noisy teachings before reusing them in synthesis pipelines.
- Promote stable bundles into recipe files once they prove useful.
What Changed
Older docs referenced a TeachingsGenerator class and text2sql.teach()
method. Those surfaces are not part of the current public API, so the supported
workflow is manual fragment bundles plus synthesis-time teachings injection.