DaddyIsHere
DaddyIsHere4d ago

thread.`generateText/streamText` returns a validator error

Heya guys, I'm new! I am building a small chat app with Convex Agents and I've encountered an error that I don't seem to be able to solve:
const response = await thread.generateText(
{
prompt: `# From Notes:\n\n ${contextText}\n\n---\n\n# User Prompt:\n\n"""${message}\n"""`,
},
);
const response = await thread.generateText(
{
prompt: `# From Notes:\n\n ${contextText}\n\n---\n\n# User Prompt:\n\n"""${message}\n"""`,
},
);
OR
const response = await thread.streamText(
{
prompt: `# From Notes:\n\n ${contextText}\n\n---\n\n# User Prompt:\n\n"""${message}\n"""`,
},
{
saveStreamDeltas: true, // PROBLEMATIC LINE
},
);
await response.consumeStream();
const response = await thread.streamText(
{
prompt: `# From Notes:\n\n ${contextText}\n\n---\n\n# User Prompt:\n\n"""${message}\n"""`,
},
{
saveStreamDeltas: true, // PROBLEMATIC LINE
},
);
await response.consumeStream();
These functions (even with just {message} and not the whole prompt) are giving me the errors in the screenshots, ONLY if I actually save the message in the database. If I pass saveMessages: "none" and/or saveStreamDeltas: false the problem goes away (but streaming doesn't work and the whole flow is generally slower). Can you help me understand what the problem is? 🙏🏽 (I can give you more context if needed!)
No description
No description
1 Reply
ampp
ampp3d ago
#agents its hard to tell exactly without seeing a lot of code, but there are many examples in the agents folder that should show nearly everything. #2 is passing a array when expecting a string looks like. so you could pass the first item in the array to see what you get etc.

Did you find this page helpful?