feat(firebaseai): ImageConfig and FinishReasons#18180
feat(firebaseai): ImageConfig and FinishReasons#18180
Conversation
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces support for image generation configuration in the Gemini API, including new FinishReason enum values for image-related stop conditions and the addition of the ImageConfig class with its associated ImageAspectRatio and ImageSize enums. The GenerationConfig has been updated to include an imageConfig field, and corresponding unit tests have been added to verify serialization and parsing. The feedback focuses on adhering to the project's style guide by using const constructors for the new immutable configuration classes and their instances in tests.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces support for image generation configuration in the Gemini API, including new ImageConfig, ImageAspectRatio, and ImageSize types, as well as several new FinishReason enum values. The changes include necessary JSON serialization logic and updated unit tests. Feedback was provided regarding a minor typo in a documentation comment and a recommendation to use package:checks for new test assertions to align with the repository's style guide.
| group('ImageConfig', () { | ||
| test('toJson with all fields', () { | ||
| const config = ImageConfig( | ||
| aspectRatio: ImageAspectRatio.portrait9x16, | ||
| imageSize: ImageSize.size2K, | ||
| ); | ||
| expect(config.toJson(), { | ||
| 'aspectRatio': '9:16', | ||
| 'imageSize': '2K', | ||
| }); | ||
| }); | ||
|
|
||
| test('toJson with some fields null', () { | ||
| const config = ImageConfig( | ||
| aspectRatio: ImageAspectRatio.landscape16x9, | ||
| ); | ||
| expect(config.toJson(), { | ||
| 'aspectRatio': '16:9', | ||
| }); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
The repository style guide (line 69) recommends using package:checks for assertions instead of package:test's expect. While the existing tests use expect, new tests should ideally follow the updated guidelines.
References
- Use package:checks for assertions. (link)
There was a problem hiding this comment.
Keeping expect to be consistent with rest of file.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces image generation configuration through the ImageConfig class and associated enums, while also expanding the FinishReason enum with several new safety and image-related values. A critical compilation error was identified in firebase_ai.dart where malformed export statements and duplicate entries will prevent the code from building. Additional feedback includes suggestions to override toString() in new enums for consistency with the existing codebase and the removal of excessive blank lines in api.dart.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces support for image generation configuration by adding the ImageConfig class along with ImageAspectRatio and ImageSize enums. It also expands the FinishReason enum with several new values related to image safety and content filtering, and integrates ImageConfig into the GenerationConfig class. Feedback was provided regarding the FinishReason.parseValue method, specifically suggesting the addition of an 'UNKNOWN' case for symmetry and updating the default case to return FinishReason.unknown instead of throwing an exception to improve robustness against future backend changes.
Replicating changes from iOS SDK for ImageConfig and expanded FinishReasons.
Incorporates work from #17761 from @thatfiredev