@deepagents/text2sql 0.8.0 → 0.9.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.
@@ -1 +1 @@
1
- {"version":3,"file":"info.postgres.grounding.d.ts","sourceRoot":"","sources":["../../../../src/lib/adapters/postgres/info.postgres.grounding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EACL,aAAa,EACb,KAAK,mBAAmB,EACzB,MAAM,iCAAiC,CAAC;AAEzC;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,aAAa;;gBAG1C,OAAO,EAAE,OAAO,EAAE,MAAM,GAAE,mBAAwB;cAKrC,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC;CAc7D"}
1
+ {"version":3,"file":"info.postgres.grounding.d.ts","sourceRoot":"","sources":["../../../../src/lib/adapters/postgres/info.postgres.grounding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EACL,aAAa,EACb,KAAK,mBAAmB,EACzB,MAAM,iCAAiC,CAAC;AAEzC;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,aAAa;;gBAG1C,OAAO,EAAE,OAAO,EAAE,MAAM,GAAE,mBAAwB;cAKrC,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC;CAiB7D"}
@@ -344,6 +344,47 @@ import {
344
344
  toState,
345
345
  user
346
346
  } from "@deepagents/agent";
347
+ var reportAgent = agent({
348
+ name: "db-report-agent",
349
+ model: groq("openai/gpt-oss-20b"),
350
+ prompt: () => dedent`
351
+ <identity>
352
+ You are a database analyst expert. Your job is to understand what
353
+ a database represents and provide business context about it.
354
+ You have READ-ONLY access to the database.
355
+ </identity>
356
+
357
+ <instructions>
358
+ Write a business context that helps another agent answer questions accurately.
359
+
360
+ For EACH table, do queries ONE AT A TIME:
361
+ 1. SELECT COUNT(*) to get row count
362
+ 2. SELECT * LIMIT 3 to see sample data
363
+
364
+ Then write a report with:
365
+ - What business this database is for
366
+ - For each table: purpose, row count, and example of what the data looks like
367
+
368
+ Include concrete examples like "Track prices are $0.99",
369
+ "Customer names like 'Luís Gonçalves'", etc.
370
+
371
+ Keep it 400-600 words, conversational style.
372
+ </instructions>
373
+ `,
374
+ tools: {
375
+ query_database: tool({
376
+ description: "Execute a SELECT query to explore the database and gather insights.",
377
+ inputSchema: z.object({
378
+ sql: z.string().describe("The SELECT query to execute"),
379
+ purpose: z.string().describe("What insight you are trying to gather with this query")
380
+ }),
381
+ execute: ({ sql }, options) => {
382
+ const state = toState(options);
383
+ return state.adapter.execute(sql);
384
+ }
385
+ })
386
+ }
387
+ });
347
388
  var ReportGrounding = class extends AbstractGrounding {
348
389
  #adapter;
349
390
  #model;
@@ -372,51 +413,8 @@ var ReportGrounding = class extends AbstractGrounding {
372
413
  return () => report2;
373
414
  }
374
415
  async #generateReport() {
375
- const reportAgent = agent({
376
- name: "db-report-agent",
377
- model: this.#model,
378
- prompt: () => dedent`
379
- <identity>
380
- You are a database analyst expert. Your job is to understand what
381
- a database represents and provide business context about it.
382
- You have READ-ONLY access to the database.
383
- </identity>
384
-
385
- <instructions>
386
- Write a business context that helps another agent answer questions accurately.
387
-
388
- For EACH table, do queries ONE AT A TIME:
389
- 1. SELECT COUNT(*) to get row count
390
- 2. SELECT * LIMIT 3 to see sample data
391
-
392
- Then write a report with:
393
- - What business this database is for
394
- - For each table: purpose, row count, and example of what the data looks like
395
-
396
- Include concrete examples like "Track prices are $0.99",
397
- "Customer names like 'Luís Gonçalves'", etc.
398
-
399
- Keep it 400-600 words, conversational style.
400
- </instructions>
401
- `,
402
- tools: {
403
- query_database: tool({
404
- description: "Execute a SELECT query to explore the database and gather insights.",
405
- inputSchema: z.object({
406
- sql: z.string().describe("The SELECT query to execute"),
407
- purpose: z.string().describe(
408
- "What insight you are trying to gather with this query"
409
- )
410
- }),
411
- execute: ({ sql }, options) => {
412
- const state = toState(options);
413
- return state.adapter.execute(sql);
414
- }
415
- })
416
- }
417
- });
418
416
  const { text } = await generate(
419
- reportAgent,
417
+ reportAgent.clone({ model: this.#model }),
420
418
  [
421
419
  user(
422
420
  "Please analyze the database and write a contextual report about what this database represents."
@@ -961,7 +959,10 @@ var SqliteInfoGrounding = class extends InfoGrounding {
961
959
  );
962
960
  return {
963
961
  dialect: "sqlite",
964
- version: rows[0]?.version
962
+ version: rows[0]?.version,
963
+ details: {
964
+ parameterPlaceholder: "?"
965
+ }
965
966
  };
966
967
  }
967
968
  };