@querypanel/node-sdk 1.0.50 → 1.0.52
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.cjs +15 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +50 -1
- package/dist/index.d.ts +50 -1
- package/dist/index.js +15 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -929,6 +929,8 @@ var QueryErrorCode = {
|
|
|
929
929
|
SQL_VALIDATION_FAILED: "SQL_VALIDATION_FAILED",
|
|
930
930
|
// Context retrieval errors
|
|
931
931
|
CONTEXT_RETRIEVAL_FAILED: "CONTEXT_RETRIEVAL_FAILED",
|
|
932
|
+
// Clarification errors (v2)
|
|
933
|
+
CLARIFICATION_NEEDED: "CLARIFICATION_NEEDED",
|
|
932
934
|
// General errors
|
|
933
935
|
INTERNAL_ERROR: "INTERNAL_ERROR",
|
|
934
936
|
AUTHENTICATION_REQUIRED: "AUTHENTICATION_REQUIRED",
|
|
@@ -965,6 +967,12 @@ var QueryPipelineError = class extends Error {
|
|
|
965
967
|
isGuardrailError() {
|
|
966
968
|
return this.isRelevanceError() || this.isSecurityError();
|
|
967
969
|
}
|
|
970
|
+
/**
|
|
971
|
+
* Check if this is a clarification needed error (v2 pipeline)
|
|
972
|
+
*/
|
|
973
|
+
isClarificationNeeded() {
|
|
974
|
+
return this.code === QueryErrorCode.CLARIFICATION_NEEDED;
|
|
975
|
+
}
|
|
968
976
|
};
|
|
969
977
|
|
|
970
978
|
// src/routes/charts.ts
|
|
@@ -1276,6 +1284,7 @@ async function ask(client, queryEngine, question, options, signal) {
|
|
|
1276
1284
|
let attempt = 0;
|
|
1277
1285
|
let lastError = options.lastError;
|
|
1278
1286
|
let previousSql = options.previousSql;
|
|
1287
|
+
const queryEndpoint = options.pipeline === "v2" ? "/v2/query" : "/query";
|
|
1279
1288
|
while (attempt <= maxRetry) {
|
|
1280
1289
|
console.log({ lastError, previousSql });
|
|
1281
1290
|
const databaseName = options.database ?? queryEngine.getDefaultDatabase();
|
|
@@ -1289,7 +1298,7 @@ async function ask(client, queryEngine, question, options, signal) {
|
|
|
1289
1298
|
};
|
|
1290
1299
|
}
|
|
1291
1300
|
const queryResponse = await client.postWithHeaders(
|
|
1292
|
-
|
|
1301
|
+
queryEndpoint,
|
|
1293
1302
|
{
|
|
1294
1303
|
question,
|
|
1295
1304
|
...querypanelSessionId ? { session_id: querypanelSessionId } : {},
|
|
@@ -1405,7 +1414,9 @@ async function ask(client, queryEngine, question, options, signal) {
|
|
|
1405
1414
|
context: queryResponse.data.context,
|
|
1406
1415
|
attempts: attempt + 1,
|
|
1407
1416
|
target_db: dbName,
|
|
1408
|
-
querypanelSessionId: responseSessionId ?? void 0
|
|
1417
|
+
querypanelSessionId: responseSessionId ?? void 0,
|
|
1418
|
+
intent: queryResponse.data.intent,
|
|
1419
|
+
trace: queryResponse.data.trace
|
|
1409
1420
|
};
|
|
1410
1421
|
} catch (error) {
|
|
1411
1422
|
attempt++;
|
|
@@ -1517,6 +1528,7 @@ async function modifyChart(client, queryEngine, input, options, signal) {
|
|
|
1517
1528
|
const hasSqlMods = !!input.sqlModifications;
|
|
1518
1529
|
const hasVizMods = !!input.vizModifications;
|
|
1519
1530
|
const hasCustomSql = !!input.sqlModifications?.customSql;
|
|
1531
|
+
const queryEndpoint = options?.pipeline === "v2" ? "/v2/query" : "/query";
|
|
1520
1532
|
let finalSql = input.sql;
|
|
1521
1533
|
let finalParams = input.params ?? {};
|
|
1522
1534
|
let paramMetadata = [];
|
|
@@ -1549,7 +1561,7 @@ async function modifyChart(client, queryEngine, input, options, signal) {
|
|
|
1549
1561
|
input.sqlModifications
|
|
1550
1562
|
);
|
|
1551
1563
|
const queryResponse = await client.post(
|
|
1552
|
-
|
|
1564
|
+
queryEndpoint,
|
|
1553
1565
|
{
|
|
1554
1566
|
question: modifiedQuestion,
|
|
1555
1567
|
previous_sql: input.sql,
|