@superatomai/sdk-node 0.0.16 → 0.0.17

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
@@ -3451,6 +3451,26 @@ var BaseLLM = class {
3451
3451
  getApiKey(apiKey) {
3452
3452
  return apiKey || this.apiKey || this.getDefaultApiKey();
3453
3453
  }
3454
+ /**
3455
+ * Check if a component contains a Form (data_modification component)
3456
+ * Forms have hardcoded defaultValues that become stale when cached
3457
+ * This checks both single Form components and Forms inside MultiComponentContainer
3458
+ */
3459
+ containsFormComponent(component) {
3460
+ if (!component) return false;
3461
+ if (component.type === "Form" || component.name === "DynamicForm") {
3462
+ return true;
3463
+ }
3464
+ if (component.type === "Container" || component.name === "MultiComponentContainer") {
3465
+ const nestedComponents = component.props?.config?.components || [];
3466
+ for (const nested of nestedComponents) {
3467
+ if (nested.type === "Form" || nested.name === "DynamicForm") {
3468
+ return true;
3469
+ }
3470
+ }
3471
+ }
3472
+ return false;
3473
+ }
3454
3474
  /**
3455
3475
  * Match components from text response suggestions and generate follow-up questions
3456
3476
  * Takes a text response with component suggestions (c1:type format) and matches with available components
@@ -4325,9 +4345,15 @@ ${errorMsg}
4325
4345
  logCollector?.info(
4326
4346
  `\u2713 Found similar conversation (${(conversationMatch.similarity * 100).toFixed(2)}% match)`
4327
4347
  );
4328
- const component = conversationMatch.uiBlock?.component || conversationMatch.uiBlock?.generatedComponentMetadata;
4348
+ const rawComponent = conversationMatch.uiBlock?.component || conversationMatch.uiBlock?.generatedComponentMetadata;
4349
+ const isValidComponent = rawComponent && typeof rawComponent === "object" && Object.keys(rawComponent).length > 0;
4350
+ const component = isValidComponent ? rawComponent : null;
4329
4351
  const cachedTextResponse = conversationMatch.uiBlock?.analysis || conversationMatch.uiBlock?.textResponse || conversationMatch.uiBlock?.text || "";
4330
- if (!component) {
4352
+ logger.debug(`[${this.getProviderName()}] Cached component: ${component ? "present" : "null"}, cachedTextResponse: ${cachedTextResponse ? cachedTextResponse.substring(0, 50) + "..." : "empty"}`);
4353
+ if (this.containsFormComponent(component)) {
4354
+ logger.info(`[${this.getProviderName()}] Skipping cached result - Form components contain stale defaultValues, fetching fresh data`);
4355
+ logCollector?.info("Skipping cache for form - fetching current values from database...");
4356
+ } else if (!component) {
4331
4357
  if (conversationMatch.similarity >= 0.99) {
4332
4358
  const elapsedTime2 = Date.now() - startTime;
4333
4359
  logger.info(`[${this.getProviderName()}] \u2713 Exact match for general question - returning cached text response`);