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

Add support for request options with a timeout #44

Open natebosch opened 9 months ago

natebosch commented 9 months ago

See https://github.com/google/generative-ai-js/pull/31, https://github.com/google/generative-ai-android/pull/52

The new design allows passing a requestOptions argument when creating the model. Currently they cannot be passed to generateContent and the other calls like safety settings and generation config, but we can add optional arguments later and it should not be breaking for anyone since the class is final.

The initially supported option is a timeout. cc @brianquinlan - Do you think we should punt on this for now until package:http supports "real" timeouts which cancel requests, or should we implement faked support for now and update to also cancel the outstanding request when we implement timeouts there?

More options may be added later.

brianquinlan commented 9 months ago

I'd add fake support - we don't even have a proposed implementation for timeouts in package:http, do we?

natebosch commented 9 months ago

No, we need to solve the upgrade path for client implementations. Once we solve that problem I think the API and implementation questions are manageable.

We could also hold off on adding timeouts in this SDK for now and revisit after http gets the new feature, or at least a concrete API design.