Skip to content

Commit c8ed5fa

Browse files
authored
Desctructure streaming context for more idiomatic flow definition (#1191)
1 parent b970fee commit c8ed5fa

File tree

1 file changed

+2
-2
lines changed
  • Node/quickstarts/genkit-helloworld/functions

1 file changed

+2
-2
lines changed

Diff for: Node/quickstarts/genkit-helloworld/functions/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const jokeTeller = ai.defineFlow({
4646
inputSchema: z.string().nullable(),
4747
outputSchema: z.string(),
4848
streamSchema: z.string(),
49-
}, async (jokeType = "knock-knock", response) => {
49+
}, async (jokeType = "knock-knock", {sendChunk}) => {
5050
const prompt = `Tell me a ${jokeType} joke.`;
5151

5252
// Call the `generateStream()` method to
@@ -56,7 +56,7 @@ const jokeTeller = ai.defineFlow({
5656
// Send new words of the generative AI response
5757
// to the client as they're generated.
5858
for await (const chunk of stream) {
59-
response.sendChunk(chunk.text);
59+
sendChunk(chunk.text);
6060
}
6161

6262
// Return the full generative AI response

0 commit comments

Comments
 (0)