genkit icon indicating copy to clipboard operation
genkit copied to clipboard

[JS] schema validation error in streaming mode cause reflection API to crash

Open pavelgj opened this issue 1 year ago • 1 comments

Describe the bug When running the flow (see below) from the Dev UI in streaming mode the genkit start process "crashes". Full error: https://gist.github.com/pavelgj/0ef67bc35d2c4436c7c128462a64b0b9

To Reproduce

const jokeSubjectGenerator = defineTool(
  {
    name: 'jokeSubjectGenerator',
    description: 'can be called to generate a subject for a joke',
  },
  async () => {
    return 'banana';
  }
);

export const toolCaller = defineFlow(
  {
    name: 'toolCaller',
    outputSchema: z.string(),
  },
  async (_, streamingCallback) => {
    if (!streamingCallback) {
      throw new Error('this flow only works in streaming mode');
    }

    const { response, stream } = await generateStream({
      model: gemini15ProPreview,
      config: {
        temperature: 1,
      },
      tools: [jokeSubjectGenerator],
      prompt: `tell me a joke`,
    });

    for await (const chunk of stream()) {
      streamingCallback(chunk);
    }

    return (await response()).text();
  }
);

Expected behavior A clear and concise description of what you expected to happen.

Screenshots image

pavelgj avatar May 29 '24 13:05 pavelgj

If this was fixed in Go, do we already know the solution for JS? @pavelgj

chrisraygill avatar Jul 04 '24 22:07 chrisraygill

Is this still an active problem?

MichaelDoyle avatar Nov 20 '24 14:11 MichaelDoyle

This is from "May 29"... this specific issue is likely outdated and can be closed. We fixed some crash issues in 0.9.

pavelgj avatar Nov 20 '24 14:11 pavelgj