@deepagents/text2sql 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3102 -0
- package/dist/index.js.map +7 -0
- package/dist/lib/adapters/adapter.d.ts +80 -0
- package/dist/lib/adapters/adapter.d.ts.map +1 -0
- package/dist/lib/adapters/postgres.d.ts +31 -0
- package/dist/lib/adapters/postgres.d.ts.map +1 -0
- package/dist/lib/adapters/resolveTables.spec.d.ts +2 -0
- package/dist/lib/adapters/resolveTables.spec.d.ts.map +1 -0
- package/dist/lib/adapters/sqlite.d.ts +30 -0
- package/dist/lib/adapters/sqlite.d.ts.map +1 -0
- package/dist/lib/adapters/sqlserver.d.ts +31 -0
- package/dist/lib/adapters/sqlserver.d.ts.map +1 -0
- package/dist/lib/agents/brief.agent.d.ts +16 -0
- package/dist/lib/agents/brief.agent.d.ts.map +1 -0
- package/dist/lib/agents/explainer.agent.d.ts +8 -0
- package/dist/lib/agents/explainer.agent.d.ts.map +1 -0
- package/dist/lib/agents/suggestions.agents.d.ts +16 -0
- package/dist/lib/agents/suggestions.agents.d.ts.map +1 -0
- package/dist/lib/agents/synthesizer.agent.d.ts +6 -0
- package/dist/lib/agents/synthesizer.agent.d.ts.map +1 -0
- package/dist/lib/agents/teachables.agent.d.ts +14 -0
- package/dist/lib/agents/teachables.agent.d.ts.map +1 -0
- package/dist/lib/agents/text2sql.agent.d.ts +38 -0
- package/dist/lib/agents/text2sql.agent.d.ts.map +1 -0
- package/dist/lib/history/history.d.ts +41 -0
- package/dist/lib/history/history.d.ts.map +1 -0
- package/dist/lib/history/memory.history.d.ts +5 -0
- package/dist/lib/history/memory.history.d.ts.map +1 -0
- package/dist/lib/history/sqlite.history.d.ts +15 -0
- package/dist/lib/history/sqlite.history.d.ts.map +1 -0
- package/dist/lib/memory/user-profile.d.ts +39 -0
- package/dist/lib/memory/user-profile.d.ts.map +1 -0
- package/dist/lib/prompt.d.ts +7 -0
- package/dist/lib/prompt.d.ts.map +1 -0
- package/dist/lib/sql.d.ts +52 -0
- package/dist/lib/sql.d.ts.map +1 -0
- package/dist/lib/teach/teachables.d.ts +462 -0
- package/dist/lib/teach/teachables.d.ts.map +1 -0
- package/dist/lib/teach/teachings.d.ts +4 -0
- package/dist/lib/teach/teachings.d.ts.map +1 -0
- package/dist/lib/teach/xml.d.ts +6 -0
- package/dist/lib/teach/xml.d.ts.map +1 -0
- package/package.json +38 -0
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
export interface Teachables {
|
|
2
|
+
type: 'term' | 'hint' | 'guardrail' | 'explain' | 'example' | 'clarification' | 'workflow' | 'quirk' | 'styleGuide' | 'analogy' | 'user_profile';
|
|
3
|
+
format: () => string;
|
|
4
|
+
}
|
|
5
|
+
export type GeneratedTeachable = {
|
|
6
|
+
type: 'term';
|
|
7
|
+
name: string;
|
|
8
|
+
definition: string;
|
|
9
|
+
} | {
|
|
10
|
+
type: 'hint';
|
|
11
|
+
text: string;
|
|
12
|
+
} | {
|
|
13
|
+
type: 'guardrail';
|
|
14
|
+
rule: string;
|
|
15
|
+
reason?: string;
|
|
16
|
+
action?: string;
|
|
17
|
+
} | {
|
|
18
|
+
type: 'explain';
|
|
19
|
+
concept: string;
|
|
20
|
+
explanation: string;
|
|
21
|
+
therefore?: string;
|
|
22
|
+
} | {
|
|
23
|
+
type: 'example';
|
|
24
|
+
question: string;
|
|
25
|
+
sql: string;
|
|
26
|
+
note?: string;
|
|
27
|
+
} | {
|
|
28
|
+
type: 'clarification';
|
|
29
|
+
when: string;
|
|
30
|
+
ask: string;
|
|
31
|
+
reason: string;
|
|
32
|
+
} | {
|
|
33
|
+
type: 'workflow';
|
|
34
|
+
task: string;
|
|
35
|
+
steps: string[];
|
|
36
|
+
triggers?: string[];
|
|
37
|
+
notes?: string;
|
|
38
|
+
} | {
|
|
39
|
+
type: 'quirk';
|
|
40
|
+
issue: string;
|
|
41
|
+
workaround: string;
|
|
42
|
+
} | {
|
|
43
|
+
type: 'styleGuide';
|
|
44
|
+
prefer: string;
|
|
45
|
+
never?: string;
|
|
46
|
+
always?: string;
|
|
47
|
+
} | {
|
|
48
|
+
type: 'analogy';
|
|
49
|
+
concept: string[];
|
|
50
|
+
relationship: string;
|
|
51
|
+
insight?: string;
|
|
52
|
+
therefore?: string;
|
|
53
|
+
pitfall?: string;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Teach the system domain-specific vocabulary and business terminology.
|
|
57
|
+
*
|
|
58
|
+
* Use this to define simple, direct mappings between business terms and their meanings.
|
|
59
|
+
* The system will understand these terms when users mention them in queries.
|
|
60
|
+
*
|
|
61
|
+
* @param name - The business term or acronym to define
|
|
62
|
+
* @param definition - What the term means in your domain
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* // Logistics/Transportation dataset
|
|
66
|
+
* term("deadhead miles", "distance driven with empty truck between deliveries")
|
|
67
|
+
* term("dwell time", "total time a truck spends at a loading dock or warehouse")
|
|
68
|
+
* term("LTL", "less than truckload - shipment that doesn't fill entire truck")
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* // Education/University dataset
|
|
72
|
+
* term("matriculation", "students who completed enrollment and started classes")
|
|
73
|
+
* term("DFW rate", "percentage of students receiving D, F, or Withdrawal in a course")
|
|
74
|
+
* term("cohort", "group of students who entered the same semester or academic year")
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* // Finance/Banking dataset
|
|
78
|
+
* term("NPL", "non-performing loan - loan past due 90+ days")
|
|
79
|
+
* term("basis points", "one hundredth of a percentage point (1% = 100 bps)")
|
|
80
|
+
* term("AUM", "assets under management - total market value of client investments")
|
|
81
|
+
*/
|
|
82
|
+
export declare function term(name: string, definition: string): Teachables;
|
|
83
|
+
/**
|
|
84
|
+
* Teach the system behavioral rules and constraints that should always apply.
|
|
85
|
+
*
|
|
86
|
+
* Use this for business logic, data quality rules, or query preferences that should
|
|
87
|
+
* be automatically applied to all relevant queries. Hints are injected as constraints
|
|
88
|
+
* in the system prompt.
|
|
89
|
+
*
|
|
90
|
+
* @param text - The rule or constraint to follow (use imperative language)
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* // Manufacturing/Supply Chain dataset
|
|
94
|
+
* hint("Always exclude work orders with status = 'simulation' from production metrics")
|
|
95
|
+
* hint("When calculating OEE (overall equipment effectiveness), only count scheduled production time")
|
|
96
|
+
* hint("Defect rates should be calculated per batch, not per individual unit, for consistency")
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* // Real Estate/Property dataset
|
|
100
|
+
* hint("Never include properties with listing_status = 'draft' in market analysis")
|
|
101
|
+
* hint("Always filter out duplicate MLS listings - use the earliest listing_date for each property_id")
|
|
102
|
+
* hint("Square footage comparisons must specify if including or excluding basement/garage")
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* // Social Media/Content Platform dataset
|
|
106
|
+
* hint("Engagement metrics should exclude bot accounts identified by is_verified_human = false")
|
|
107
|
+
* hint("View counts reset daily - always use cumulative_views for historical analysis")
|
|
108
|
+
* hint("Default content filters to published_status = 'public' unless analyzing drafts")
|
|
109
|
+
*/
|
|
110
|
+
export declare function hint(text: string): Teachables;
|
|
111
|
+
/**
|
|
112
|
+
* Define hard guardrails, safety rules, and compliance boundaries the system must enforce.
|
|
113
|
+
*
|
|
114
|
+
* Use this for "never do" rules, sensitive data handling, and required behaviors when
|
|
115
|
+
* certain conditions occur. Guardrails should be explicit and action oriented.
|
|
116
|
+
*
|
|
117
|
+
* @param input.rule - The guardrail or restriction to enforce
|
|
118
|
+
* @param input.reason - Why this guardrail exists (compliance, security, performance)
|
|
119
|
+
* @param input.action - What to do when this guardrail is triggered (block, ask, sanitize)
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* // Healthcare dataset
|
|
123
|
+
* guardrail({
|
|
124
|
+
* rule: "Never return PHI like SSN, MRN, or full address in query results",
|
|
125
|
+
* reason: "HIPAA compliance",
|
|
126
|
+
* action: "If asked, state that identifiable patient data cannot be shared; offer de-identified aggregates instead"
|
|
127
|
+
* })
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* // Finance dataset
|
|
131
|
+
* guardrail({
|
|
132
|
+
* rule: "Block any query exposing employee-level compensation by name",
|
|
133
|
+
* reason: "Confidential payroll data",
|
|
134
|
+
* action: "Provide ranges grouped by department or level instead of individual salaries"
|
|
135
|
+
* })
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* // E-commerce dataset
|
|
139
|
+
* guardrail({
|
|
140
|
+
* rule: "Warn when a query would scan more than 10 million rows; require a narrower date range",
|
|
141
|
+
* reason: "Performance and cost control",
|
|
142
|
+
* action: "Ask the user to add filters (recent timeframe, specific categories) before proceeding"
|
|
143
|
+
* })
|
|
144
|
+
*/
|
|
145
|
+
export declare function guardrail(input: {
|
|
146
|
+
rule: string;
|
|
147
|
+
reason?: string;
|
|
148
|
+
action?: string;
|
|
149
|
+
}): Teachables;
|
|
150
|
+
/**
|
|
151
|
+
* Teach the system a rich understanding of a single concept using metaphors and explanations.
|
|
152
|
+
*
|
|
153
|
+
* Use this when a simple term definition isn't enough - when you need to convey deeper
|
|
154
|
+
* understanding about how to think about and calculate a metric or concept.
|
|
155
|
+
*
|
|
156
|
+
* @param input.concept - The concept being explained
|
|
157
|
+
* @param input.explanation - A metaphor or detailed explanation (often using real-world comparisons)
|
|
158
|
+
* @param input.therefore - Optional actionable instruction based on this understanding
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* // Gaming/Entertainment dataset
|
|
162
|
+
* explain({
|
|
163
|
+
* concept: "daily active users to monthly active users ratio",
|
|
164
|
+
* explanation: "like measuring how many club members visit daily vs just once a month - shows stickiness",
|
|
165
|
+
* therefore: "Calculate as DAU / MAU, where higher ratio (closer to 1) means more engaged user base"
|
|
166
|
+
* })
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* // HR/Employee Management dataset
|
|
170
|
+
* explain({
|
|
171
|
+
* concept: "time to fill",
|
|
172
|
+
* explanation: "like measuring how long a house sits on the market - from posting job to accepting offer",
|
|
173
|
+
* therefore: "Calculate as days between job_posted_date and offer_accepted_date, exclude cancelled requisitions"
|
|
174
|
+
* })
|
|
175
|
+
*
|
|
176
|
+
* @example
|
|
177
|
+
* // Telecommunications dataset
|
|
178
|
+
* explain({
|
|
179
|
+
* concept: "network congestion ratio",
|
|
180
|
+
* explanation: "like rush hour traffic density - measures actual usage vs total capacity at peak times",
|
|
181
|
+
* therefore: "Calculate as (peak_hour_bandwidth_used / total_bandwidth_capacity) during busiest hour of day"
|
|
182
|
+
* })
|
|
183
|
+
*/
|
|
184
|
+
export declare function explain(input: {
|
|
185
|
+
concept: string;
|
|
186
|
+
explanation: string;
|
|
187
|
+
therefore?: string;
|
|
188
|
+
}): Teachables;
|
|
189
|
+
/**
|
|
190
|
+
* Teach the system through concrete examples of question → SQL pairs.
|
|
191
|
+
*
|
|
192
|
+
* Use this for few-shot learning - show the system exactly how to translate
|
|
193
|
+
* specific types of questions into SQL queries. Great for establishing patterns
|
|
194
|
+
* and handling domain-specific query structures.
|
|
195
|
+
*
|
|
196
|
+
* @param input.question - The natural language question or request
|
|
197
|
+
* @param input.sql - The correct SQL query that answers the question
|
|
198
|
+
* @param input.note - Optional note or explanation about the example
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* // Energy/Utilities dataset
|
|
202
|
+
* example({
|
|
203
|
+
* question: "show me peak demand hours for the last week",
|
|
204
|
+
* sql: "SELECT DATE_TRUNC('hour', reading_timestamp) as hour, MAX(consumption_kwh) as peak_demand FROM meter_readings WHERE reading_timestamp >= CURRENT_DATE - INTERVAL '7 days' GROUP BY hour ORDER BY peak_demand DESC LIMIT 10"
|
|
205
|
+
* })
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* // Agriculture/Farm Management dataset
|
|
209
|
+
* example({
|
|
210
|
+
* question: "what is the average yield per acre by crop type this season",
|
|
211
|
+
* sql: "SELECT crop_type, AVG(harvest_quantity / field_acres) as yield_per_acre FROM harvests WHERE harvest_date >= '2024-01-01' GROUP BY crop_type ORDER BY yield_per_acre DESC"
|
|
212
|
+
* })
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* // Travel/Hospitality dataset
|
|
216
|
+
* example({
|
|
217
|
+
* question: "show me hotel occupancy rate for this month",
|
|
218
|
+
* sql: "SELECT hotel_name, (SUM(occupied_rooms) / SUM(total_rooms)) * 100 as occupancy_rate FROM daily_occupancy WHERE date >= DATE_TRUNC('month', CURRENT_DATE) GROUP BY hotel_id, hotel_name ORDER BY occupancy_rate DESC",
|
|
219
|
+
* note: "Occupancy rate is a percentage - multiply by 100 for readable output"
|
|
220
|
+
* })
|
|
221
|
+
*/
|
|
222
|
+
export declare function example(input: {
|
|
223
|
+
question: string;
|
|
224
|
+
sql: string;
|
|
225
|
+
note?: string;
|
|
226
|
+
}): Teachables;
|
|
227
|
+
/**
|
|
228
|
+
* Teach the system when and what to ask for clarification.
|
|
229
|
+
*
|
|
230
|
+
* Use this to handle ambiguous terms or situations where the system should
|
|
231
|
+
* proactively ask the user for more information before generating a query.
|
|
232
|
+
* Makes the system more conversational and precise.
|
|
233
|
+
*
|
|
234
|
+
* @param input.when - The condition or trigger that should prompt clarification
|
|
235
|
+
* @param input.ask - The question to ask the user
|
|
236
|
+
* @param input.reason - Why this clarification is necessary (helps system understand importance)
|
|
237
|
+
*
|
|
238
|
+
* @example
|
|
239
|
+
* // Marketing/Advertising dataset
|
|
240
|
+
* clarification({
|
|
241
|
+
* when: "user asks for 'conversion rate'",
|
|
242
|
+
* ask: "Which conversion: click-to-lead, lead-to-opportunity, or opportunity-to-customer?",
|
|
243
|
+
* reason: "Conversion rate means different things at each funnel stage - need to specify which metric"
|
|
244
|
+
* })
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
* // Food Delivery dataset
|
|
248
|
+
* clarification({
|
|
249
|
+
* when: "user asks about 'delivery time'",
|
|
250
|
+
* ask: "Do you mean estimated time at order, actual delivery time, or time from kitchen to door?",
|
|
251
|
+
* reason: "Multiple time metrics exist - estimated vs actual impacts customer satisfaction differently"
|
|
252
|
+
* })
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* // Fitness/Gym Management dataset
|
|
256
|
+
* clarification({
|
|
257
|
+
* when: "user mentions 'active members'",
|
|
258
|
+
* ask: "Do you mean paid memberships or members who actually visited in last 30 days?",
|
|
259
|
+
* reason: "Many paid members don't use facilities - different metrics for revenue vs utilization"
|
|
260
|
+
* })
|
|
261
|
+
*/
|
|
262
|
+
export declare function clarification(input: {
|
|
263
|
+
when: string;
|
|
264
|
+
ask: string;
|
|
265
|
+
reason: string;
|
|
266
|
+
}): Teachables;
|
|
267
|
+
/**
|
|
268
|
+
* Teach the system multi-step analytical processes that can't be solved with a single query.
|
|
269
|
+
*
|
|
270
|
+
* Use this for complex analytical tasks that require multiple CTEs, sequential logic,
|
|
271
|
+
* or specific methodologies. Workflows teach the system HOW to approach a type of analysis.
|
|
272
|
+
*
|
|
273
|
+
* @param input.task - Name of the analytical task
|
|
274
|
+
* @param input.steps - Sequential steps to execute (can include SQL snippets or descriptions)
|
|
275
|
+
* @param input.triggers - Optional phrases that should activate this workflow
|
|
276
|
+
* @param input.notes - Optional additional context, warnings, or guidance
|
|
277
|
+
*
|
|
278
|
+
* @example
|
|
279
|
+
* // Insurance dataset
|
|
280
|
+
* workflow({
|
|
281
|
+
* task: "Claims Loss Ratio Analysis",
|
|
282
|
+
* triggers: ["loss ratio", "claims ratio", "underwriting performance"],
|
|
283
|
+
* steps: [
|
|
284
|
+
* "Calculate total claims paid for each policy period",
|
|
285
|
+
* "Calculate total premiums earned for same period",
|
|
286
|
+
* "Compute loss ratio as (claims_paid / premiums_earned) * 100",
|
|
287
|
+
* "Segment by policy type, geography, and underwriter",
|
|
288
|
+
* "Identify policies with loss ratio > 100% (losing money)",
|
|
289
|
+
* "Calculate trend over time using rolling 12-month windows"
|
|
290
|
+
* ],
|
|
291
|
+
* notes: "Use incurred date for claims, not paid date. Exclude reinsurance recoveries from claims total."
|
|
292
|
+
* })
|
|
293
|
+
*
|
|
294
|
+
* @example
|
|
295
|
+
* // Media/Publishing dataset
|
|
296
|
+
* workflow({
|
|
297
|
+
* task: "Content Performance Funnel",
|
|
298
|
+
* triggers: ["content funnel", "engagement funnel", "content performance"],
|
|
299
|
+
* steps: [
|
|
300
|
+
* "Count total impressions (articles shown) per content piece",
|
|
301
|
+
* "Count click-throughs (articles opened)",
|
|
302
|
+
* "Count scroll depth > 50% (meaningful engagement)",
|
|
303
|
+
* "Count shares, comments, or saves (viral actions)",
|
|
304
|
+
* "Calculate conversion rate at each funnel stage",
|
|
305
|
+
* "Identify top-performing content by final conversion rate"
|
|
306
|
+
* ],
|
|
307
|
+
* notes: "Requires multiple event types. Join events table multiple times or use conditional aggregation."
|
|
308
|
+
* })
|
|
309
|
+
*
|
|
310
|
+
* @example
|
|
311
|
+
* // Sports Analytics dataset
|
|
312
|
+
* workflow({
|
|
313
|
+
* task: "Player Performance Rating Calculation",
|
|
314
|
+
* triggers: ["player rating", "performance score", "player analytics"],
|
|
315
|
+
* steps: [
|
|
316
|
+
* "Aggregate per-game stats: points, assists, rebounds, turnovers",
|
|
317
|
+
* "Calculate efficiency metrics: shooting percentage, plus/minus",
|
|
318
|
+
* "Normalize each metric using z-scores vs league average",
|
|
319
|
+
* "Apply position-specific weights to each metric",
|
|
320
|
+
* "Combine weighted scores into overall performance rating (0-100)",
|
|
321
|
+
* "Rank players within position group and overall"
|
|
322
|
+
* ],
|
|
323
|
+
* notes: "Requires league-wide statistics for normalization. Update weights each season based on game trends."
|
|
324
|
+
* })
|
|
325
|
+
*/
|
|
326
|
+
export declare function workflow(input: {
|
|
327
|
+
task: string;
|
|
328
|
+
steps: string[];
|
|
329
|
+
triggers?: string[];
|
|
330
|
+
notes?: string;
|
|
331
|
+
}): Teachables;
|
|
332
|
+
/**
|
|
333
|
+
* Teach the system about data quirks, edge cases, or database-specific issues and their workarounds.
|
|
334
|
+
*
|
|
335
|
+
* Use this to document weird data patterns, database limitations, or special handling
|
|
336
|
+
* required for specific scenarios. Helps the system navigate real-world messiness.
|
|
337
|
+
*
|
|
338
|
+
* @param input.issue - Description of the quirk, edge case, or problem
|
|
339
|
+
* @param input.workaround - How to handle or work around this issue
|
|
340
|
+
*
|
|
341
|
+
* @example
|
|
342
|
+
* // Government/Public Services dataset
|
|
343
|
+
* quirk({
|
|
344
|
+
* issue: "Citizen IDs contain leading zeros but are stored as integers, losing the zeros",
|
|
345
|
+
* workaround: "Always cast to VARCHAR and use LPAD(citizen_id::VARCHAR, 10, '0') to restore leading zeros"
|
|
346
|
+
* })
|
|
347
|
+
*
|
|
348
|
+
* @example
|
|
349
|
+
* // Aviation dataset
|
|
350
|
+
* quirk({
|
|
351
|
+
* issue: "Flight times crossing midnight show as negative duration (landing before takeoff)",
|
|
352
|
+
* workaround: "Add 24 hours when calculated duration < 0: CASE WHEN duration < 0 THEN duration + INTERVAL '24 hours' ELSE duration END"
|
|
353
|
+
* })
|
|
354
|
+
*
|
|
355
|
+
* @example
|
|
356
|
+
* // Automotive/Dealership dataset
|
|
357
|
+
* quirk({
|
|
358
|
+
* issue: "VIN numbers with letter 'O' were incorrectly entered as zero '0' in legacy data",
|
|
359
|
+
* workaround: "When searching by VIN, use REPLACE(vin, '0', 'O') or fuzzy matching to handle both cases"
|
|
360
|
+
* })
|
|
361
|
+
*/
|
|
362
|
+
export declare function quirk(input: {
|
|
363
|
+
issue: string;
|
|
364
|
+
workaround: string;
|
|
365
|
+
}): Teachables;
|
|
366
|
+
/**
|
|
367
|
+
* Teach the system SQL style preferences and coding standards for generated queries.
|
|
368
|
+
*
|
|
369
|
+
* Use this to enforce consistent SQL formatting, naming conventions, and best practices
|
|
370
|
+
* specific to your team or organization. Improves readability and maintainability.
|
|
371
|
+
*
|
|
372
|
+
* @param input.prefer - Preferred SQL style or pattern
|
|
373
|
+
* @param input.never - Optional anti-pattern to avoid
|
|
374
|
+
* @param input.always - Optional rule that must always be followed
|
|
375
|
+
*
|
|
376
|
+
* @example
|
|
377
|
+
* // Non-profit/Charity dataset
|
|
378
|
+
* styleGuide({
|
|
379
|
+
* prefer: "Use donor-centric language in column aliases: 'donor_name' not 'customer_name'",
|
|
380
|
+
* never: "Never expose internal donor IDs in external reports - use public gift IDs",
|
|
381
|
+
* always: "Always include fiscal year in date-based aggregations (FY starts July 1)"
|
|
382
|
+
* })
|
|
383
|
+
*
|
|
384
|
+
* @example
|
|
385
|
+
* // Legal/Law Firm dataset
|
|
386
|
+
* styleGuide({
|
|
387
|
+
* prefer: "Use billable_hours with 2 decimal precision for accurate client billing",
|
|
388
|
+
* never: "Never include attorney_rate in queries visible to paralegals - confidential data",
|
|
389
|
+
* always: "Always filter by matter_status = 'open' unless specifically analyzing closed cases"
|
|
390
|
+
* })
|
|
391
|
+
*
|
|
392
|
+
* @example
|
|
393
|
+
* // Inventory/Warehouse dataset
|
|
394
|
+
* styleGuide({
|
|
395
|
+
* prefer: "Use location_id in joins rather than location_name (duplicates exist across warehouses)",
|
|
396
|
+
* never: "Never aggregate inventory without grouping by warehouse_id first",
|
|
397
|
+
* always: "Always use inventory_on_hand - inventory_reserved for available stock calculations"
|
|
398
|
+
* })
|
|
399
|
+
*/
|
|
400
|
+
export declare function styleGuide(input: {
|
|
401
|
+
prefer: string;
|
|
402
|
+
never?: string;
|
|
403
|
+
always?: string;
|
|
404
|
+
}): Teachables;
|
|
405
|
+
/**
|
|
406
|
+
* Teach the system by comparing related concepts through real-world analogies.
|
|
407
|
+
*
|
|
408
|
+
* Use this to teach relational understanding between two concepts by drawing comparisons
|
|
409
|
+
* to familiar real-world scenarios. Helps the system understand WHY concepts differ and
|
|
410
|
+
* when to use each one appropriately.
|
|
411
|
+
*
|
|
412
|
+
* @param input.concept - Array of two related concepts to compare
|
|
413
|
+
* @param input.relationship - The comparison/analogy using real-world examples
|
|
414
|
+
* @param input.insight - Optional key insight the analogy reveals
|
|
415
|
+
* @param input.therefore - Optional actionable instruction based on this understanding
|
|
416
|
+
* @param input.pitfall - Optional common mistake to avoid
|
|
417
|
+
*
|
|
418
|
+
* @example
|
|
419
|
+
* // E-commerce dataset
|
|
420
|
+
* analogy({
|
|
421
|
+
* concept: ["cart abandonment", "browse abandonment"],
|
|
422
|
+
* relationship: "Cart abandonment is like leaving items at a checkout counter, browse abandonment is like window shopping without picking anything up",
|
|
423
|
+
* insight: "Cart abandonment shows purchase intent (added to cart), browse abandonment shows only interest",
|
|
424
|
+
* therefore: "Prioritize cart abandonment recovery campaigns - higher conversion potential than browse",
|
|
425
|
+
* pitfall: "Don't combine both into generic 'abandonment rate' - they need different marketing strategies"
|
|
426
|
+
* })
|
|
427
|
+
*
|
|
428
|
+
* @example
|
|
429
|
+
* // SaaS dataset
|
|
430
|
+
* analogy({
|
|
431
|
+
* concept: ["logo churn", "revenue churn"],
|
|
432
|
+
* relationship: "Logo churn is like counting how many customers left the store, revenue churn is how much money walked out",
|
|
433
|
+
* insight: "Losing 10 small customers (high logo churn) might hurt less than losing 1 enterprise customer (high revenue churn)",
|
|
434
|
+
* therefore: "Always report both metrics - logo churn for customer satisfaction, revenue churn for financial health",
|
|
435
|
+
* pitfall: "Don't use logo churn to predict revenue impact - customer size distribution matters"
|
|
436
|
+
* })
|
|
437
|
+
*
|
|
438
|
+
* @example
|
|
439
|
+
* // Healthcare dataset
|
|
440
|
+
* analogy({
|
|
441
|
+
* concept: ["incident", "prevalence"],
|
|
442
|
+
* relationship: "Incidence is like new house sales this month, prevalence is total houses currently occupied",
|
|
443
|
+
* insight: "Incidence measures new cases over time, prevalence measures all existing cases at a point in time",
|
|
444
|
+
* therefore: "For tracking disease outbreaks use incidence rate, for resource planning use prevalence",
|
|
445
|
+
* pitfall: "Don't sum incidence rates across time periods - it's a rate not a count"
|
|
446
|
+
* })
|
|
447
|
+
*/
|
|
448
|
+
export declare function analogy(input: {
|
|
449
|
+
concept: string[];
|
|
450
|
+
relationship: string;
|
|
451
|
+
insight?: string;
|
|
452
|
+
therefore?: string;
|
|
453
|
+
pitfall?: string;
|
|
454
|
+
}): Teachables;
|
|
455
|
+
export declare function toInstructions(...teachables: Teachables[]): string;
|
|
456
|
+
export declare function toTeachables(generated: GeneratedTeachable[]): Teachables[];
|
|
457
|
+
export declare function userProfile(input: {
|
|
458
|
+
preferences: string;
|
|
459
|
+
identity: string;
|
|
460
|
+
working_context: string;
|
|
461
|
+
}): Teachables;
|
|
462
|
+
//# sourceMappingURL=teachables.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"teachables.d.ts","sourceRoot":"","sources":["../../../src/lib/teach/teachables.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,UAAU;IACzB,IAAI,EACA,MAAM,GACN,MAAM,GACN,WAAW,GACX,SAAS,GACT,SAAS,GACT,eAAe,GACf,UAAU,GACV,OAAO,GACP,YAAY,GACZ,SAAS,GACT,cAAc,CAAC;IACnB,MAAM,EAAE,MAAM,MAAM,CAAC;CACtB;AACD,MAAM,MAAM,kBAAkB,GAC1B;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAClD;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GACrE;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GACD;IAAE,IAAI,EAAE,SAA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GAiCG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,UAAU,CAWb;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE;IAC7B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,GAAG,UAAU,CAab;AAED,wBAAgB,cAAc,CAAC,GAAG,UAAU,EAAE,UAAU,EAAE,GAAG,MAAM,CAkClE;AAeD,wBAAgB,YAAY,CAAC,SAAS,EAAE,kBAAkB,EAAE,GAAG,UAAU,EAAE,CA2D1E;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;CACzB,GAAG,UAAU,CAOb"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"teachings.d.ts","sourceRoot":"","sources":["../../../src/lib/teach/teachings.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EAMhB,MAAM,iBAAiB,CAAC;wBA0DpB,UAAU,EAAE;AAxDjB,wBAwDkB"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function wrapBlock(tag: string, children: string[]): string;
|
|
2
|
+
export declare function list(tag: string, values: string[], childTag: string): string;
|
|
3
|
+
export declare function leaf(tag: string, value: string): string;
|
|
4
|
+
export declare function indentBlock(text: string, spaces: number): string;
|
|
5
|
+
export declare function escapeXml(value: string): string;
|
|
6
|
+
//# sourceMappingURL=xml.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xml.d.ts","sourceRoot":"","sources":["../../../src/lib/teach/xml.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,CAQjE;AAED,wBAAgB,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAM5E;AAED,wBAAgB,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAMvD;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAShE;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAO/C"}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@deepagents/text2sql",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
"./package.json": "./package.json",
|
|
10
|
+
".": {
|
|
11
|
+
"development": "./src/index.ts",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"!**/*.tsbuildinfo",
|
|
20
|
+
"!**/*.test.*"
|
|
21
|
+
],
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@ai-sdk/groq": "2.0.26",
|
|
27
|
+
"@deepagents/agent": "0.2.0",
|
|
28
|
+
"ai": "^5.0.65",
|
|
29
|
+
"autoevals": "^0.0.131",
|
|
30
|
+
"dedent": "1.7.0",
|
|
31
|
+
"zod": "^3.25.76 || ^4.0.0",
|
|
32
|
+
"evalite": "^0.19.0",
|
|
33
|
+
"@deepagents/toolbox": "0.2.0",
|
|
34
|
+
"pluralize": "^8.0.0",
|
|
35
|
+
"openai": "5.12.2",
|
|
36
|
+
"uuid": "^13.0.0"
|
|
37
|
+
}
|
|
38
|
+
}
|