#getting error when creating new analysis with thread and assistant

1 messages · Page 1 of 1 (latest)

quaint crown
#

I'm trying to create a memory for a script I have that runs every minute with threads, the code i have is this:

async function analyzeBatchImages(screenshots) {
  try {
    if (!threadId || !assistantId) {
      throw new Error("Assistant or thread not initialized.");
    }

    const data = JSON.parse(fs.readFileSync(ASSISTANT_DATA_FILE, "utf-8"));
    const prompt = data.prompt;

    if (!screenshots || !Array.isArray(screenshots) || screenshots.length === 0) {
      throw new Error("Invalid screenshots array provided.");
    }

    const content = [
      { type: "text", text: `${prompt}\nAnalyze these screenshots for trading insights.` },
      ...screenshots.map((screenshot) => ({
        type: "image_url",
        image_url: { url: screenshot.imageUrl },
      })),
    ];

    console.log("Thread ID:", threadId);
    console.log("Assistant ID:", assistantId);
    console.log("Message Content:", content);

    await openai.beta.threads.messages.create(threadId, {
      role: "user",
      content,
    });

    console.log("Running thread analysis...");

    const run = await openai.beta.threads.runs.create({
      thread_id: threadId,
      assistant_id: assistantId,
    });

    const analysis = run.steps
      .map((step) => step.step_details.content)
      .join("\n");

    console.log("OpenAI Response:", analysis);
    return analysis;
  } catch (error) {
    console.error("Error analyzing batch images with OpenAI:", error.message);
    throw error;
  }
}

I provide the assistant ID and thread ID from the state file and I pass the message that contains this:

Message Content: [
  {
    type: 'text',
    text: ''************************'
  },
  {
    type: 'image_url',
    image_url: {
      url: '************************'
    }
  },
  {
    type: 'image_url',
    image_url: {
      url: ''************************''
    }
  }

the error I get is this: Cannot destructure property 'include' of 'params' as it is undefined
not sure what is happening