sendMessageStream does not add to history and returns improper candidate object #309
Labels
component:js sdk
Issue/PR related to JavaScript SDK
status:triaged
Issue/PR triaged to the corresponding sub-team
type:bug
Something isn't working
Description of the bug:
When using
sendMessageStream
, the response payload forresponse
object is not the same assendMessage
. There are several things odd about it, and the end result is that the messages do not get added to the internal history. This causes subsequent messages sent on the chat session to essentially be starting from scratch. This means you can't use function calling or anything, unless you persist your own history and pass the full object in every time you callsendMessageStream
Actual vs expected behavior:
Here is a simple
node-ts
script you can run withnode-ts <file>.ts
(assuming you havenode-ts
). This simple implementation faces the error I'm describingThe response of
sendMessage
is of the formwhile the response of `sendMessageStream is
For some reason, the candidates object is being placed onto the
undefined
key in the array, which causes the length of the array to be zero, thus no history is addedhttps://github.com/google-gemini/generative-ai-js/blob/main/src/methods/chat-session.ts#L185
Any other information you'd like to share?
I've noticed this issue with both 2.0 flash and 1.5 flash. I feel like I must be doing something wrong or very few people are using this sdk with streaming and function calling, as I'm surprised to be the first to notice this.
Thanks for your help in advance!
The text was updated successfully, but these errors were encountered: