Uzi (ꏿ﹏ꏿ;)U
Convex Community7mo ago
3 replies
Uzi (ꏿ﹏ꏿ;)

AI Agent: generateObject no longer working with schema

I have this action that uses an AI Agent:
export const generateEvent = action({
    args: { input: v.string() },
    handler: async (ctx, { input }): Promise<schemas.EventDetails> => {
        const { thread } = await eventGenerationAgent.createThread(ctx);
        const result = await thread.generateObject({
            prompt: input,
            schema: schemas.eventSchema
        });
        console.log(result);
        return agent.handleEventGenerationResponse({ result: result.object });
    },
});



And here is the prompt:
export const eventGenerationPrompt = `
    You are an event details parser.
    The current date is ${new Date().toLocaleDateString('en-GB', { weekday: 'long', day: 'numeric', month: 'long', year: 'numeric' })}.
    Extract event information from the user's input and format it as a JSON object with the following structure:
    {
        "title": "string - The event title",
        "description": "string - A detailed description of the event",
        "category": "string - Must be one of: 'Meetup', 'Workshop', 'Network', 'Social', 'Other'",
        "eventStart": "string - ISO date format (YYYY-MM-DDTHH:mm:ss)",
        "eventEnd": "string - ISO date format (YYYY-MM-DDTHH:mm:ss)",
        "spaces": "number - Maximum number of participants allowed"
    }

    Ensure all dates are in ISO format and the category matches one of the allowed values exactly.
    If you cannot determine any of the fields, put them as null.`;


When I run the action with this input:
{
  input: "I want to host a coding club with 20 members",
}

I get an error (see text file of next message).

I did not used to get this error which makes me think that OpenAI maybe changed their return format to include 'content', 'id' and 'role', but not too sure.
Was this page helpful?