[fix] plugin: accept version pinned model names

The pattern that validates the model name rejected "@", so names like
gemini-1.5-pro@001 were refused with "no valid model configured".  Those
names are ordinary on the gateways this plugin can be pointed at, which
made the api_key support less useful than it looks.

Verified against a LiteLLM gateway serving an alias named gemma4-e4b@001:
the model list, the request and the streamed answer all carry the pinned
name.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
jasonwitty
2026-08-14 11:00:13 -07:00
co-authored by Claude Opus 5
parent 37d7d11959
commit 1fa83635c0
2 changed files with 28 additions and 4 deletions
+5 -1
View File
@@ -45,7 +45,11 @@ if t.TYPE_CHECKING:
from . import PluginCfg
VALID_ROLES = ("user", "assistant")
MODEL_NAME_REGEXP = re.compile(r"[A-Za-z0-9._:/-]{1,128}")
# Model names differ per provider: "gemma3:4b" (Ollama), "bedrock/anthropic.
# claude-3-5-sonnet" (a gateway's routing prefix), "gemini-1.5-pro@001" (a
# pinned version). The pattern accepts those and rejects anything that could
# change the meaning of the request body it is placed into.
MODEL_NAME_REGEXP = re.compile(r"[A-Za-z0-9._:/@-]{1,128}")
log = logging.getLogger("searx.plugins.ai_summary")