@superatomai/sdk-node 0.0.78 → 0.0.79
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 +48 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +48 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -402,7 +402,8 @@ var UserQueryFiltersSchema = import_zod3.z.object({
|
|
|
402
402
|
username: import_zod3.z.string().optional(),
|
|
403
403
|
email: import_zod3.z.string().optional(),
|
|
404
404
|
role: import_zod3.z.string().optional(),
|
|
405
|
-
fullname: import_zod3.z.string().optional()
|
|
405
|
+
fullname: import_zod3.z.string().optional(),
|
|
406
|
+
id: import_zod3.z.number().optional()
|
|
406
407
|
});
|
|
407
408
|
var UsersRequestPayloadSchema = import_zod3.z.object({
|
|
408
409
|
operation: import_zod3.z.enum(["create", "update", "delete", "getAll", "getOne", "query"]),
|
|
@@ -12389,7 +12390,8 @@ async function pickComponentWithLLM(prompt, components, anthropicApiKey, groqApi
|
|
|
12389
12390
|
outputSchema: tool.outputSchema
|
|
12390
12391
|
});
|
|
12391
12392
|
logger.info(`[DASH_COMP_REQ] Tool ${tool.name} executed successfully`);
|
|
12392
|
-
|
|
12393
|
+
const resultJson = JSON.stringify(result2, null, 2);
|
|
12394
|
+
return resultJson + "\n\n[REMINDER: The above is tool output for verification. You MUST still respond with ONLY the JSON component selection object. Do NOT summarize or describe these results.]";
|
|
12393
12395
|
};
|
|
12394
12396
|
const result = await LLM.streamWithTools(
|
|
12395
12397
|
{
|
|
@@ -12407,18 +12409,59 @@ async function pickComponentWithLLM(prompt, components, anthropicApiKey, groqApi
|
|
|
12407
12409
|
5
|
|
12408
12410
|
// max iterations
|
|
12409
12411
|
);
|
|
12410
|
-
|
|
12411
|
-
|
|
12412
|
+
let jsonMatch = result.match(/\{[\s\S]*\}/);
|
|
12413
|
+
let parsedResult = jsonMatch ? (() => {
|
|
12414
|
+
try {
|
|
12415
|
+
return JSON.parse(jsonMatch[0]);
|
|
12416
|
+
} catch {
|
|
12417
|
+
return null;
|
|
12418
|
+
}
|
|
12419
|
+
})() : null;
|
|
12420
|
+
const isValidComponent = parsedResult && parsedResult.componentId && parsedResult.props;
|
|
12421
|
+
if (!isValidComponent && executedTools.length > 0) {
|
|
12422
|
+
const toolDataSummary = executedTools.map(
|
|
12423
|
+
(t) => `Tool "${t.name}" was called with params ${JSON.stringify(t.params)} and returned:
|
|
12424
|
+
${JSON.stringify(t.result, null, 2).substring(0, 5e3)}`
|
|
12425
|
+
).join("\n\n");
|
|
12426
|
+
const retryUserPrompt = `Original user request: ${prompt}
|
|
12427
|
+
|
|
12428
|
+
The following tool was already called and returned data:
|
|
12429
|
+
${toolDataSummary}
|
|
12430
|
+
|
|
12431
|
+
Using this data, select the appropriate component and respond with ONLY the JSON component selection object. No explanation, no markdown, just JSON.`;
|
|
12432
|
+
const retryResult = await LLM.text(
|
|
12433
|
+
{
|
|
12434
|
+
sys: prompts.system,
|
|
12435
|
+
user: retryUserPrompt
|
|
12436
|
+
},
|
|
12437
|
+
{
|
|
12438
|
+
model,
|
|
12439
|
+
maxTokens: 4096,
|
|
12440
|
+
temperature: 0.1,
|
|
12441
|
+
apiKey
|
|
12442
|
+
}
|
|
12443
|
+
);
|
|
12444
|
+
jsonMatch = retryResult.match(/\{[\s\S]*\}/);
|
|
12445
|
+
parsedResult = jsonMatch ? (() => {
|
|
12446
|
+
try {
|
|
12447
|
+
return JSON.parse(jsonMatch[0]);
|
|
12448
|
+
} catch {
|
|
12449
|
+
return null;
|
|
12450
|
+
}
|
|
12451
|
+
})() : null;
|
|
12452
|
+
}
|
|
12412
12453
|
if (!parsedResult) {
|
|
12413
12454
|
errors.push("Failed to parse LLM response as JSON");
|
|
12414
12455
|
errors.push(`LLM Response: ${result}`);
|
|
12456
|
+
logger.error(`[DASH_COMP_REQ] Failed to parse JSON from LLM response`);
|
|
12415
12457
|
return { success: false, errors };
|
|
12416
12458
|
}
|
|
12417
|
-
logger.
|
|
12459
|
+
logger.info(`[DASH_COMP_REQ] Parsed component: ${parsedResult.componentName} (${parsedResult.componentId})`);
|
|
12418
12460
|
logger.file("[DASH_COMP_REQ] LLM response:", JSON.stringify(parsedResult, null, 2));
|
|
12419
12461
|
if (!parsedResult.componentId || !parsedResult.props) {
|
|
12420
12462
|
errors.push("Invalid LLM response: missing componentId or props");
|
|
12421
12463
|
errors.push(`LLM Response: ${result}`);
|
|
12464
|
+
logger.error(`[DASH_COMP_REQ] Invalid structure - missing componentId: ${!parsedResult.componentId}, missing props: ${!parsedResult.props}`);
|
|
12422
12465
|
userPromptErrorLogger.logError("DASH_COMP_REQ", "Invalid LLM response structure", {
|
|
12423
12466
|
prompt,
|
|
12424
12467
|
result: parsedResult,
|