From b46e1116329c2de88f3b1cd90def59ab38dbcad7 Mon Sep 17 00:00:00 2001 From: Daniel Lee Date: Thu, 6 Feb 2025 14:45:55 -0800 Subject: [PATCH 1/2] Desctructure streaming context for more idiomatic flow definition. --- Node/quickstarts/genkit-helloworld/functions/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Node/quickstarts/genkit-helloworld/functions/index.js b/Node/quickstarts/genkit-helloworld/functions/index.js index b93f2de667..43b1f9ab37 100644 --- a/Node/quickstarts/genkit-helloworld/functions/index.js +++ b/Node/quickstarts/genkit-helloworld/functions/index.js @@ -46,7 +46,7 @@ const jokeTeller = ai.defineFlow({ inputSchema: z.string().nullable(), outputSchema: z.string(), streamSchema: z.string(), -}, async (jokeType = "knock-knock", response) => { +}, async (jokeType = "knock-knock", { sendChunk }) => { const prompt = `Tell me a ${jokeType} joke.`; // Call the `generateStream()` method to @@ -56,7 +56,7 @@ const jokeTeller = ai.defineFlow({ // Send new words of the generative AI response // to the client as they're generated. for await (const chunk of stream) { - response.sendChunk(chunk.text); + sendChunk(chunk.text); } // Return the full generative AI response From ec2ed51d28f7ea8291202ed83cad3d0c8eb4ea8b Mon Sep 17 00:00:00 2001 From: Daniel Lee Date: Thu, 6 Feb 2025 16:30:59 -0800 Subject: [PATCH 2/2] Make linter happy. --- Node/quickstarts/genkit-helloworld/functions/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Node/quickstarts/genkit-helloworld/functions/index.js b/Node/quickstarts/genkit-helloworld/functions/index.js index 43b1f9ab37..a176bea669 100644 --- a/Node/quickstarts/genkit-helloworld/functions/index.js +++ b/Node/quickstarts/genkit-helloworld/functions/index.js @@ -46,7 +46,7 @@ const jokeTeller = ai.defineFlow({ inputSchema: z.string().nullable(), outputSchema: z.string(), streamSchema: z.string(), -}, async (jokeType = "knock-knock", { sendChunk }) => { +}, async (jokeType = "knock-knock", {sendChunk}) => { const prompt = `Tell me a ${jokeType} joke.`; // Call the `generateStream()` method to