GenkitG
Genkitโ€ข9mo ago
faint-white

@mbleigh Hi there again, I think there's

@mbleigh Hi there again, I think there's something weird with the new Genkit version (1.7.0, I was < 1.0.0 before) . I migrated the code by following the docs + Genkit source itself and here's what I got:
// init everything
...
// Prepare flow input and prompt input
export const AgentInput = z.object({
    userId: z.string(),
    sessionId: z.string(),
    request: z.string(),
});
export const TestRequest = ai.defineSchema(
    "TestRequest",
    z.object({
        request: z.string().nullable(),
        info: z.object({
            introduction: z.string(),
        }),
    })
);

export const testFlow = ai.defineFlow(
    {
        name: "testFlow",
        inputSchema: AgentInput,
        outputSchema: z.string()
    },
    async (input) => {
        const session = await ai.loadSession(input.sessionId, {
            store: new FirestoreSessionStore(),
        });
        const prompt = ai.prompt("test-prompt", {});
        const chat = session.chat(prompt, {
            model: 'gemini25ProExp0325',
            config: {
                temperature: 0.3,
            },
            input: {
                input: {
                    info: {
                        introduction: 'The introduction',
                    },
                }
            }
        });
        const {text} = await chat.send(input.request);
        return decodeHTML(text);
    }
);


Look at the chat method which takes ChatOptions "input" then again "input", otherwise the prompt doesn't render with the input data.
Was this page helpful?