@deepagents/text2sql 0.38.0 → 0.38.1
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/README.md +10 -1
- package/dist/index.js +11 -9
- package/dist/index.js.map +2 -2
- package/dist/lib/sql.d.ts +8 -3
- package/dist/lib/sql.d.ts.map +1 -1
- package/package.json +6 -5
package/README.md
CHANGED
|
@@ -17,6 +17,15 @@ AI-powered natural language to SQL. Ask questions in plain English, get executab
|
|
|
17
17
|
npm install @deepagents/text2sql
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
+
Install the database driver or client library that matches your adapter:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install pg # PostgreSQL
|
|
24
|
+
npm install mssql # SQL Server
|
|
25
|
+
npm install mysql2 # MySQL / MariaDB
|
|
26
|
+
npm install @google-cloud/bigquery # BigQuery
|
|
27
|
+
```
|
|
28
|
+
|
|
20
29
|
Requires Node.js LTS (20+).
|
|
21
30
|
|
|
22
31
|
## Quick Start
|
|
@@ -187,7 +196,7 @@ Control what schema metadata the AI receives:
|
|
|
187
196
|
|
|
188
197
|
## Conversations
|
|
189
198
|
|
|
190
|
-
`chat()` persists history through the `ContextEngine` returned by your `context` factory. Reuse the same store, `chatId`, and `userId` to continue the same thread:
|
|
199
|
+
`chat()` persists history through the `ContextEngine` returned by your `context` factory. Reuse the same store, `chatId`, and `userId` to continue the same thread. Pass only the new incoming message(s) for the current turn; do not replay earlier turns that are already stored in the context store:
|
|
191
200
|
|
|
192
201
|
```typescript
|
|
193
202
|
const stream = await text2sql.chat([
|
package/dist/index.js
CHANGED
|
@@ -5392,22 +5392,24 @@ var Text2Sql = class {
|
|
|
5392
5392
|
const producer = factory(adapter);
|
|
5393
5393
|
return producer.toPairs();
|
|
5394
5394
|
}
|
|
5395
|
-
async chat(
|
|
5396
|
-
if (messages.length === 0) {
|
|
5397
|
-
throw new Error("messages must not be empty");
|
|
5398
|
-
}
|
|
5395
|
+
async chat(options) {
|
|
5399
5396
|
return createUIMessageStream({
|
|
5400
5397
|
execute: async ({ writer }) => {
|
|
5398
|
+
const context = this.#config.context;
|
|
5399
|
+
const head = await context.headMessage();
|
|
5400
|
+
if (!head || head.name !== "assistant") {
|
|
5401
|
+
throw new Error(
|
|
5402
|
+
"text2sql.chat: expected head to be an assistant message \u2014 call context.continue() before chat()"
|
|
5403
|
+
);
|
|
5404
|
+
}
|
|
5405
|
+
writer.write({ type: "start", messageId: head.id });
|
|
5401
5406
|
const progress = (event) => {
|
|
5402
5407
|
writer.write({
|
|
5403
5408
|
type: TEXT2SQL_INDEX_PROGRESS_CHUNK,
|
|
5404
5409
|
data: event
|
|
5405
5410
|
});
|
|
5406
5411
|
};
|
|
5407
|
-
|
|
5408
|
-
...guidelines(),
|
|
5409
|
-
...await this.#index(progress)
|
|
5410
|
-
);
|
|
5412
|
+
context.set(...guidelines(), ...await this.#index(progress));
|
|
5411
5413
|
const chatAgent = agent2({
|
|
5412
5414
|
name: "text2sql",
|
|
5413
5415
|
sandbox: this.#config.sandbox,
|
|
@@ -5417,7 +5419,7 @@ var Text2Sql = class {
|
|
|
5417
5419
|
guardrails: [errorRecoveryGuardrail],
|
|
5418
5420
|
maxGuardrailRetries: 3
|
|
5419
5421
|
});
|
|
5420
|
-
const chatStream = await chat(chatAgent,
|
|
5422
|
+
const chatStream = await chat(chatAgent, {
|
|
5421
5423
|
abortSignal: options?.abortSignal,
|
|
5422
5424
|
generateTitle: options?.generateTitle,
|
|
5423
5425
|
transform: this.#config.transform
|