Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/4067.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- GoogleLLMService now applies a low-latency thinking default (`thinking_level="minimal"`) for Gemini 3+ Flash models.
16 changes: 9 additions & 7 deletions src/pipecat/services/google/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -995,18 +995,20 @@ def _build_generation_params(

def _maybe_unset_thinking_budget(self, generation_params: Dict[str, Any]):
try:
# There's no way to introspect on model capabilities, so
# to check for models that we know default to thinkin on
# and can be configured to turn it off.
if not self._settings.model.startswith("gemini-2.5-flash"):
return
# If we have an image model, we don't use a budget either.
# If we have an image model, we don't apply a thinking default.
if "image" in self._settings.model:
return
# If thinking_config is already set, don't override it.
if "thinking_config" in generation_params:
return
generation_params.setdefault("thinking_config", {})["thinking_budget"] = 0
# Apply model-aware low-latency thinking defaults.
# Gemini 2.5 Flash: disable thinking via thinking_budget.
# Gemini 3+ Flash: use minimal thinking via thinking_level.
model = self._settings.model
if model.startswith("gemini-2.5-flash"):
generation_params["thinking_config"] = {"thinking_budget": 0}
elif model.startswith("gemini-3") and "flash" in model:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Technically this more general check (as opposed to explicitly checking for the string "gemini-3-flash") would cause use to set this thinking config unnecessarily in "gemini-3.1-flash-lite" (where minimal thinking is default), but I think it's absolutely worth it for future-proofing. So, good call 👍.

generation_params["thinking_config"] = {"thinking_level": "minimal"}
except Exception as e:
logger.error(f"Failed to unset thinking budget: {e}")

Expand Down
Loading