orykevin
orykevin2mo ago

Agent Component to generateObject

Hi guys, I've tried the agent component, it's working on generate text, but not working when I tried to generateObject and when I want to pass a schema, it's throwing error because schema type is undefined, and when I try to generate the object and not using schema, I got this error : [Request ID: a8fb2413930d45cd] Server Error Uncaught ConvexError: Uncaught ConvexError: No agents added
No description
6 Replies
ian
ian2mo ago
Ah the types are off here. To generate an object today you have to set output: "object", but AI SDK has that as the default so you don't have to set it I'm not sure where "No agents added" is coming from - there isn't any error message like that in the component - is that in your code somewhere?
orykevin
orykevinOP2mo ago
Hi @ian , thanks for mention this, Silly me that is my error handle, I've use the generateObject and it's working, but I still do not find a way to fix the schema type error, so I give ts-ignore for now
No description
ian
ian2mo ago
does doing this fix it?
await thread.generateObject({
output: "object",
schema: z.object(...
await thread.generateObject({
output: "object",
schema: z.object(...
I also cut a fix so the output field isn't required for "object". It's in version @convex-dev/agent@0.0.9-alpha.1 if you want to give it a try
orykevin
orykevinOP2mo ago
Yes, it's working! Thanks. I didn't know that field was available because it wasn't suggested in typescript
ian
ian2mo ago
Would you mind confirming if it works for you in the alpha version without providing that field? I think it makes sense to not require it for the default object case
orykevin
orykevinOP2mo ago
Yep, thanks again, it's working without the output field after using the 0.0.9 alpha ver
No description

Did you find this page helpful?