Skip to content

Commit 01ace80

Browse files
committed
feat(managed)!: 环境变量改名 QODER_BASE_URL -> QODER_MANAGED_BASE_URL
原名没有 mode 前缀,与 Forward 侧的 QODER_FORWARD_BASE_URL 不对称, 也和 .env.live.example 里已在用的 QODER_MANAGED_BASE_URL 不一致。 改名后 examples 的 prefix + BASE_URL 查找即可覆盖,去掉多余兜底。
1 parent 4088c28 commit 01ace80

4 files changed

Lines changed: 5 additions & 9 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Both clients read their token from the environment. `from qca.forward import Cli
4747
| Setting | Forward | Managed |
4848
|---|---|---|
4949
| Token | `QODER_ACCESS_TOKEN` | `QODER_ACCESS_TOKEN` |
50-
| Base URL | `QODER_FORWARD_BASE_URL` | `QODER_BASE_URL` |
50+
| Base URL | `QODER_FORWARD_BASE_URL` | `QODER_MANAGED_BASE_URL` |
5151
| Default base URL | `https://api.qoder.com/api/v1/forward/` | `https://api.qoder.com/api/v1/cloud/` |
5252

5353
Explicit arguments take precedence over environment variables. The clients never read `.env` files; only the examples load `.env.live`. Other regions, including China, have to be configured explicitly:

examples/common/live.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,7 @@ def load(cls, mode: str, *, env_file: str = ".env.live", region: str | None = No
7070
if not token:
7171
raise ValueError(f"Configure {prefix}PAT or QODER_ACCESS_TOKEN")
7272
suffix = "forward" if mode == "forward" else "cloud"
73-
base = (
74-
values.get(prefix + "BASE_URL")
75-
or (values.get("QODER_BASE_URL") if mode == "managed" else None)
76-
or f"https://api.qoder.com.cn/api/v1/{suffix}"
77-
)
73+
base = values.get(prefix + "BASE_URL") or f"https://api.qoder.com.cn/api/v1/{suffix}"
7874
url = httpx.URL(base)
7975
if (
8076
url.scheme != "https"

src/qca/managed/_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
class Managed(SyncAPIClient):
2121
_default_base_url = "https://api.qoder.com/api/v1/cloud/"
22-
_base_url_env = "QODER_BASE_URL"
22+
_base_url_env = "QODER_MANAGED_BASE_URL"
2323

2424
@cached_property
2525
def agents(self) -> Agents:
@@ -68,7 +68,7 @@ def models(self) -> Models:
6868

6969
class AsyncManaged(AsyncAPIClient):
7070
_default_base_url = "https://api.qoder.com/api/v1/cloud/"
71-
_base_url_env = "QODER_BASE_URL"
71+
_base_url_env = "QODER_MANAGED_BASE_URL"
7272

7373
@cached_property
7474
def agents(self) -> AsyncAgents:

tests/test_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def make_client(handler, cls=Forward, **kwargs):
4141

4242

4343
@pytest.mark.parametrize(
44-
"cls,env,suffix", [(Forward, "QODER_FORWARD_BASE_URL", "forward"), (Managed, "QODER_BASE_URL", "cloud")]
44+
"cls,env,suffix", [(Forward, "QODER_FORWARD_BASE_URL", "forward"), (Managed, "QODER_MANAGED_BASE_URL", "cloud")]
4545
)
4646
def test_environment_defaults_and_explicit_precedence(monkeypatch, cls, env, suffix):
4747
monkeypatch.setenv("QODER_ACCESS_TOKEN", "from-env")

0 commit comments

Comments
 (0)