@superatomai/sdk-node 0.0.3 → 0.0.4

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
@@ -2745,24 +2745,34 @@ var BaseLLM = class {
2745
2745
  if (classification.visualizations.length > 1) {
2746
2746
  const multiMsg = `Matching ${classification.visualizations.length} components for types: ${classification.visualizations.join(", ")}`;
2747
2747
  logCollector?.info(multiMsg);
2748
- const matchedComponents = [];
2749
- for (const vizType of classification.visualizations) {
2748
+ const componentPromises = classification.visualizations.map((vizType) => {
2750
2749
  logCollector?.info(`Matching component for type: ${vizType}`);
2751
- const result = await this.generateAnalyticalComponent(
2750
+ return this.generateAnalyticalComponent(
2752
2751
  userPrompt,
2753
2752
  components,
2754
2753
  vizType,
2755
2754
  apiKey,
2756
2755
  logCollector,
2757
2756
  conversationHistory
2758
- );
2759
- if (result.component) {
2760
- matchedComponents.push(result.component);
2761
- logCollector?.info(`Matched: ${result.component.name}`);
2757
+ ).then((result) => ({ vizType, result }));
2758
+ });
2759
+ const settledResults = await Promise.allSettled(componentPromises);
2760
+ const matchedComponents = [];
2761
+ for (const settledResult of settledResults) {
2762
+ if (settledResult.status === "fulfilled") {
2763
+ const { vizType, result } = settledResult.value;
2764
+ if (result.component) {
2765
+ matchedComponents.push(result.component);
2766
+ logCollector?.info(`Matched: ${result.component.name}`);
2767
+ logger.info("Component : ", result.component.name, " props: ", result.component.props);
2768
+ } else {
2769
+ logCollector?.warn(`Failed to match component for type: ${vizType}`);
2770
+ }
2762
2771
  } else {
2763
- logCollector?.warn(`Failed to match component for type: ${vizType}`);
2772
+ logCollector?.warn(`Error matching component: ${settledResult.reason?.message || "Unknown error"}`);
2764
2773
  }
2765
2774
  }
2775
+ console.log("matched components: after multi comp", matchedComponents.length);
2766
2776
  if (matchedComponents.length === 0) {
2767
2777
  return {
2768
2778
  component: null,
@@ -3098,6 +3108,7 @@ var UILogCollector = class {
3098
3108
  };
3099
3109
  this.logs.push(log);
3100
3110
  this.sendLogImmediately(log);
3111
+ console.log("UILogCollector:", log);
3101
3112
  }
3102
3113
  /**
3103
3114
  * Send a single log to runtime immediately
@@ -3285,15 +3296,17 @@ async function handleUserPromptRequest(data, components, sendMessage, anthropicA
3285
3296
  }, sendMessage, wsId);
3286
3297
  return;
3287
3298
  }
3288
- logCollector.info(`Starting user prompt request with ${components.length} components`);
3289
3299
  const threadManager = ThreadManager.getInstance();
3290
3300
  let thread = threadManager.getThread(threadId);
3291
3301
  if (!thread) {
3292
3302
  thread = threadManager.createThread(threadId);
3293
3303
  logger.info(`Created new thread: ${threadId}`);
3294
3304
  }
3305
+ logCollector.info(`Starting user prompt request with ${components.length} components`);
3295
3306
  const conversationHistory = thread.getConversationContext(CONTEXT_CONFIG.MAX_CONVERSATION_CONTEXT_BLOCKS, existingUiBlockId);
3307
+ logger.info("conversationHistory", conversationHistory);
3296
3308
  const userResponse = await get_user_response(prompt, components, anthropicApiKey, groqApiKey, llmProviders, logCollector, conversationHistory);
3309
+ logger.info("llm userResponse", userResponse);
3297
3310
  logCollector.info("User prompt request completed");
3298
3311
  if (userResponse.success && userResponse.data && typeof userResponse.data === "object" && "component" in userResponse.data) {
3299
3312
  const component = userResponse.data.component;
@@ -3336,6 +3349,7 @@ function sendDataResponse4(id, res, sendMessage, clientId) {
3336
3349
  ...res
3337
3350
  }
3338
3351
  };
3352
+ logger.info("sending user prompt response", response);
3339
3353
  sendMessage(response);
3340
3354
  }
3341
3355