-
Notifications
You must be signed in to change notification settings - Fork 657
[AI] Add support for Thinking Levels #7599
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
base: main
Are you sure you want to change the base?
Conversation
Gemini 2.5 series models and newer utilize a thinking process before generating a response. Thinking levels are an alternative to thinking budgets as they are preset values that Gemini 3 models can use to limit how many tokens are dedicated to the thinking process. The [thinking documentation](https://firebase.google.com/docs/ai-logic/thinking) gives more details.
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. |
📝 PRs merging into main branchOur main branch should always be in a releasable state. If you are working on a larger change, or if you don't want this change to see the light of the day just yet, consider using a feature branch first, and only merge into the main branch when the code complete and ready to be released. |
Coverage Report 1Affected ProductsNo changes between base commit (bc2bc5c) and merge commit (3d15042).Test Logs |
|
The public api surface has changed for the subproject firebase-ai: Please update the api.txt files for the subprojects being affected by this change by running ./gradlew ${subproject}:generateApiTxtFile. Also perform a major/minor bump accordingly. |
Size Report 1Affected Products
Test Logs |
|
The public api surface has changed for the subproject firebase-ai: Please update the api.txt files for the subprojects being affected by this change by running ./gradlew ${subproject}:generateApiTxtFile. Also perform a major/minor bump accordingly. |
| if (thinkingLevel != null) | ||
| throw IllegalArgumentException("Cannot set both `thinkingBudget` and `thinkingLevel`") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's simpler to perform this check in the build() function once, rather than twice (one in each setter):
public fun build(): ThinkingConfig {
if (thinkingLevel != null && thinkingBudget != null) {
throw IllegalArgumentException("Cannot set both `thinkingBudget` and `thinkingLevel` in the same request")
}
ThinkingConfig(
thinkingBudget = thinkingBudget,
includeThoughts = includeThoughts,
thinkingLevel = thinkingLevel
)
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it would be simpler. On the other hand, by having the check duplicated on the method, any exception will pin point directly to the offending line, which makes devs life easier. WDYT?
I think the duplication balances out with the benefit. If you feel strongly around this, I can update the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, good point about pinpointing the exact line.
I have no strong preference.
Gemini 3 models support thinking levels, an alternative to thinking budgets. They are preset values that can use to limit how many tokens are dedicated to the thinking process.
The thinking documentation gives more details.