fix(filters): isolate is_copilot_model to metadata and fix single-pipe match

This commit is contained in:
fujie
2026-03-21 14:59:30 +08:00
parent 85c58f1a3d
commit 318e3951ff
2 changed files with 12 additions and 4 deletions

View File

@@ -2713,7 +2713,8 @@ class Filter:
Check if compression should be skipped. Check if compression should be skipped.
Returns True if: Returns True if:
""" """
if body.get("is_copilot_model", False): is_copilot = body.get("is_copilot_model", False) or body.get("metadata", {}).get("is_copilot_model", False)
if is_copilot:
return True return True
return False return False

View File

@@ -51,8 +51,12 @@ class Filter:
# 1) Prefix match (most reliable for OpenWebUI model id formats) # 1) Prefix match (most reliable for OpenWebUI model id formats)
raw_prefixes = self.valves.target_model_prefixes or "" raw_prefixes = self.valves.target_model_prefixes or ""
prefixes = [p.strip().lower() for p in raw_prefixes.split(",") if p.strip()] prefixes = [p.strip().lower() for p in raw_prefixes.split(",") if p.strip()]
if any(current.startswith(prefix) for prefix in prefixes): for prefix in prefixes:
return True if current.startswith(prefix):
return True
# Match exact string without trailing dot for single-pipe endpoints
if prefix.endswith(".") and current == prefix[:-1]:
return True
# 2) Keyword fallback for backward compatibility # 2) Keyword fallback for backward compatibility
keyword = (self.valves.target_model_keyword or "").strip().lower() keyword = (self.valves.target_model_keyword or "").strip().lower()
@@ -114,7 +118,10 @@ class Filter:
# Check if it's a Copilot model # Check if it's a Copilot model
is_copilot_model = self._is_copilot_model(current_model) is_copilot_model = self._is_copilot_model(current_model)
body["is_copilot_model"] = is_copilot_model
if "metadata" not in body:
body["metadata"] = {}
body["metadata"]["is_copilot_model"] = is_copilot_model
await self._emit_debug_log( await self._emit_debug_log(
__event_emitter__, __event_emitter__,