Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

require at least one argument for vararg #116

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

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).

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