#An assistant message with 'tool_calls' must be followed by tool messages responding to each 'tool_ca

1 messages · Page 1 of 1 (latest)

short meadow
#

I keep getting this error when i reply after the ai did a tool call. Am i missing something? Am i supposed to follow it up with something and if so how do i do that? None of the documentation states how or what to do about this situation. Aparently its happening somewhere in this code: ```js
switch (completion.choices[0].finish_reason) {
case "stop":
for (const chunk of utils.splitTextSync(
completion.choices[0].message.content
)) {
await message.channel.send(chunk);
}
break;
case "tool_calls":
const functions = [];
for (const func of completion.choices[0].message.tool_calls)
functions.push(func.function);

    for (const func of functions) {
      if (func.name === "generate_image") {
        //console.log(func);
        const image = await ai.generateImage(
          JSON.parse(func.arguments).prompt
        );
        await message.channel.send({
          embeds: [new EmbedBuilder().setImage(image.data[0].url)],
        });
      }
    }
    const followup = await ai.generateChatCompletion({
      messages: messages,
      model: "gpt-4-1106-preview",
      tools: tools,
    });
    break;
  case "content_filter":
    await message.reply(
      "Oh no! You triggered a content filter! Don't be bad next time :angry:!"
    );
    break;
}```
#

Please ping