Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(ai): Add thinking levels parameter#9424

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
hsubox76 wants to merge4 commits intomain
base:main
Choose a base branch
Loading
fromch-thinking-levels

Conversation

@hsubox76
Copy link
Contributor

Add thinking levels feature.

API proposal (internal):https://docs.google.com/document/d/16cdWurhdLDuNIDj0eJWNnL00any0tL_DjI-lAg7miP8/edit?tab=t.0

Added the param, plus an error if both thinkingLevel and thinkingBudget are set. This validation function may be used in the future to validate other common config issues.

Docs notes:

  • Copied text of documentation from Swift comments in API proposal doc (see above)
  • Some of the "removed" text in the md files is actually just removing them from the toc table at the top of the page, where they are unnecessary, and most of the text still remains in the entries below.

@changeset-bot
Copy link

changeset-botbot commentedDec 12, 2025
edited
Loading

🦋 Changeset detected

Latest commit:87464b7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
NameType
@firebase/aiMinor
firebaseMinor

Not sure what this means?Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello@hsubox76, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the AI model configuration by introducing athinkingLevel parameter, offering a simplified way to control the model's internal reasoning process. It ensures proper configuration through client-side validation and provides comprehensive documentation for the new feature.

Highlights

  • NewthinkingLevel Parameter: Introduced a newthinkingLevel parameter withinThinkingConfig to allow users to specify a preset level for the model's 'thinking' process, with options likeMINIMAL,LOW,MEDIUM, andHIGH.
  • Mutual Exclusivity Validation: Implemented client-side validation to prevent the simultaneous setting of boththinkingBudget andthinkingLevel in theGenerationConfig, throwing anAIErrorCode.UNSUPPORTED error if both are provided.
  • Documentation Updates: Updated API documentation and devsite markdown files to reflect the newThinkingLevel type, its usage, and the updatedThinkingConfig interface, including notes on its interaction withthinkingBudget and model support.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on ourdocumentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either/gemini <command> or@gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

FeatureCommandDescription
Code Review/gemini reviewPerforms a code review for the current pull request in its current state.
Pull Request Summary/gemini summaryProvides a summary of the current pull request in its current state.
Comment@gemini-code-assistResponds in comments when explicitly tagged, both in pull request comments and review comments.
Help/gemini helpDisplays a list of available commands.

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.gemini/ folder in the base of the repository. Detailed instructions can be foundhere.

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

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with theGemini Code Assist IDE Extension.

Footnotes

  1. Review thePrivacy Notices,Generative AI Prohibited Use Policy,Terms of Service, and learn how to configure Gemini Code Assist in GitHubhere. Gemini can make mistakes, so double check it anduse code with caution.

@github-actions
Copy link
Contributor

github-actionsbot commentedDec 12, 2025
edited
Loading

Changeset File Check ✅

  • No modified packages are missing from the changeset file.
  • No changeset formatting errors detected.

Copy link
Contributor

@gemini-code-assistgemini-code-assistbot 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 thethinkingLevel parameter to thethinkingConfig, providing users with presets to control the model's thinking process. The changes include updates to theThinkingConfig interface, new type definitions forThinkingLevel, and comprehensive documentation updates. A key addition is the client-side validation that preventsthinkingLevel andthinkingBudget from being set simultaneously, which is a great way to prevent invalid configurations. The associated test case for this validation is also well-implemented. Overall, the changes are solid. I have one minor suggestion to improve the readability of the validation logic.

Comment on lines 175 to 186
functionvalidateGenerationConfig(generationConfig:GenerationConfig):void{
if(
// != allows for null and undefined. 0 is considered "set" by the model
generationConfig.thinkingConfig?.thinkingBudget!=null&&
generationConfig.thinkingConfig.thinkingLevel
){
thrownewAIError(
AIErrorCode.UNSUPPORTED,
`Cannot set both thinkingBudget and thinkingLevel in a config.`
);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

While the current logic is correct due to&& short-circuiting, it's a bit subtle. AccessinggenerationConfig.thinkingConfig.thinkingLevel could be misinterpreted as unsafe if one overlooks the short-circuiting behavior. Refactoring to first check forthinkingConfig's existence improves readability and maintainability.

Suggested change
functionvalidateGenerationConfig(generationConfig:GenerationConfig):void{
if(
// != allows for null and undefined. 0 is considered "set" by the model
generationConfig.thinkingConfig?.thinkingBudget!=null&&
generationConfig.thinkingConfig.thinkingLevel
){
thrownewAIError(
AIErrorCode.UNSUPPORTED,
`Cannot set both thinkingBudget and thinkingLevel in a config.`
);
}
}
functionvalidateGenerationConfig(generationConfig:GenerationConfig):void{
const{ thinkingConfig}=generationConfig;
if(
thinkingConfig&&
// != allows for null and undefined. 0 is considered "set" by the model
thinkingConfig.thinkingBudget!=null&&
thinkingConfig.thinkingLevel
){
thrownewAIError(
AIErrorCode.UNSUPPORTED,
`Cannot set both thinkingBudget and thinkingLevel in a config.`
);
}
}

@google-oss-bot
Copy link
Contributor

google-oss-bot commentedDec 12, 2025
edited
Loading

Size Report1

Affected Products

  • @firebase/ai

    TypeBase (bc2b2cd)Merge (4d7a47b)Diff
    browser67.4 kB67.8 kB+406 B (+0.6%)
    main71.7 kB72.2 kB+483 B (+0.7%)
    module67.4 kB67.8 kB+406 B (+0.6%)
  • firebase

    TypeBase (bc2b2cd)Merge (4d7a47b)Diff
    firebase-ai.js52.8 kB53.1 kB+312 B (+0.6%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/gmZ043F2ec.html

@google-oss-bot
Copy link
Contributor

google-oss-bot commentedDec 12, 2025
edited
Loading

Size Analysis Report1

Affected Products

  • @firebase/ai

    • GenerativeModel

      Size

      TypeBase (bc2b2cd)Merge (4d7a47b)Diff
      size26.1 kB26.3 kB+209 B (+0.8%)
      size-with-ext-deps43.9 kB44.1 kB+211 B (+0.5%)

      Dependency

      TypeBase (bc2b2cd)Merge (4d7a47b)Diff
      functions

      39 dependencies

      addHelpersaggregateResponsesassignRoleToPartsAndValidateSendMessageRequestcallCloudOrDevicechromeAdapterFactorycountTokenscountTokensOnCloudcreateEnhancedContentResponsedecodeInstanceIdentifierfactoryformatBlockErrorMessageformatGenerateContentInputformatNewContentformatSystemInstructiongenerateContentgenerateContentOnCloudgenerateContentStreamgenerateContentStreamOnCloudgenerateResponseSequencegetClientHeadersgetFunctionCallsgetHeadersgetInlineDataPartsgetResponsePromisegetResponseStreamgetTexthadBadFinishReasonhasValidCandidatesinitApiSettingsmakeRequestmapCountTokensRequestmapGenerateContentCandidatesmapGenerateContentRequestmapGenerateContentResponsemapPromptFeedbackprocessGenerateContentResponseprocessStreamregisterAIvalidateChatHistory

      40 dependencies

      addHelpersaggregateResponsesassignRoleToPartsAndValidateSendMessageRequestcallCloudOrDevicechromeAdapterFactorycountTokenscountTokensOnCloudcreateEnhancedContentResponsedecodeInstanceIdentifierfactoryformatBlockErrorMessageformatGenerateContentInputformatNewContentformatSystemInstructiongenerateContentgenerateContentOnCloudgenerateContentStreamgenerateContentStreamOnCloudgenerateResponseSequencegetClientHeadersgetFunctionCallsgetHeadersgetInlineDataPartsgetResponsePromisegetResponseStreamgetTexthadBadFinishReasonhasValidCandidatesinitApiSettingsmakeRequestmapCountTokensRequestmapGenerateContentCandidatesmapGenerateContentRequestmapGenerateContentResponsemapPromptFeedbackprocessGenerateContentResponseprocessStreamregisterAIvalidateChatHistoryvalidateGenerationConfig

      + validateGenerationConfig

    • ThinkingLevel

      Size

      TypeBase (bc2b2cd)Merge (4d7a47b)Diff
      size?7.01 kB? (?)
      size-with-ext-deps?24.6 kB? (?)

      Dependency

      TypeBase (bc2b2cd)Merge (4d7a47b)Diff
      functions?

      chromeAdapterFactorydecodeInstanceIdentifierfactoryregisterAI

      ?
      classes?

      AIErrorAIServiceBackendChromeAdapterImplGoogleAIBackendVertexAIBackend

      ?
      variables?

      12 dependencies

      AIErrorCodeAI_TYPEAvailabilityBackendTypeDEFAULT_API_VERSIONDEFAULT_LOCATIONInferenceModeThinkingLeveldefaultExpectedInputsloggernameversion

      ?
      enums??

      External Dependency

      ModuleBase (bc2b2cd)Merge (4d7a47b)Diff
      @firebase/app?

      _registerComponentregisterVersion

      ?
      @firebase/component?

      Component

      ?
      @firebase/logger?

      Logger

      ?
      @firebase/util?

      FirebaseError

      ?
    • getGenerativeModel

      Size

      TypeBase (bc2b2cd)Merge (4d7a47b)Diff
      size26.4 kB26.6 kB+209 B (+0.8%)
      size-with-ext-deps44.2 kB44.4 kB+211 B (+0.5%)

      Dependency

      TypeBase (bc2b2cd)Merge (4d7a47b)Diff
      functions

      40 dependencies

      addHelpersaggregateResponsesassignRoleToPartsAndValidateSendMessageRequestcallCloudOrDevicechromeAdapterFactorycountTokenscountTokensOnCloudcreateEnhancedContentResponsedecodeInstanceIdentifierfactoryformatBlockErrorMessageformatGenerateContentInputformatNewContentformatSystemInstructiongenerateContentgenerateContentOnCloudgenerateContentStreamgenerateContentStreamOnCloudgenerateResponseSequencegetClientHeadersgetFunctionCallsgetGenerativeModelgetHeadersgetInlineDataPartsgetResponsePromisegetResponseStreamgetTexthadBadFinishReasonhasValidCandidatesinitApiSettingsmakeRequestmapCountTokensRequestmapGenerateContentCandidatesmapGenerateContentRequestmapGenerateContentResponsemapPromptFeedbackprocessGenerateContentResponseprocessStreamregisterAIvalidateChatHistory

      41 dependencies

      addHelpersaggregateResponsesassignRoleToPartsAndValidateSendMessageRequestcallCloudOrDevicechromeAdapterFactorycountTokenscountTokensOnCloudcreateEnhancedContentResponsedecodeInstanceIdentifierfactoryformatBlockErrorMessageformatGenerateContentInputformatNewContentformatSystemInstructiongenerateContentgenerateContentOnCloudgenerateContentStreamgenerateContentStreamOnCloudgenerateResponseSequencegetClientHeadersgetFunctionCallsgetGenerativeModelgetHeadersgetInlineDataPartsgetResponsePromisegetResponseStreamgetTexthadBadFinishReasonhasValidCandidatesinitApiSettingsmakeRequestmapCountTokensRequestmapGenerateContentCandidatesmapGenerateContentRequestmapGenerateContentResponsemapPromptFeedbackprocessGenerateContentResponseprocessStreamregisterAIvalidateChatHistoryvalidateGenerationConfig

      + validateGenerationConfig

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/9KGDGIu9Bx.html

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

1 more reviewer

@gemini-code-assistgemini-code-assist[bot]gemini-code-assist[bot] left review comments

Reviewers whose approvals may not affect merge requirements

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@hsubox76@google-oss-bot

[8]ページ先頭

©2009-2025 Movatter.jp