Repository navigation
fix(provider): support Gemini relay aliases and dated 2.5 thinking models - #10961
JosephTian876 wants to merge 1 commit into
Conversation
agammann
left a comment
There was a problem hiding this comment.
[P2] Exclude Gemini 2.5 image models from the broad generation fallback. gemini-2.5-flash-image now matches generation == (2, 5), so the default budget=0 still creates a ThinkingConfig and sends it with image requests. Google's model card lists Thinking as unsupported for this model (https://ai.google.dev/gemini-api/docs/models/gemini-2.5-flash-image); the previous explicit list did not include it. Keep the fallback limited to thinking-capable 2.5 model IDs, and test the image model path so an image request does not acquire a thinking config.
21d253f to
c12aca8
Compare
|
Thanks @agammann — good catch, and it's fixed in c12aca8 (amended into the same single commit, branch force-updated). What changed The if model_name in [
"gemini-2.5-pro", "gemini-2.5-pro-preview", "gemini-2.5-flash",
"gemini-2.5-flash-preview", "gemini-2.5-flash-lite",
"gemini-2.5-flash-lite-preview", "gemini-robotics-er-1.5-preview",
"gemini-live-2.5-flash-preview-native-audio-09-2025",
] or re.search(
r"gemini-2\.5-(?:pro|flash|flash-lite)"
r"(?:-preview|-exp)?(?:-\d{2}(?:-\d{2,4})?)?$",
model_name,
re.IGNORECASE,
):
Tests (
Verification
Could you take another look when you have a moment? |
|
Rechecked |
…dels After AstrBotDevs#11219 and AstrBotDevs#11251 landed Gemini 4 reasoning_effort and Gemini 3.8 thinking level support on master, narrow this change to the two remaining matching gaps in ProviderGoogleGenAI._prepare_query_config(): - Normalize relay-decorated model aliases (such as [AN]gemini-4-hydrogen or full-width prefixed ids) down to their canonical lowercase Gemini id so Gemini 4 reasoning_effort / sampling-param stripping, Gemini 3 thinkingLevel rules, and Gemini 2.5 thinkingBudget all apply cleanly. - Match dated/preview/exp Gemini 2.5 thinking families (pro, flash, flash-lite) via a default-deny allow-list so dated preview ids receive thinkingBudget while non-thinking 2.5 variants (image, tts, native-audio, computer-use) remain excluded.
c12aca8 to
220cdf9
Compare
|
Rebased onto latest master (feb3e82) and narrowed to the two matching gaps remaining after #11219 and #11251:
All 50 tests in |
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Motivation
After #11219 and #11251 landed Gemini 4
reasoning_effortsupport, per-model Gemini 4 allowed levels, Gemini 3.8MINIMALfiltering, and path/case normalization onmaster, two model-ID matching gaps remain inProviderGoogleGenAI._prepare_query_config()(astrbot/core/provider/sources/gemini_source.py):[抗截断]gemini-4-argon,relay/[AN]Gemini-4-Neon,[抗截断]gemini-3.8-flash, or[抗截断]gemini-2.5-flash.model.rsplit("/", 1)[-1].lower()strips path segments, but the remaining prefix still preventsstartswith("gemini-4"),startswith(("gemini-3-", "gemini-3.")), and Gemini 2.5 matching. For decorated Gemini 4 IDs, configuringcustom_extra_body.reasoning_efforteven raisesValueError: Unsupported Gemini custom_extra_body parameters: reasoning_effort.thinkingBudgetcheck is still an exact 8-entry list, so dated thinking IDs such asgemini-2.5-flash-preview-09-2025,gemini-2.5-pro-preview-05-06,gemini-2.5-flash-lite-preview-06-17,gemini-2.5-pro-exp-03-25, andgemini-2.5-flash-001silently omitthinkingConfig.Modifications / 改动点
astrbot/core/provider/sources/gemini_source.py_normalize_gemini_model_name()to extract the canonical lowercasegemini-<digit>...identifier from resource paths and relay-decorated aliases (keeping the outgoing APImodelvalue untouched).custom_extra_body.reasoning_effortfor Gemini 4,GEMINI_4_THINKING_LEVELS, sampling parameter stripping, forcedTEXTmodality,AUTO/Nonedefaults)._GEMINI_25_THINKING_MODEL_REas a default-deny allow-list of thinking-capable Gemini 2.5 families (pro,flash,flash-litewith optional-preview/-expand dated/revision suffixes), keeping non-thinking 2.5 variants (-image,-tts,-native-audio,-computer-use, decorated or not) excluded so they never receivethinkingConfig.tests/test_gemini_source.pyThis is NOT a breaking change. / 这不是一个破坏性变更。
Verification
ruff format --check .→ 599 files already formattedruff check .→ All checks passedpytest tests/test_gemini_source.py→ 50 passedSuggested merge order
Logically independent of
#10894,#11185, and#11298(all touch distinct sections ofastrbot/core/provider/sources/gemini_source.py). Suggested order: #10961 → #10894 → #11185 → #11298 (any order works).Summary by Sourcery
Fix Gemini model matching so relay aliases and dated Gemini 2.5 models receive the appropriate thinking configuration without affecting unsupported variants.
Bug Fixes:
Enhancements:
Tests: