diff --git a/python/semantic_kernel/connectors/ai/google/google_ai/google_ai_prompt_execution_settings.py b/python/semantic_kernel/connectors/ai/google/google_ai/google_ai_prompt_execution_settings.py index 426763c67e0a..293bfd9184a3 100644 --- a/python/semantic_kernel/connectors/ai/google/google_ai/google_ai_prompt_execution_settings.py +++ b/python/semantic_kernel/connectors/ai/google/google_ai/google_ai_prompt_execution_settings.py @@ -18,6 +18,21 @@ class GoogleAIPromptExecutionSettings(PromptExecutionSettings): temperature: Annotated[float | None, Field(ge=0.0, le=2.0)] = None top_p: float | None = None top_k: int | None = None + thinking_level: Literal["minimal", "low", "medium", "high"] | str | None = None + + def prepare_settings_dict(self, **kwargs) -> dict[str, Any]: + """Prepare the settings as a dictionary for sending to the AI service. + + This method extracts the thinking_level from the settings dictionary + and maps it to the thinking_config expected by the Google AI SDK. + """ + settings_dict = super().prepare_settings_dict(**kwargs) + + thinking_level = settings_dict.pop("thinking_level", None) + if thinking_level: + settings_dict["thinking_config"] = {"thinking_level": thinking_level} + + return settings_dict class GoogleAITextPromptExecutionSettings(GoogleAIPromptExecutionSettings): diff --git a/python/tests/unit/connectors/ai/google/google_ai/test_google_ai_request_settings.py b/python/tests/unit/connectors/ai/google/google_ai/test_google_ai_request_settings.py index 07b2f0267b5b..5d6340dfd4ca 100644 --- a/python/tests/unit/connectors/ai/google/google_ai/test_google_ai_request_settings.py +++ b/python/tests/unit/connectors/ai/google/google_ai/test_google_ai_request_settings.py @@ -131,3 +131,24 @@ def test_default_google_ai_embedding_prompt_execution_settings(): settings = GoogleAIEmbeddingPromptExecutionSettings() assert settings.output_dimensionality is None + + +def test_google_ai_prompt_execution_settings_thinking_level(): + settings = GoogleAIPromptExecutionSettings(thinking_level="high") + assert settings.thinking_level == "high" + + +def test_google_ai_prompt_execution_settings_thinking_level_mapping(): + settings = GoogleAIPromptExecutionSettings(thinking_level="medium") + settings_dict = settings.prepare_settings_dict() + + assert "thinking_level" not in settings_dict + assert settings_dict["thinking_config"] == {"thinking_level": "medium"} + + +def test_google_ai_prompt_execution_settings_no_thinking_level(): + settings = GoogleAIPromptExecutionSettings(temperature=0.5) + settings_dict = settings.prepare_settings_dict() + + assert "thinking_level" not in settings_dict + assert "thinking_level" not in settings_dict.get("thinking_config", {})