google-gemini / generative-ai-dart

The official Dart library for the Google Gemini API
https://ai.google.dev/gemini-api/docs/get-started/tutorial?lang=dart
Apache License 2.0
571 stars 115 forks source link

Default the role to 'model' for chat responses #205

Closed natebosch closed 3 months ago

natebosch commented 3 months ago

Fixes #197

A content requires a role when it is sent to the model in the history. If the backend happens to respond with a message that has no role, default it to 'model'.

natebosch commented 3 months ago

I think the TODO was because I was aware that roles were required when we send the message, but I had never seen a case where the backend replied without a role. We have a report of such a case, so add the defaulting in.