mirror of
https://github.com/andrewyng/openworker.git
synced 2026-11-20 20:37:44 +00:00
fix(models): readable names for listed models without one; singular 'not on this key'; retirement reads as Deprecated (OPE-252)
From the owner's manual test of the provider page: - A row whose list gives no display name (Fireworks, Kimi, Cohere, the bare lists) showed its raw id. display_label() now drops the namespace (accounts/<org>/models|routers/, <org>/), writes Fireworks' 5p3 as 5.3 and turns the id into words: accounts/fireworks/models/deepseek-v4p1-flash-1017 reads 'DeepSeek V4.1 Flash 1017', glm-5p3-fast 'GLM-5.3 Fast', gpt-oss-120b 'GPT-OSS 120B'. A list's own name and the catalog's label still win; the full id stays beside the name. - '1 ticked models are not on this key' gets a singular form. - A retirement date reads 'Deprecated · ends <date>', and a past one 'Deprecated · ended <date>'.
This commit is contained in:
@@ -328,9 +328,57 @@ def _label(item: dict[str, Any], model_id: str, *keys: str) -> str:
|
||||
return model_id
|
||||
|
||||
|
||||
_FIREWORKS_NAMESPACE = re.compile(r"^accounts/[^/]+/(?:models|routers)/")
|
||||
_FIREWORKS_DOT = re.compile(r"(?<=\d)p(?=\d)") # Fireworks writes 5.3 as 5p3
|
||||
_ACRONYMS = {"glm", "gpt", "oss", "vl", "ai", "it"}
|
||||
_BRANDS = {"deepseek": "DeepSeek", "minimax": "MiniMax", "kimi": "Kimi", "qwen": "Qwen", "llama": "Llama"}
|
||||
_SIZE = re.compile(r"^[a-z]?\d+(?:\.\d+)?b$", re.I) # 120b, 8B, a12b
|
||||
_O_SERIES = re.compile(r"^o\d$") # OpenAI's o3, o4 stay lower case
|
||||
|
||||
|
||||
def _cased(token: str) -> str:
|
||||
low = token.lower()
|
||||
if low in _ACRONYMS:
|
||||
return low.upper()
|
||||
if low in _BRANDS:
|
||||
return _BRANDS[low]
|
||||
if _SIZE.match(token):
|
||||
return token.upper()
|
||||
if _O_SERIES.match(low):
|
||||
return low
|
||||
return token[:1].upper() + token[1:]
|
||||
|
||||
|
||||
def display_label(model_id: str) -> str:
|
||||
"""A readable name for a row whose list gives none, for display only: the full id stays
|
||||
the row's id and shows beside the name. Drops the namespace (`accounts/<org>/models/`,
|
||||
`<org>/`), writes Fireworks' `5p3` as `5.3`, turns hyphens into spaces and cases each
|
||||
word: `accounts/fireworks/models/deepseek-v4p1-flash-1017` -> "DeepSeek V4.1 Flash 1017",
|
||||
`gpt-5.4-nano` -> "GPT-5.4 Nano", `gpt-oss-120b` -> "GPT-OSS 120B". A leading acronym keeps
|
||||
its hyphen to the version (GPT-5.4, GLM-5.3), and two acronyms stay one word (GPT-OSS). Tier words such as
|
||||
Fast or Spot stay in the name."""
|
||||
short = _FIREWORKS_NAMESPACE.sub("", model_id)
|
||||
if short != model_id:
|
||||
short = _FIREWORKS_DOT.sub(".", short)
|
||||
elif "/" in model_id:
|
||||
short = model_id.rsplit("/", 1)[-1]
|
||||
tokens = [t for t in re.split(r"[-_]", short) if t]
|
||||
if not tokens:
|
||||
return model_id
|
||||
out = _cased(tokens[0])
|
||||
for i, (prev, token) in enumerate(zip(tokens, tokens[1:])):
|
||||
acronym = prev.lower() in _ACRONYMS
|
||||
# the leading acronym keeps its version (GPT-5.4); two acronyms stay one word (GPT-OSS)
|
||||
joined = acronym and ((i == 0 and token[:1].isdigit()) or token.lower() in _ACRONYMS)
|
||||
out += ("-" if joined else " ") + _cased(token)
|
||||
return out
|
||||
|
||||
|
||||
def _row(model_id: str, label: str, kind: Optional[str], source: str, detail: Optional[str] = None, **facts: Any) -> LiveModel:
|
||||
if kind is None or kind == CHAT:
|
||||
kind, source = CHAT, (source if source == "provider" else "none")
|
||||
if label == model_id:
|
||||
label = display_label(model_id)
|
||||
return LiveModel(id=model_id, label=label, kind=kind, kind_source=source, detail=detail, **facts)
|
||||
|
||||
|
||||
|
||||
@@ -5686,6 +5686,7 @@ class SessionManager:
|
||||
kinds, unless the reviewed catalog vouches for the model or the user picked it
|
||||
anyway. Picker models of this provider the key does not list come last, `on_key`
|
||||
false."""
|
||||
from ..providers import live_models
|
||||
from ..providers.matrix import MATRIX, full_id, models_for_provider, split_id
|
||||
|
||||
d = get_descriptor(name, self.secrets)
|
||||
@@ -5751,7 +5752,7 @@ class SessionManager:
|
||||
offered.append({
|
||||
"id": bare,
|
||||
"model": full,
|
||||
"label": cat.label if cat else f"{bare} · {suffix}",
|
||||
"label": cat.label if cat else f"{live_models.display_label(bare)} · {suffix}",
|
||||
"kind": "chat",
|
||||
"kind_source": "catalog" if cat else "none",
|
||||
"detail": None,
|
||||
|
||||
@@ -94,9 +94,9 @@ describe("ProviderModels with a live listing", () => {
|
||||
await flush();
|
||||
const facts = screen.getByTestId("catalog-facts-command-a-translate-08-2025");
|
||||
const amber = Array.from(facts.querySelectorAll(".text-warnInk")).map((n) => n.textContent);
|
||||
expect(amber).toEqual(["Context 9K — short for long tasks", "No tool support — coworkers cannot act", "Retires 11 Dec 2026"]);
|
||||
expect(amber).toEqual(["Context 9K — short for long tasks", "No tool support — coworkers cannot act", "Deprecated · ends 11 Dec 2026"]);
|
||||
expect(screen.getByTestId("catalog-facts-command-r-old").querySelector(".text-danger")!.textContent).toBe("Not on this key");
|
||||
expect(screen.getByTestId("catalog-not-on-key").textContent).toContain("1 ticked models are not on this key");
|
||||
expect(screen.getByTestId("catalog-not-on-key").textContent).toContain("1 ticked model is not on this key; the provider will refuse it.");
|
||||
});
|
||||
|
||||
it("every model name opens the model's settings without toggling the tick", async () => {
|
||||
|
||||
@@ -1457,7 +1457,8 @@
|
||||
"catalog_refresh": "Refresh",
|
||||
"catalog_refreshing": "Checking…",
|
||||
"catalog_stale": "The provider did not answer this time ({{error}}). Showing the last list.",
|
||||
"catalog_not_on_key_help": "{{count}} ticked models are not on this key; the provider will refuse them.",
|
||||
"catalog_not_on_key_help_one": "{{count}} ticked model is not on this key; the provider will refuse it.",
|
||||
"catalog_not_on_key_help_other": "{{count}} ticked models are not on this key; the provider will refuse them.",
|
||||
"catalog_search": "Search models…",
|
||||
"catalog_did_you_mean": "Did you mean:",
|
||||
"catalog_count_one": "{{count}} model on this key",
|
||||
@@ -1471,7 +1472,7 @@
|
||||
"catalog_fact_tools": "Tools",
|
||||
"catalog_fact_no_tools": "No tool support — coworkers cannot act",
|
||||
"catalog_fact_reasoning": "Reasoning",
|
||||
"catalog_fact_retires": "Retires {{date}}",
|
||||
"catalog_fact_retires": "Deprecated · ends {{date}}",
|
||||
"catalog_fact_not_on_key": "Not on this key",
|
||||
"catalog_aside_line_one": "{{count}} more model on this key is for images, speech, embeddings and other tasks.",
|
||||
"catalog_aside_line_other": "{{count}} more models on this key are for images, speech, embeddings and other tasks.",
|
||||
@@ -1491,7 +1492,7 @@
|
||||
"catalog_kind_specialised": "Specialised: {{detail}}",
|
||||
"catalog_kind_hybrid_image": "Also generates images",
|
||||
"catalog_kind_hybrid_audio": "Also generates speech",
|
||||
"catalog_kind_retired": "Retired on {{date}}",
|
||||
"catalog_kind_retired": "Deprecated · ended {{date}}",
|
||||
"catalog_kind_other": "Not a chat model",
|
||||
"catalog_kind_likely": "Likely {{phrase}}",
|
||||
"catalog_kindword_image": "image generation",
|
||||
|
||||
@@ -1427,7 +1427,7 @@
|
||||
"catalog_refresh": "刷新",
|
||||
"catalog_refreshing": "检查中…",
|
||||
"catalog_stale": "提供方这次没有回应({{error}})。显示上次的列表。",
|
||||
"catalog_not_on_key_help": "已勾选的模型中有 {{count}} 个不在此密钥上;提供方会拒绝它们。",
|
||||
"catalog_not_on_key_help_other": "已勾选的模型中有 {{count}} 个不在此密钥上;提供方会拒绝它们。",
|
||||
"catalog_search": "搜索模型…",
|
||||
"catalog_did_you_mean": "你是指:",
|
||||
"catalog_count_other": "此密钥可用 {{count}} 个模型",
|
||||
@@ -1440,7 +1440,7 @@
|
||||
"catalog_fact_tools": "工具",
|
||||
"catalog_fact_no_tools": "不支持工具 — 协作者无法执行操作",
|
||||
"catalog_fact_reasoning": "推理",
|
||||
"catalog_fact_retires": "{{date}} 停用",
|
||||
"catalog_fact_retires": "已弃用 · {{date}} 停用",
|
||||
"catalog_fact_not_on_key": "不在此密钥上",
|
||||
"catalog_aside_line_other": "此密钥上还有 {{count}} 个模型用于图像、语音、嵌入等其他任务。",
|
||||
"catalog_show": "显示",
|
||||
@@ -1459,7 +1459,7 @@
|
||||
"catalog_kind_specialised": "专用:{{detail}}",
|
||||
"catalog_kind_hybrid_image": "也会生成图像",
|
||||
"catalog_kind_hybrid_audio": "也会生成语音",
|
||||
"catalog_kind_retired": "已于 {{date}} 停用",
|
||||
"catalog_kind_retired": "已弃用 · 已于 {{date}} 停用",
|
||||
"catalog_kind_other": "不是对话模型",
|
||||
"catalog_kind_likely": "可能{{phrase}}",
|
||||
"catalog_kindword_image": "图像生成",
|
||||
|
||||
@@ -178,6 +178,39 @@ def test_groq_modalities_and_the_prompt_guard_word():
|
||||
assert (guard.kind, guard.kind_source, guard.reason_phrase) == ("moderation", "name", "Likely built for content moderation")
|
||||
|
||||
|
||||
def test_a_row_without_a_display_name_gets_a_readable_one():
|
||||
"""Owner's test 2026-11-10: names must read as names. The list's own name wins; without
|
||||
one the id loses its namespace and becomes words. The full id still shows beside it."""
|
||||
fw = _parsed("fireworks")
|
||||
glm = fw["accounts/fireworks/models/glm-5p3"]
|
||||
assert (glm.id, glm.label) == ("accounts/fireworks/models/glm-5p3", "GLM-5.3")
|
||||
assert fw["accounts/fireworks/routers/glm-5p3-fast"].label == "GLM-5.3 Fast" # the tier stays in the name
|
||||
assert fw["accounts/fireworks/models/kimi-k3"].label == "Kimi K3"
|
||||
assert fw["auto"].label == "Auto"
|
||||
assert _parsed("huggingface")["Qwen/Qwen3.8-27B"].label == "Qwen3.8 27B"
|
||||
assert _parsed("kimi")["kimi-k2.6"].label == "Kimi K2.6"
|
||||
assert _parsed("openrouter")["openai/gpt-6-astra"].label == "OpenAI: GPT-6 Astra" # a list's own name wins
|
||||
assert _parsed("openai-codex")["gpt-5.6-terra"].label == "GPT-5.6-Terra"
|
||||
cases = {
|
||||
"accounts/fireworks/models/deepseek-v4p1-flash-1017": "DeepSeek V4.1 Flash 1017",
|
||||
"accounts/fireworks/routers/deepseek-v4p1-flash-1017-spot": "DeepSeek V4.1 Flash 1017 Spot",
|
||||
"accounts/fireworks/models/minimax-m3p1-flash": "MiniMax M3.1 Flash",
|
||||
"accounts/fireworks/models/qwen3p8-2p4t-a95b": "Qwen3.8 2.4t A95B",
|
||||
"gpt-5.4-nano": "GPT-5.4 Nano",
|
||||
"gpt-oss-120b": "GPT-OSS 120B",
|
||||
"chat-latest": "Chat Latest",
|
||||
"o4-mini": "o4 Mini",
|
||||
"glm-4.5-air": "GLM-4.5 Air",
|
||||
"Meta-Llama-3.3-70B-Instruct": "Meta Llama 3.3 70B Instruct",
|
||||
"gemma-4-31B-it": "Gemma 4 31B IT",
|
||||
"nvidia/nemotron-3-super-120b-a12b": "Nemotron 3 Super 120B A12B",
|
||||
"MiniMax-M3.1-Flash": "MiniMax M3.1 Flash",
|
||||
"muse-spark-1.3": "Muse Spark 1.3",
|
||||
"grok-4.3": "Grok 4.3",
|
||||
}
|
||||
assert {i: live_models.display_label(i) for i in cases} == cases
|
||||
|
||||
|
||||
def test_fireworks_kind_field():
|
||||
rows = _parsed("fireworks")
|
||||
glm = rows["accounts/fireworks/models/glm-5p3"]
|
||||
|
||||
Reference in New Issue
Block a user