fix(providers): give alibaba-coding-plan-cn its own API key env var
ALIBABA_CODING_PLAN_CN_API_KEY is checked first for the China Coding Plan endpoint (mirroring kimi-coding-cn), so the intl and CN rows no longer light off the same key. Fixes #101122.
This commit is contained in:
@@ -9,6 +9,10 @@ Region split, mirroring the base DashScope pair (#73265):
|
||||
|
||||
Profile names match the models.dev catalog keys exactly so model metadata
|
||||
lines up and ``model.provider: alibaba-coding-plan-cn`` resolves at runtime.
|
||||
|
||||
The CN profile checks its own ``ALIBABA_CODING_PLAN_CN_API_KEY`` first (#101122,
|
||||
mirroring kimi-coding-cn) and keeps the shared vars as ordered fallbacks so
|
||||
existing CN users configured with the shared key keep working.
|
||||
"""
|
||||
|
||||
from providers import register_provider
|
||||
@@ -31,7 +35,7 @@ alibaba_coding_plan_cn = ProviderProfile(
|
||||
display_name="Alibaba Cloud (Coding Plan, China)",
|
||||
description="Alibaba Cloud Coding Plan, mainland-China endpoint",
|
||||
signup_url="https://help.aliyun.com/zh/model-studio/",
|
||||
env_vars=("ALIBABA_CODING_PLAN_API_KEY", "DASHSCOPE_API_KEY", "ALIBABA_CODING_PLAN_CN_BASE_URL"),
|
||||
env_vars=("ALIBABA_CODING_PLAN_CN_API_KEY", "ALIBABA_CODING_PLAN_API_KEY", "DASHSCOPE_API_KEY", "ALIBABA_CODING_PLAN_CN_BASE_URL"),
|
||||
base_url="https://coding.dashscope.aliyuncs.com/v1",
|
||||
auth_type="api_key",
|
||||
)
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
"""alibaba-coding-plan and alibaba-coding-plan-cn must not both appear in the
|
||||
/model picker off a single shared key (#101122).
|
||||
|
||||
The CN profile now has its own ALIBABA_CODING_PLAN_CN_API_KEY (checked first),
|
||||
keeping the shared ALIBABA_CODING_PLAN_API_KEY / DASHSCOPE_API_KEY as ordered
|
||||
fallbacks so existing CN users are not broken. The picker hides a ``-cn`` row
|
||||
whose only lit vars are shared with a lit non-CN sibling row.
|
||||
"""
|
||||
|
||||
import os
|
||||
from unittest.mock import patch
|
||||
|
||||
from hermes_cli.model_switch import list_authenticated_providers
|
||||
|
||||
_CLEAR = {k: "" for k in ("ALIBABA_CODING_PLAN_API_KEY", "ALIBABA_CODING_PLAN_CN_API_KEY", "DASHSCOPE_API_KEY")}
|
||||
|
||||
|
||||
def _alibaba_slugs(current_provider=""):
|
||||
return [p["slug"] for p in list_authenticated_providers(current_provider=current_provider) if "coding-plan" in p["slug"]]
|
||||
|
||||
|
||||
@patch.dict(os.environ, {**_CLEAR, "ALIBABA_CODING_PLAN_CN_API_KEY": "sk-cn-fake"}, clear=False)
|
||||
def test_alibaba_cn_appears_when_only_cn_key_set():
|
||||
assert _alibaba_slugs() == ["alibaba-coding-plan-cn"]
|
||||
|
||||
|
||||
@patch.dict(os.environ, {**_CLEAR, "ALIBABA_CODING_PLAN_API_KEY": "sk-intl-fake"}, clear=False)
|
||||
def test_alibaba_cn_does_not_appear_when_only_intl_key_set():
|
||||
"""#101122: the shared intl key alone must light only the intl row."""
|
||||
assert _alibaba_slugs() == ["alibaba-coding-plan"]
|
||||
Reference in New Issue
Block a user