Skip to content

.Net: New Feature: Support of thinking_config for Gemini connector #11645

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

Closed
rodion-m opened this issue Apr 18, 2025 · 2 comments · Fixed by #11647
Closed

.Net: New Feature: Support of thinking_config for Gemini connector #11645

rodion-m opened this issue Apr 18, 2025 · 2 comments · Fixed by #11647
Assignees
Labels
ai connector Anything related to AI connectors .NET Issue or Pull requests regarding .NET code

Comments

@rodion-m
Copy link


name: Support of thinking_config for Gemini connector
about: Recently Google has updated Gemini 2.5 Flash model and added thinking_config with thinking_budget: https://ai.google.dev/gemini-api/docs/thinking#set-budget


Recently Google has updated Gemini 2.5 Flash model and added thinking_config with thinking_budget: https://ai.google.dev/gemini-api/docs/thinking#set-budget

It would be great to support this feature in Gemini connector for .NET.

@markwallace-microsoft markwallace-microsoft added .NET Issue or Pull requests regarding .NET code triage labels Apr 18, 2025
@rodion-m rodion-m changed the title New Feature: Support of thinking_config for Gemini connector [.NET] New Feature: Support of thinking_config for Gemini connector Apr 18, 2025
@github-actions github-actions bot changed the title [.NET] New Feature: Support of thinking_config for Gemini connector .Net: New Feature: Support of thinking_config for Gemini connector Apr 18, 2025
@shethaadit
Copy link
Contributor

Hi @markwallace-microsoft @RogerBarreto / @westey-m, I have raised PR to add new feature. Could you please review this?

@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented Apr 22, 2025

@markwallace-microsoft markwallace-microsoft moved this to Sprint: In Review in Semantic Kernel Apr 22, 2025
@RogerBarreto RogerBarreto added the ai connector Anything related to AI connectors label Apr 22, 2025
github-merge-queue bot pushed a commit that referenced this issue Apr 25, 2025
### Description

**PR Title:**

feat(connectors-google): Introduce Gemini Thinking Budget Configuration

Closes 11645

**Description:**

This pull request introduces the `GeminiThinkingConfig` class and the
`ThinkingConfig` property within `GeminiPromptExecutionSettings` to
support the thinking budget feature available in Gemini 2.5 and similar
experimental models.

**Key changes include:**

* Added the `GeminiThinkingConfig` class with a `ThinkingBudget`
property for controlling the number of thinking tokens.
* Implemented validation and clamping logic for the `ThinkingBudget`
property within `GeminiThinkingConfig`, ensuring it adheres to the API
requirements (range 0-24576, with 1-1023 clamped to 1024).
* Added the `ThinkingConfig` property to
`GeminiPromptExecutionSettings`, allowing users to configure the
thinking budget for Gemini 2.5 models.
* Implemented a check within the `ThinkingConfig` property setter to
ensure it's only used with Gemini 2.5 model IDs, throwing an
`InvalidOperationException` otherwise.
* Included comprehensive unit tests to verify the functionality of both
`ThinkingConfig` and `ThinkingBudget`, covering valid and invalid input
scenarios, as well as the model ID restriction.

This enhancement enables developers to leverage the thinking budget
feature for more complex tasks with supported Gemini models.

### Contribution Checklist

- [Y] The code builds clean without any errors or warnings
- [Y] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [Y] All unit tests pass, and I have added new tests where possible
- [Y] I didn't break anyone 😄

Fixes #11645

---------

Co-authored-by: Adit Sheth <adsheth@microsoft.com>
Co-authored-by: Roger Barreto <19890735+RogerBarreto@users.noreply.github.com>
@RogerBarreto RogerBarreto moved this from Sprint: In Review to Sprint: Done in Semantic Kernel Apr 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ai connector Anything related to AI connectors .NET Issue or Pull requests regarding .NET code
Projects
Status: Sprint: Done
Development

Successfully merging a pull request may close this issue.

4 participants