firebase / genkit

An open source framework for building AI-powered apps with familiar code-centric patterns. Genkit makes it easy to integrate, test, and deploy sophisticated AI features to Firebase or Google Cloud.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[JS] inconsistent flows output between streaming and non streaming modes

pavelgj opened this issue · comments

When invoking in non-streaming mode the output looks like this:

success:

{"result":"3 + 9 = 12 \n"}

error:

{"error":{"status":"INTERNAL","message":"oops","details":"Error: oops\n    at Flow.<anonymous> (/Users/pavelgj/app/node_modules/@genkit-ai/flow/lib/flow.js:492:19)\n    at Generator.next (<anonymous>)\n    at fulfilled (/Users/pavelgj/app/node_modules/@genkit-ai/flow/lib/flow.js:36:24)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"}}

however when invoked in streaming mode it looks like this:

success:

{"index":0,"content":[{"text":"3"}]}
{"index":0,"content":[{"text":" + 9 = 12 \n"}]}
{"index":0,"content":[{"text":""}]}
{"name":"a777921c-521a-42d3-b8ae-62ef19c67142","done":true,"result":{"response":"3 + 9 = 12 \n"}}

error:

{"name":"4482ddf8-ac19-477b-9684-960617f2c831","done":true,"result":{"error":"oops"}}

Specifically the last line is problematic -- it must be the same format as in non-streaming mode (Firebase Callable Function format).