Skip to content

Conversation

thatfiredev
Copy link
Member

@thatfiredev thatfiredev commented Apr 8, 2024

In its current state, generateContent(), generateContentStream() and countTokens() let developers pass zero arguments, which then causes the runtime error:
com.google.ai.client.generativeai.type.ServerException: * GenerateContentRequest.contents: contents is not specified - because contents is a required field on the API.

Although the current error might be helpful, it would be nice if a developer could spot this mistake in compile time rather than in runtime.

Backwards compatibility

The changes in this PR would probably not break most of the cases that we have documented (eg. countTokens(content)), but would certainly break a few cases like for example if the developer was doing something like countTokens(*contentArray, content) (which we actually document here).

@thatfiredev
Copy link
Member Author

Superseeded by firebase/firebase-android-sdk#7104

@thatfiredev thatfiredev closed this Jul 4, 2025
rlazo pushed a commit to firebase/firebase-android-sdk that referenced this pull request Jul 8, 2025
This is a breaking change.

See context in
google-gemini/deprecated-generative-ai-android#116

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
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