@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.mjs CHANGED
@@ -2728,24 +2728,34 @@ var BaseLLM = class {
2728
2728
  if (classification.visualizations.length > 1) {
2729
2729
  const multiMsg = `Matching ${classification.visualizations.length} components for types: ${classification.visualizations.join(", ")}`;
2730
2730
  logCollector?.info(multiMsg);
2731
- const matchedComponents = [];
2732
- for (const vizType of classification.visualizations) {
2731
+ const componentPromises = classification.visualizations.map((vizType) => {
2733
2732
  logCollector?.info(`Matching component for type: ${vizType}`);
2734
- const result = await this.generateAnalyticalComponent(
2733
+ return this.generateAnalyticalComponent(
2735
2734
  userPrompt,
2736
2735
  components,
2737
2736
  vizType,
2738
2737
  apiKey,
2739
2738
  logCollector,
2740
2739
  conversationHistory
2741
- );
2742
- if (result.component) {
2743
- matchedComponents.push(result.component);
2744
- logCollector?.info(`Matched: ${result.component.name}`);
2740
+ ).then((result) => ({ vizType, result }));
2741
+ });
2742
+ const settledResults = await Promise.allSettled(componentPromises);
2743
+ const matchedComponents = [];
2744
+ for (const settledResult of settledResults) {
2745
+ if (settledResult.status === "fulfilled") {
2746
+ const { vizType, result } = settledResult.value;
2747
+ if (result.component) {
2748
+ matchedComponents.push(result.component);
2749
+ logCollector?.info(`Matched: ${result.component.name}`);
2750
+ logger.info("Component : ", result.component.name, " props: ", result.component.props);
2751
+ } else {
2752
+ logCollector?.warn(`Failed to match component for type: ${vizType}`);
2753
+ }
2745
2754
  } else {
2746
- logCollector?.warn(`Failed to match component for type: ${vizType}`);
2755
+ logCollector?.warn(`Error matching component: ${settledResult.reason?.message || "Unknown error"}`);
2747
2756
  }
2748
2757
  }
2758
+ console.log("matched components: after multi comp", matchedComponents.length);
2749
2759
  if (matchedComponents.length === 0) {
2750
2760
  return {
2751
2761
  component: null,
@@ -3081,6 +3091,7 @@ var UILogCollector = class {
3081
3091
  };
3082
3092
  this.logs.push(log);
3083
3093
  this.sendLogImmediately(log);
3094
+ console.log("UILogCollector:", log);
3084
3095
  }
3085
3096
  /**
3086
3097
  * Send a single log to runtime immediately
@@ -3268,15 +3279,17 @@ async function handleUserPromptRequest(data, components, sendMessage, anthropicA
3268
3279
  }, sendMessage, wsId);
3269
3280
  return;
3270
3281
  }
3271
- logCollector.info(`Starting user prompt request with ${components.length} components`);
3272
3282
  const threadManager = ThreadManager.getInstance();
3273
3283
  let thread = threadManager.getThread(threadId);
3274
3284
  if (!thread) {
3275
3285
  thread = threadManager.createThread(threadId);
3276
3286
  logger.info(`Created new thread: ${threadId}`);
3277
3287
  }
3288
+ logCollector.info(`Starting user prompt request with ${components.length} components`);
3278
3289
  const conversationHistory = thread.getConversationContext(CONTEXT_CONFIG.MAX_CONVERSATION_CONTEXT_BLOCKS, existingUiBlockId);
3290
+ logger.info("conversationHistory", conversationHistory);
3279
3291
  const userResponse = await get_user_response(prompt, components, anthropicApiKey, groqApiKey, llmProviders, logCollector, conversationHistory);
3292
+ logger.info("llm userResponse", userResponse);
3280
3293
  logCollector.info("User prompt request completed");
3281
3294
  if (userResponse.success && userResponse.data && typeof userResponse.data === "object" && "component" in userResponse.data) {
3282
3295
  const component = userResponse.data.component;
@@ -3319,6 +3332,7 @@ function sendDataResponse4(id, res, sendMessage, clientId) {
3319
3332
  ...res
3320
3333
  }
3321
3334
  };
3335
+ logger.info("sending user prompt response", response);
3322
3336
  sendMessage(response);
3323
3337
  }
3324
3338