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