@superatomai/sdk-node 0.0.60 → 0.0.62
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.d.mts +39 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.js +87 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +87 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2494,7 +2494,13 @@ var ArtifactsRequestPayloadSchema = z3.object({
|
|
|
2494
2494
|
limit: z3.number().optional(),
|
|
2495
2495
|
// Query operation fields
|
|
2496
2496
|
filters: ArtifactsQueryFiltersSchema.optional(),
|
|
2497
|
-
sort: z3.enum(["ASC", "DESC"]).optional()
|
|
2497
|
+
sort: z3.enum(["ASC", "DESC"]).optional(),
|
|
2498
|
+
// Menu grouping fields
|
|
2499
|
+
type: z3.string().optional(),
|
|
2500
|
+
menuId: z3.number().optional(),
|
|
2501
|
+
artifactGroupName: z3.string().optional(),
|
|
2502
|
+
artifactGroupId: z3.string().optional(),
|
|
2503
|
+
artifactGroupIcon: z3.string().optional()
|
|
2498
2504
|
}).optional()
|
|
2499
2505
|
});
|
|
2500
2506
|
var ArtifactsRequestMessageSchema = z3.object({
|
|
@@ -2571,7 +2577,9 @@ var MenusRequestPayloadSchema = z3.object({
|
|
|
2571
2577
|
items: z3.array(z3.object({
|
|
2572
2578
|
id: z3.number(),
|
|
2573
2579
|
sortOrder: z3.number()
|
|
2574
|
-
})).optional()
|
|
2580
|
+
})).optional(),
|
|
2581
|
+
menuJson: z3.record(z3.unknown()).optional(),
|
|
2582
|
+
version: z3.number().optional()
|
|
2575
2583
|
}).optional()
|
|
2576
2584
|
});
|
|
2577
2585
|
var MenusRequestMessageSchema = z3.object({
|
|
@@ -5952,6 +5960,7 @@ var BaseLLM = class {
|
|
|
5952
5960
|
this.defaultLimit = config?.defaultLimit || 50;
|
|
5953
5961
|
this.apiKey = config?.apiKey;
|
|
5954
5962
|
this.modelStrategy = config?.modelStrategy || "fast";
|
|
5963
|
+
this.conversationSimilarityThreshold = config?.conversationSimilarityThreshold || 0.8;
|
|
5955
5964
|
}
|
|
5956
5965
|
/**
|
|
5957
5966
|
* Get the appropriate model based on task type and model strategy
|
|
@@ -5984,6 +5993,26 @@ var BaseLLM = class {
|
|
|
5984
5993
|
getModelStrategy() {
|
|
5985
5994
|
return this.modelStrategy;
|
|
5986
5995
|
}
|
|
5996
|
+
/**
|
|
5997
|
+
* Set the conversation similarity threshold at runtime
|
|
5998
|
+
* @param threshold - Value between 0 and 1 (e.g., 0.8 = 80% similarity required)
|
|
5999
|
+
*/
|
|
6000
|
+
setConversationSimilarityThreshold(threshold) {
|
|
6001
|
+
if (threshold < 0 || threshold > 1) {
|
|
6002
|
+
logger.warn(`[${this.getProviderName()}] Invalid threshold ${threshold}, must be between 0 and 1. Using default 0.8`);
|
|
6003
|
+
this.conversationSimilarityThreshold = 0.8;
|
|
6004
|
+
return;
|
|
6005
|
+
}
|
|
6006
|
+
this.conversationSimilarityThreshold = threshold;
|
|
6007
|
+
logger.info(`[${this.getProviderName()}] Conversation similarity threshold set to: ${threshold}`);
|
|
6008
|
+
}
|
|
6009
|
+
/**
|
|
6010
|
+
* Get the current conversation similarity threshold
|
|
6011
|
+
* @returns The current threshold value
|
|
6012
|
+
*/
|
|
6013
|
+
getConversationSimilarityThreshold() {
|
|
6014
|
+
return this.conversationSimilarityThreshold;
|
|
6015
|
+
}
|
|
5987
6016
|
/**
|
|
5988
6017
|
* Get the API key (from instance, parameter, or environment)
|
|
5989
6018
|
*/
|
|
@@ -7285,8 +7314,7 @@ ${errorMsg}
|
|
|
7285
7314
|
userPrompt,
|
|
7286
7315
|
collections,
|
|
7287
7316
|
userId,
|
|
7288
|
-
similarityThreshold:
|
|
7289
|
-
// 80% threshold
|
|
7317
|
+
similarityThreshold: this.conversationSimilarityThreshold
|
|
7290
7318
|
});
|
|
7291
7319
|
if (conversationMatch) {
|
|
7292
7320
|
logger.info(`[${this.getProviderName()}] \u2713 Found matching conversation with ${(conversationMatch.similarity * 100).toFixed(2)}% similarity`);
|
|
@@ -10551,6 +10579,7 @@ async function handleArtifactsRequest(data, collections, sendMessage) {
|
|
|
10551
10579
|
const request = ArtifactsRequestMessageSchema.parse(data);
|
|
10552
10580
|
const { id, payload, from } = request;
|
|
10553
10581
|
const { operation, data: requestData } = payload;
|
|
10582
|
+
logger.info("[SDK-NODEJS] Received artifacts request:", JSON.stringify({ operation, requestData }, null, 2));
|
|
10554
10583
|
const artifactId = requestData?.id;
|
|
10555
10584
|
const name = requestData?.name;
|
|
10556
10585
|
const createdBy = requestData?.createdBy;
|
|
@@ -10560,9 +10589,22 @@ async function handleArtifactsRequest(data, collections, sendMessage) {
|
|
|
10560
10589
|
const limit = requestData?.limit;
|
|
10561
10590
|
const filters = requestData?.filters;
|
|
10562
10591
|
const sort = requestData?.sort;
|
|
10592
|
+
const type = requestData?.type;
|
|
10593
|
+
const menuId = requestData?.menuId;
|
|
10594
|
+
const artifactGroupName = requestData?.artifactGroupName;
|
|
10595
|
+
const artifactGroupId = requestData?.artifactGroupId;
|
|
10596
|
+
const artifactGroupIcon = requestData?.artifactGroupIcon;
|
|
10597
|
+
logger.info("[SDK-NODEJS] Extracted params for create:", JSON.stringify({
|
|
10598
|
+
name,
|
|
10599
|
+
type,
|
|
10600
|
+
menuId,
|
|
10601
|
+
artifactGroupName,
|
|
10602
|
+
artifactGroupId,
|
|
10603
|
+
artifactGroupIcon
|
|
10604
|
+
}, null, 2));
|
|
10563
10605
|
switch (operation) {
|
|
10564
10606
|
case "create":
|
|
10565
|
-
await handleCreate6(id, name, createdBy, dsl, status, executeCollection, sendMessage, from.id);
|
|
10607
|
+
await handleCreate6(id, name, createdBy, dsl, status, type, menuId, artifactGroupName, artifactGroupId, artifactGroupIcon, executeCollection, sendMessage, from.id);
|
|
10566
10608
|
break;
|
|
10567
10609
|
case "update":
|
|
10568
10610
|
await handleUpdate6(id, artifactId, name, dsl, status, deleted, executeCollection, sendMessage, from.id);
|
|
@@ -10593,7 +10635,7 @@ async function handleArtifactsRequest(data, collections, sendMessage) {
|
|
|
10593
10635
|
}, sendMessage);
|
|
10594
10636
|
}
|
|
10595
10637
|
}
|
|
10596
|
-
async function handleCreate6(id, name, createdBy, dsl, status, executeCollection, sendMessage, clientId) {
|
|
10638
|
+
async function handleCreate6(id, name, createdBy, dsl, status, type, menuId, artifactGroupName, artifactGroupId, artifactGroupIcon, executeCollection, sendMessage, clientId) {
|
|
10597
10639
|
if (!name) {
|
|
10598
10640
|
sendResponse8(id, {
|
|
10599
10641
|
success: false,
|
|
@@ -10602,7 +10644,17 @@ async function handleCreate6(id, name, createdBy, dsl, status, executeCollection
|
|
|
10602
10644
|
return;
|
|
10603
10645
|
}
|
|
10604
10646
|
try {
|
|
10605
|
-
const result = await executeCollection("artifacts", "create", {
|
|
10647
|
+
const result = await executeCollection("artifacts", "create", {
|
|
10648
|
+
name,
|
|
10649
|
+
createdBy,
|
|
10650
|
+
dsl,
|
|
10651
|
+
status,
|
|
10652
|
+
type,
|
|
10653
|
+
menuId,
|
|
10654
|
+
artifactGroupName,
|
|
10655
|
+
artifactGroupId,
|
|
10656
|
+
artifactGroupIcon
|
|
10657
|
+
});
|
|
10606
10658
|
sendResponse8(id, {
|
|
10607
10659
|
success: true,
|
|
10608
10660
|
data: result.data,
|
|
@@ -12842,8 +12894,10 @@ var SuperatomSDK = class {
|
|
|
12842
12894
|
this.llmProviders = config.LLM_PROVIDERS || getLLMProviders();
|
|
12843
12895
|
this.databaseType = config.databaseType || "postgresql";
|
|
12844
12896
|
this.modelStrategy = config.modelStrategy || "fast";
|
|
12897
|
+
this.conversationSimilarityThreshold = config.conversationSimilarityThreshold ?? 0.8;
|
|
12845
12898
|
this.applyModelStrategy(this.modelStrategy);
|
|
12846
|
-
|
|
12899
|
+
this.applyConversationSimilarityThreshold(this.conversationSimilarityThreshold);
|
|
12900
|
+
logger.info(`Initializing Superatom SDK v${SDK_VERSION} for project ${this.projectId}, llm providers: ${this.llmProviders.join(", ")}, database type: ${this.databaseType}, model strategy: ${this.modelStrategy}, conversation similarity threshold: ${this.conversationSimilarityThreshold}`);
|
|
12847
12901
|
this.userManager = new UserManager(this.projectId, 5e3);
|
|
12848
12902
|
this.dashboardManager = new DashboardManager(this.projectId);
|
|
12849
12903
|
this.reportManager = new ReportManager(this.projectId);
|
|
@@ -13256,6 +13310,31 @@ var SuperatomSDK = class {
|
|
|
13256
13310
|
getModelStrategy() {
|
|
13257
13311
|
return this.modelStrategy;
|
|
13258
13312
|
}
|
|
13313
|
+
/**
|
|
13314
|
+
* Apply conversation similarity threshold to all LLM provider singletons
|
|
13315
|
+
* @param threshold - Value between 0 and 1 (e.g., 0.8 = 80% similarity required)
|
|
13316
|
+
*/
|
|
13317
|
+
applyConversationSimilarityThreshold(threshold) {
|
|
13318
|
+
anthropicLLM.setConversationSimilarityThreshold(threshold);
|
|
13319
|
+
groqLLM.setConversationSimilarityThreshold(threshold);
|
|
13320
|
+
geminiLLM.setConversationSimilarityThreshold(threshold);
|
|
13321
|
+
openaiLLM.setConversationSimilarityThreshold(threshold);
|
|
13322
|
+
logger.info(`Conversation similarity threshold '${threshold}' applied to all LLM providers`);
|
|
13323
|
+
}
|
|
13324
|
+
/**
|
|
13325
|
+
* Set conversation similarity threshold at runtime
|
|
13326
|
+
* @param threshold - Value between 0 and 1 (e.g., 0.8 = 80% similarity required)
|
|
13327
|
+
*/
|
|
13328
|
+
setConversationSimilarityThreshold(threshold) {
|
|
13329
|
+
this.conversationSimilarityThreshold = threshold;
|
|
13330
|
+
this.applyConversationSimilarityThreshold(threshold);
|
|
13331
|
+
}
|
|
13332
|
+
/**
|
|
13333
|
+
* Get current conversation similarity threshold
|
|
13334
|
+
*/
|
|
13335
|
+
getConversationSimilarityThreshold() {
|
|
13336
|
+
return this.conversationSimilarityThreshold;
|
|
13337
|
+
}
|
|
13259
13338
|
};
|
|
13260
13339
|
export {
|
|
13261
13340
|
BM25L,
|