Skip to content

[Firebase AI] Add simplified object generation#1423

Open
a-maurice wants to merge 3 commits intomainfrom
am-generate_object
Open

[Firebase AI] Add simplified object generation#1423
a-maurice wants to merge 3 commits intomainfrom
am-generate_object

Conversation

@a-maurice
Copy link
Copy Markdown
Collaborator

Description

Provide details of the change, and generalize the change in the PR title above.

Add logic to allow easier object generation with GenerateObjectAsync on GenerativeModel. Add the IFirebaseDeserializable interface, to allow users to define their own method of deserialization if the reflection logic won't work for their needs.


Testing

Describe how you've tested these changes.

Running test locally. Proper automated tests will be included in a future PR, as part of another feature.


Type of Change

Place an x the applicable box:

  • Bug fix. Add the issue # below if applicable.
  • New feature. A non-breaking change which adds functionality.
  • Other, such as a build process or documentation change.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces GenerateObjectAsync to the Firebase AI SDK, enabling simplified object generation from model responses. It includes a new GenerateObjectResponse<T> struct and a SerializationHelpers utility class to handle JSON deserialization via reflection or the IFirebaseDeserializable interface. The review identified several critical issues: the GenerateObjectResponse struct is vulnerable to NullReferenceException if initialized via the default constructor, the deserialization logic fails when casting null results to value types, Enum.Parse lacks robustness for numeric JSON values, the list deserialization logic does not support generic collection interfaces, and the logging in the serialization helper is overly verbose for production.

@a-maurice a-maurice requested a review from AustinBenoit April 8, 2026 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant