fix: improve model matching for OpenRouter :free models and vendor prefixes
This commit is contained in:
@@ -123,8 +123,8 @@ def norm_keep(s: str) -> str:
|
||||
|
||||
def arena_lookup(gw_name: str, arena_models: list) -> tuple:
|
||||
"""(arena_dict|None, note). Сопоставление гейтвей-имени с ареной."""
|
||||
# 0) Снимаем префикс провайдера (agy/..., openrouter/..., etc.)
|
||||
raw = gw_name.split("/", 1)[-1].lower()
|
||||
# 0) Снимаем префикс провайдера (agy/..., openrouter/..., etc.) и vendor (openrouter/nvidia/...)
|
||||
raw = gw_name.split("/")[-1].lower()
|
||||
|
||||
# Снимаем суффиксы -it, -preview, reasoning суффиксы (-thinking, -tiered, -low, -medium, -high, -disabled, -mini, -ultra, -max, -xhigh)
|
||||
base = re.sub(r"-(it|preview)(:[^:]*)?$", "", raw)
|
||||
@@ -167,12 +167,13 @@ def arena_lookup(gw_name: str, arena_models: list) -> tuple:
|
||||
# 3) containment: гейтвей-имя (с дефисами) — подстрока/суффикс арен-имени.
|
||||
# Покрывает вендор-префиксы арены: nemotron-3-super → nvidia-nemotron-3-super.
|
||||
# Защита от ложняков (ling→inkling): минимум 10 символов И есть цифра или дефис.
|
||||
gk = norm_keep(cleaned)
|
||||
if len(gk) >= 10 and (re.search(r"\d", gk) or "-" in gk):
|
||||
for m in arena_models:
|
||||
am = norm_keep(m["model"])
|
||||
if gk == am or am.endswith("-" + gk) or ("-" + gk) in am:
|
||||
return m, "containment"
|
||||
for candidate in (base, cleaned):
|
||||
gk = norm_keep(candidate)
|
||||
if len(gk) >= 10 and (re.search(r"\d", gk) or "-" in gk):
|
||||
for m in arena_models:
|
||||
am = norm_keep(m["model"])
|
||||
if gk == am or am.endswith("-" + gk) or ("-" + gk) in am or (gk in am and len(gk) >= 12):
|
||||
return m, "containment"
|
||||
return None, ""
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user