@superatomai/sdk-node 0.0.68 → 0.0.70

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 CHANGED
@@ -3557,7 +3557,7 @@ function convertTopToLimit(query) {
3557
3557
  let modifiedQuery = query.replace(/\bSELECT\s+TOP\s+\(?\d+\)?\s*/gi, "SELECT ");
3558
3558
  return modifiedQuery;
3559
3559
  }
3560
- function ensureQueryLimit(query, defaultLimit = 10, maxLimit = 100, dbType) {
3560
+ function ensureQueryLimit(query, defaultLimit = 10, maxLimit = 10, dbType) {
3561
3561
  if (!query || query.trim().length === 0) {
3562
3562
  return query;
3563
3563
  }
@@ -6189,7 +6189,7 @@ Fixed SQL query:`;
6189
6189
  {
6190
6190
  model: this.getModelForTask("simple"),
6191
6191
  maxTokens: 2048,
6192
- temperature: 0.1,
6192
+ temperature: 0,
6193
6193
  apiKey: this.getApiKey(apiKey)
6194
6194
  }
6195
6195
  );
@@ -6435,12 +6435,13 @@ ${executedToolsText}`);
6435
6435
  },
6436
6436
  apiKey
6437
6437
  );
6438
+ const limitedFixedQuery = ensureQueryLimit(fixedQueryStr, this.defaultLimit, 10);
6438
6439
  if (typeof currentQuery === "string") {
6439
- currentQuery = fixedQueryStr;
6440
+ currentQuery = limitedFixedQuery;
6440
6441
  } else {
6441
- currentQuery = { ...currentQuery, sql: fixedQueryStr };
6442
+ currentQuery = { ...currentQuery, sql: limitedFixedQuery };
6442
6443
  }
6443
- currentQueryStr = fixedQueryStr;
6444
+ currentQueryStr = limitedFixedQuery;
6444
6445
  logger.info(`[${this.getProviderName()}] LLM provided fixed query for answer component, retrying...`);
6445
6446
  } catch (fixError) {
6446
6447
  const fixErrorMsg = fixError instanceof Error ? fixError.message : String(fixError);
@@ -6476,7 +6477,7 @@ ${executedToolsText}`);
6476
6477
  {
6477
6478
  model: this.getModelForTask("complex"),
6478
6479
  maxTokens: 8192,
6479
- temperature: 0.2,
6480
+ temperature: 0,
6480
6481
  apiKey: this.getApiKey(apiKey),
6481
6482
  partial: partialCallback
6482
6483
  },
@@ -6619,6 +6620,26 @@ ${executedToolsText}`);
6619
6620
  }
6620
6621
  }
6621
6622
  }
6623
+ if (cleanedProps.query) {
6624
+ if (typeof cleanedProps.query === "string") {
6625
+ cleanedProps.query = ensureQueryLimit(
6626
+ cleanedProps.query,
6627
+ this.defaultLimit,
6628
+ 10
6629
+ // maxLimit - enforce maximum of 10 rows for component queries
6630
+ );
6631
+ } else if (cleanedProps.query?.sql) {
6632
+ cleanedProps.query = {
6633
+ ...cleanedProps.query,
6634
+ sql: ensureQueryLimit(
6635
+ cleanedProps.query.sql,
6636
+ this.defaultLimit,
6637
+ 10
6638
+ // maxLimit - enforce maximum of 10 rows for component queries
6639
+ )
6640
+ };
6641
+ }
6642
+ }
6622
6643
  if (cleanedProps.query && cleanedProps.externalTool) {
6623
6644
  logger.info(`[${this.getProviderName()}] Both query and externalTool exist, keeping both - frontend will decide`);
6624
6645
  }
@@ -6739,11 +6760,12 @@ ${executedToolsText}`);
6739
6760
  );
6740
6761
  if (fixedQueryStr && fixedQueryStr !== currentQueryStr) {
6741
6762
  logger.info(`[${this.getProviderName()}] Received fixed query for ${component.name}, retrying...`);
6742
- currentQueryStr = fixedQueryStr;
6763
+ const limitedFixedQuery = ensureQueryLimit(fixedQueryStr, this.defaultLimit, 10);
6764
+ currentQueryStr = limitedFixedQuery;
6743
6765
  if (typeof currentQuery === "string") {
6744
- currentQuery = fixedQueryStr;
6766
+ currentQuery = limitedFixedQuery;
6745
6767
  } else {
6746
- currentQuery = { ...currentQuery, sql: fixedQueryStr };
6768
+ currentQuery = { ...currentQuery, sql: limitedFixedQuery };
6747
6769
  }
6748
6770
  } else {
6749
6771
  logger.warn(`[${this.getProviderName()}] LLM returned same or empty query, stopping retries`);
@@ -6871,7 +6893,7 @@ ${executedToolsText}`);
6871
6893
  {
6872
6894
  model: this.getModelForTask("simple"),
6873
6895
  maxTokens: 1500,
6874
- temperature: 0.2,
6896
+ temperature: 0,
6875
6897
  apiKey: this.getApiKey(apiKey)
6876
6898
  },
6877
6899
  true
@@ -6944,7 +6966,7 @@ ${executedToolsText}`);
6944
6966
  {
6945
6967
  model: this.getModelForTask("complex"),
6946
6968
  maxTokens: 8192,
6947
- temperature: 0.2,
6969
+ temperature: 0,
6948
6970
  apiKey: this.getApiKey(apiKey)
6949
6971
  },
6950
6972
  true
@@ -7265,7 +7287,7 @@ ${executedToolsText}`);
7265
7287
  let sql = toolInput.sql;
7266
7288
  const params = toolInput.params || {};
7267
7289
  const reasoning = toolInput.reasoning;
7268
- sql = ensureQueryLimit(sql, 10, 100);
7290
+ sql = ensureQueryLimit(sql, 10, 10);
7269
7291
  const queryKey = sql.toLowerCase().replace(/\s+/g, " ").trim();
7270
7292
  const attempts = (queryAttempts.get(queryKey) || 0) + 1;
7271
7293
  queryAttempts.set(queryKey, attempts);
@@ -7529,7 +7551,7 @@ ${errorMsg}
7529
7551
  {
7530
7552
  model: this.getModelForTask("complex"),
7531
7553
  maxTokens: 4e3,
7532
- temperature: 0.7,
7554
+ temperature: 0,
7533
7555
  apiKey: this.getApiKey(apiKey),
7534
7556
  partial: wrappedStreamCallback
7535
7557
  // Pass the wrapped streaming callback to LLM
@@ -7939,7 +7961,7 @@ ${errorMsg}
7939
7961
  {
7940
7962
  model: this.getModelForTask("simple"),
7941
7963
  maxTokens: 1200,
7942
- temperature: 0.7,
7964
+ temperature: 0,
7943
7965
  apiKey: this.getApiKey(apiKey)
7944
7966
  },
7945
7967
  true