@superatomai/sdk-node 0.0.54 → 0.0.56
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.js +68 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +68 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5405,6 +5405,19 @@ var LLM = class {
|
|
|
5405
5405
|
// src/userResponse/base-llm.ts
|
|
5406
5406
|
init_logger();
|
|
5407
5407
|
|
|
5408
|
+
// src/utils/datetime.ts
|
|
5409
|
+
function getCurrentDateTimeForPrompt() {
|
|
5410
|
+
return (/* @__PURE__ */ new Date()).toLocaleString("en-US", {
|
|
5411
|
+
weekday: "long",
|
|
5412
|
+
year: "numeric",
|
|
5413
|
+
month: "long",
|
|
5414
|
+
day: "numeric",
|
|
5415
|
+
hour: "2-digit",
|
|
5416
|
+
minute: "2-digit",
|
|
5417
|
+
timeZoneName: "short"
|
|
5418
|
+
});
|
|
5419
|
+
}
|
|
5420
|
+
|
|
5408
5421
|
// src/userResponse/knowledge-base.ts
|
|
5409
5422
|
init_logger();
|
|
5410
5423
|
var getKnowledgeBase = async ({
|
|
@@ -5885,7 +5898,8 @@ ${fieldsText}`;
|
|
|
5885
5898
|
SCHEMA_DOC: schemaDoc,
|
|
5886
5899
|
DATABASE_RULES: databaseRules,
|
|
5887
5900
|
DEFERRED_TOOLS: deferredToolsText,
|
|
5888
|
-
EXECUTED_TOOLS: executedToolsText
|
|
5901
|
+
EXECUTED_TOOLS: executedToolsText,
|
|
5902
|
+
CURRENT_DATETIME: getCurrentDateTimeForPrompt()
|
|
5889
5903
|
});
|
|
5890
5904
|
logger.debug(`[${this.getProviderName()}] Loaded match-text-components prompts`);
|
|
5891
5905
|
const systemPromptStr = Array.isArray(prompts.system) ? prompts.system.join("\n") : prompts.system;
|
|
@@ -6160,7 +6174,8 @@ ${executedToolsText}`);
|
|
|
6160
6174
|
USER_PROMPT: userPrompt,
|
|
6161
6175
|
CONVERSATION_HISTORY: conversationHistory || "No previous conversation",
|
|
6162
6176
|
AVAILABLE_TOOLS: availableToolsDoc,
|
|
6163
|
-
SCHEMA_DOC: schemaDoc || "No database schema available"
|
|
6177
|
+
SCHEMA_DOC: schemaDoc || "No database schema available",
|
|
6178
|
+
CURRENT_DATETIME: getCurrentDateTimeForPrompt()
|
|
6164
6179
|
});
|
|
6165
6180
|
const systemPrompt = Array.isArray(prompts.system) ? prompts.system.join("\n") : prompts.system;
|
|
6166
6181
|
const userPromptText = Array.isArray(prompts.user) ? prompts.user.join("\n") : prompts.user;
|
|
@@ -6227,7 +6242,8 @@ ${executedToolsText}`);
|
|
|
6227
6242
|
COMPONENT_PROPS: JSON.stringify(component.props, null, 2),
|
|
6228
6243
|
CACHED_TEXT_RESPONSE: cachedTextResponse || "No cached text response available",
|
|
6229
6244
|
SCHEMA_DOC: schemaDoc || "No schema available",
|
|
6230
|
-
DATABASE_RULES: databaseRules
|
|
6245
|
+
DATABASE_RULES: databaseRules,
|
|
6246
|
+
CURRENT_DATETIME: getCurrentDateTimeForPrompt()
|
|
6231
6247
|
});
|
|
6232
6248
|
const result = await LLM.stream(
|
|
6233
6249
|
{
|
|
@@ -6359,7 +6375,8 @@ ${executedToolsText}`);
|
|
|
6359
6375
|
SCHEMA_DOC: schemaDoc,
|
|
6360
6376
|
DATABASE_RULES: databaseRules,
|
|
6361
6377
|
KNOWLEDGE_BASE_CONTEXT: knowledgeBaseContext || "No additional knowledge base context available.",
|
|
6362
|
-
AVAILABLE_EXTERNAL_TOOLS: availableToolsDoc
|
|
6378
|
+
AVAILABLE_EXTERNAL_TOOLS: availableToolsDoc,
|
|
6379
|
+
CURRENT_DATETIME: getCurrentDateTimeForPrompt()
|
|
6363
6380
|
});
|
|
6364
6381
|
const sysPrompt = Array.isArray(prompts.system) ? prompts.system.join("\n") : prompts.system;
|
|
6365
6382
|
const usrPrompt = Array.isArray(prompts.user) ? prompts.user.join("\n") : prompts.user;
|
|
@@ -6481,6 +6498,32 @@ ${executedToolsText}`);
|
|
|
6481
6498
|
fullStreamedText += chunk;
|
|
6482
6499
|
streamCallback(chunk);
|
|
6483
6500
|
} : void 0;
|
|
6501
|
+
const withProgressHeartbeat = async (operation, progressMessage, intervalMs = 1e3) => {
|
|
6502
|
+
if (!wrappedStreamCallback) {
|
|
6503
|
+
return operation();
|
|
6504
|
+
}
|
|
6505
|
+
const startTime = Date.now();
|
|
6506
|
+
let dotCount = 0;
|
|
6507
|
+
const maxDots = 3;
|
|
6508
|
+
wrappedStreamCallback(`\u23F3 ${progressMessage}`);
|
|
6509
|
+
const heartbeatInterval = setInterval(() => {
|
|
6510
|
+
const elapsedSeconds = Math.floor((Date.now() - startTime) / 1e3);
|
|
6511
|
+
dotCount = (dotCount + 1) % (maxDots + 1);
|
|
6512
|
+
const dots = ".".repeat(dotCount || 1);
|
|
6513
|
+
if (elapsedSeconds >= 2) {
|
|
6514
|
+
wrappedStreamCallback(`${dots} (${elapsedSeconds}s)`);
|
|
6515
|
+
} else {
|
|
6516
|
+
wrappedStreamCallback(dots);
|
|
6517
|
+
}
|
|
6518
|
+
}, intervalMs);
|
|
6519
|
+
try {
|
|
6520
|
+
const result2 = await operation();
|
|
6521
|
+
return result2;
|
|
6522
|
+
} finally {
|
|
6523
|
+
clearInterval(heartbeatInterval);
|
|
6524
|
+
wrappedStreamCallback("\n\n");
|
|
6525
|
+
}
|
|
6526
|
+
};
|
|
6484
6527
|
const toolHandler = async (toolName, toolInput) => {
|
|
6485
6528
|
if (toolName === "execute_query") {
|
|
6486
6529
|
let sql = toolInput.sql;
|
|
@@ -6534,9 +6577,6 @@ Please try rephrasing your question or simplifying your request.
|
|
|
6534
6577
|
${sql}
|
|
6535
6578
|
\`\`\`${paramsDisplay}
|
|
6536
6579
|
|
|
6537
|
-
`);
|
|
6538
|
-
wrappedStreamCallback(`\u26A1 **Executing query...**
|
|
6539
|
-
|
|
6540
6580
|
`);
|
|
6541
6581
|
} else {
|
|
6542
6582
|
wrappedStreamCallback(`
|
|
@@ -6554,9 +6594,6 @@ ${sql}
|
|
|
6554
6594
|
${sql}
|
|
6555
6595
|
\`\`\`${paramsDisplay}
|
|
6556
6596
|
|
|
6557
|
-
`);
|
|
6558
|
-
wrappedStreamCallback(`\u26A1 **Executing query...**
|
|
6559
|
-
|
|
6560
6597
|
`);
|
|
6561
6598
|
}
|
|
6562
6599
|
}
|
|
@@ -6569,13 +6606,19 @@ ${sql}
|
|
|
6569
6606
|
throw new Error("Database collection not registered. Please register database.execute collection to execute queries.");
|
|
6570
6607
|
}
|
|
6571
6608
|
const queryPayload = Object.keys(params).length > 0 ? { sql: JSON.stringify({ sql, values: params }) } : { sql };
|
|
6572
|
-
const result2 = await
|
|
6609
|
+
const result2 = await withProgressHeartbeat(
|
|
6610
|
+
() => collections["database"]["execute"](queryPayload),
|
|
6611
|
+
"Executing database query",
|
|
6612
|
+
800
|
|
6613
|
+
// Send heartbeat every 800ms for responsive feedback
|
|
6614
|
+
);
|
|
6573
6615
|
const data = result2?.data || result2;
|
|
6574
6616
|
const rowCount = result2?.count ?? (Array.isArray(data) ? data.length : "N/A");
|
|
6575
6617
|
logger.info(`[${this.getProviderName()}] Query executed successfully, rows returned: ${rowCount}`);
|
|
6576
6618
|
logCollector?.info(`Query successful, returned ${rowCount} rows`);
|
|
6577
6619
|
if (wrappedStreamCallback) {
|
|
6578
|
-
wrappedStreamCallback(
|
|
6620
|
+
wrappedStreamCallback(`
|
|
6621
|
+
\u2705 **Query executed successfully!**
|
|
6579
6622
|
|
|
6580
6623
|
`);
|
|
6581
6624
|
if (Array.isArray(data) && data.length > 0) {
|
|
@@ -6662,7 +6705,12 @@ Please try rephrasing your request or contact support.
|
|
|
6662
6705
|
`);
|
|
6663
6706
|
}
|
|
6664
6707
|
}
|
|
6665
|
-
const result2 = await
|
|
6708
|
+
const result2 = await withProgressHeartbeat(
|
|
6709
|
+
() => externalTool.fn(toolInput),
|
|
6710
|
+
`Running ${externalTool.name}`,
|
|
6711
|
+
800
|
|
6712
|
+
// Send heartbeat every 800ms
|
|
6713
|
+
);
|
|
6666
6714
|
logger.info(`[${this.getProviderName()}] External tool ${externalTool.name} executed successfully`);
|
|
6667
6715
|
logCollector?.info(`\u2713 ${externalTool.name} executed successfully`);
|
|
6668
6716
|
if (!executedToolsList.find((t) => t.id === externalTool.id)) {
|
|
@@ -6764,6 +6812,7 @@ ${errorMsg}
|
|
|
6764
6812
|
}
|
|
6765
6813
|
);
|
|
6766
6814
|
if (wrappedStreamCallback && components && components.length > 0 && category !== "general") {
|
|
6815
|
+
wrappedStreamCallback("\n\n\u{1F4CA} **Generating visualization components...**\n\n");
|
|
6767
6816
|
wrappedStreamCallback("__TEXT_COMPLETE__COMPONENT_GENERATION_START__");
|
|
6768
6817
|
}
|
|
6769
6818
|
let matchedComponents = [];
|
|
@@ -7130,7 +7179,8 @@ ${errorMsg}
|
|
|
7130
7179
|
ORIGINAL_USER_PROMPT: originalUserPrompt,
|
|
7131
7180
|
COMPONENT_INFO: component_info,
|
|
7132
7181
|
COMPONENT_DATA: component_data,
|
|
7133
|
-
CONVERSATION_HISTORY: conversationHistory || "No previous conversation"
|
|
7182
|
+
CONVERSATION_HISTORY: conversationHistory || "No previous conversation",
|
|
7183
|
+
CURRENT_DATETIME: getCurrentDateTimeForPrompt()
|
|
7134
7184
|
});
|
|
7135
7185
|
const result = await LLM.stream(
|
|
7136
7186
|
{
|
|
@@ -11033,7 +11083,8 @@ async function pickComponentWithLLM(prompt, components, anthropicApiKey, groqApi
|
|
|
11033
11083
|
AVAILABLE_COMPONENTS: availableComponentsText,
|
|
11034
11084
|
SCHEMA_DOC: schemaDoc || "No database schema available",
|
|
11035
11085
|
DATABASE_RULES: databaseRules,
|
|
11036
|
-
AVAILABLE_TOOLS: availableToolsText
|
|
11086
|
+
AVAILABLE_TOOLS: availableToolsText,
|
|
11087
|
+
CURRENT_DATETIME: getCurrentDateTimeForPrompt()
|
|
11037
11088
|
});
|
|
11038
11089
|
logger.debug("[DASH_COMP_REQ] Loaded dash-comp-picker prompts with schema and tools");
|
|
11039
11090
|
const { apiKey, model } = getApiKeyAndModel(
|
|
@@ -11182,7 +11233,8 @@ async function createFilterWithLLM(prompt, components, existingComponents, anthr
|
|
|
11182
11233
|
EXISTING_COMPONENTS: formatExistingComponentsForPrompt(existingComponents),
|
|
11183
11234
|
SCHEMA_DOC: schemaDoc || "No database schema available",
|
|
11184
11235
|
DATABASE_RULES: databaseRules,
|
|
11185
|
-
AVAILABLE_TOOLS: formatToolsForPrompt(tools)
|
|
11236
|
+
AVAILABLE_TOOLS: formatToolsForPrompt(tools),
|
|
11237
|
+
CURRENT_DATETIME: getCurrentDateTimeForPrompt()
|
|
11186
11238
|
});
|
|
11187
11239
|
logger.debug("[DASH_COMP_REQ:FILTER] Loaded dash-filter-picker prompts");
|
|
11188
11240
|
const { apiKey, model } = getApiKeyAndModel(
|