Closed IdoPesok closed 3 weeks ago
This is the intention of the Claude Chat template. This can be solved by changing the last message in the input to User. (or changing the order of the messages between the assistant and the user)
import { streamText } from "ai";
import { bedrock } from "@ai-sdk/amazon-bedrock";
const main = async () => {
try {
const { textStream } = await streamText({
model: bedrock("anthropic.claude-3-5-sonnet-20240620-v1:0"),
maxTokens: 10,
experimental_continueSteps: true,
maxSteps: 4,
messages: [
{
role: "assistant",
content: "okay, here is a long poem. on a cold December",
},
{
role: "user",
content: "write a poem",
},
],
});
for await (const v of textStream) {
console.log(v);
}
} catch (e) {
console.log("got error", e);
}
};
main();
Also Anthropic: trailing whitespace issue.
Same for Bedrock.
Description
Continue steps seems to break > 2 messages, or if you pass your own assistant message as the last message.
"ai": "^3.4.32"
"@ai-sdk/amazon-bedrock": "^0.0.34"
Code example
Additional context
got error ValidationException: A conversation must alternate between user and assistant roles. Make sure the conversation alternates between user and assistant roles and try again. at de_ValidationExceptionRes