From d3f4a739f176f7f4bcc5c38bfcfdf0b7d03eea86 Mon Sep 17 00:00:00 2001 From: binyangzhu000-sudo <224954946+binyangzhu000-sudo@users.noreply.github.com> Date: Wed, 11 Nov 2026 17:01:41 +0800 Subject: [PATCH] [feat] providers: add Atlas Cloud chat provider preset Register Atlas Cloud (https://api.atlascloud.ai/v1), an OpenAI-compatible gateway, as an agent chat provider preset, mirroring the Zhipu and DeepSeek presets. Models come from the gateway's public /v1/models endpoint through the existing discovery flow, so no fixed model list is shipped. The gateway fronts several model families and some of them (Qwen) answer 400 to reasoning_effort low and medium, while high is accepted everywhere. For this host the shared thinking setting sends reasoning_effort only for high; auto, low and medium use the model default. Other hosts are unchanged. Adds node tests for the preset shape, the label in both display languages and the saved connection identity, Python tests for the effort mapping, and the validation commands in the validation guide. Co-Authored-By: Claude Sonnet 5.5 Signed-off-by: binyangzhu000-sudo <224954946+binyangzhu000-sudo@users.noreply.github.com> --- docs/development/validation.md | 8 ++++ .../integrations/chat_completions.py | 5 +++ src/canvas/providerPresets.ts | 9 +++++ tests/providerPresets.test.ts | 38 +++++++++++++++++++ tests/test_atlascloud.py | 22 +++++++++++ 5 files changed, 82 insertions(+) create mode 100644 tests/test_atlascloud.py diff --git a/docs/development/validation.md b/docs/development/validation.md index 5497d4ee6..3e64544db 100644 --- a/docs/development/validation.md +++ b/docs/development/validation.md @@ -560,6 +560,14 @@ OPENDIRECTOR_URL=http://127.0.0.1:18238 ZHIPU_API_KEY=... ZHIPU_SAMPLE=/path/to/ Python 用例使用按真实服务响应录制的模拟 HTTP,检查 `/audio/speech` 只请求非流式 WAV 并按 RIFF/WAVE 字节验收(服务默认返回裸 PCM,且部分错误以 HTTP 200 + JSON 返回)、`1113` 余额不足归为额度而非限流、音色库只列出文档中的 7 个预置音色加 `PRIVATE` 复刻音色、复刻前的真实音频校验(mp3/wav、3–30 秒、10 MB)、复刻成功或失败后都删除上传的样本文件、`POST /voice/delete` 删除及重名/不存在的错误映射、试听只从公网 HTTPS 下载且不带凭据,以及统一生成服务的音色预检与执行快照。真实验收需要已充值且开通 GLM-TTS 的 BigModel 账户;保留预置音色与复刻音色生成的实际音频、复刻到删除的完整流程截图,并确认账户中没有遗留的 `voice-clone-input` 文件。 +Atlas Cloud chat access uses the following checks. The preset has no fixed model list: the provider form discovers models from the gateway's public `/v1/models` endpoint, like the DeepSeek preset. + +```sh +.venv/bin/python -m pytest tests/test_atlascloud.py -q +node --test tests/providerPresets.test.ts +``` + +The Python cases check that only the high thinking level sends reasoning_effort. The gateway serves several model families and some reject low and medium with a 400, so the other levels use the model default. The Node cases check the preset shape, the label in both display languages and the saved connection identity. Neither calls api.atlascloud.ai. Real streaming and model discovery additionally require network access, and chat requires an Atlas Cloud API key; keep the discovered model count, the reply and the status codes as evidence. ### Voice library / 音色库 diff --git a/packages/core/src/opendirector/integrations/chat_completions.py b/packages/core/src/opendirector/integrations/chat_completions.py index 20dd8957e..f06c1a483 100644 --- a/packages/core/src/opendirector/integrations/chat_completions.py +++ b/packages/core/src/opendirector/integrations/chat_completions.py @@ -22,6 +22,11 @@ def chat_payload(config: dict, messages: list[dict], thinking: str) -> dict: # auto so the provider default applies, and fall back to high for unknown levels. if thinking != "auto": value["reasoning_effort"] = thinking_map.get(thinking, thinking_map["auto"]) + elif hostname == "api.atlascloud.ai": + # The gateway fronts many model families and some (Qwen) reject low and medium + # with a 400. Only high is accepted everywhere, so other levels use the model default. + if thinking == "high": + value["reasoning_effort"] = "high" elif thinking != "auto": value["reasoning_effort"] = thinking if len(json.dumps(value, ensure_ascii=False).encode()) > 48 * 1024 * 1024: diff --git a/src/canvas/providerPresets.ts b/src/canvas/providerPresets.ts index cf0f488dc..8760e32d5 100644 --- a/src/canvas/providerPresets.ts +++ b/src/canvas/providerPresets.ts @@ -204,6 +204,15 @@ export const PROVIDER_PRESETS: ProviderPreset[] = [ connectionType: "api", authMode: "bearer", }, + { + id: "atlascloud", + name: "Atlas Cloud", + kinds: ["agent"], + url: "https://api.atlascloud.ai/v1", + protocol: "openai", + connectionType: "api", + authMode: "bearer", + }, { id: "zhipu", logoOrganization: "zai-org", diff --git a/tests/providerPresets.test.ts b/tests/providerPresets.test.ts index bd22c87d4..39d5bcf8d 100644 --- a/tests/providerPresets.test.ts +++ b/tests/providerPresets.test.ts @@ -271,6 +271,44 @@ test("a saved Zhipu agent connection reopens with its provider identity", () => } }); +test("Atlas Cloud preset offers agent chat through the OpenAI-compatible gateway", () => { + const preset = PROVIDER_PRESETS.find((item) => item.id === "atlascloud"); + assert.ok(preset); + assert.equal(preset.name, "Atlas Cloud"); + assert.equal(preset.url, "https://api.atlascloud.ai/v1"); + assert.equal(preset.protocol, "openai"); + assert.equal(preset.connectionType, "api"); + assert.equal(preset.authMode, "bearer"); + assert.deepEqual(preset.kinds, ["agent"]); + assert.equal(preset.modelsByKind, undefined); + assert.ok(providerOptions("agent").some((item) => item.id === "atlascloud")); + for (const kind of ["image", "video", "audio", "vision"] as const) + assert.ok(!providerOptions(kind).some((item) => item.id === "atlascloud")); +}); + +test("Atlas Cloud provider label is the same in both display languages", () => { + const previous = getActiveLocale(); + try { + for (const locale of ["zh-CN", "en-US"] as const) { + setActiveLocale(locale); + assert.equal(providerOptions("agent").find((item) => item.id === "atlascloud")?.name, "Atlas Cloud"); + } + } finally { + setActiveLocale(previous); + } +}); + +test("a saved Atlas Cloud agent connection reopens with its provider identity", () => { + const preset = PROVIDER_PRESETS.find((item) => item.id === "atlascloud")!; + const model: ModelConfig = { + ...preset, id: "saved-atlascloud", kind: "agent", modelId: "deepseek-ai/deepseek-v4-flash", + url: `${preset.url}/`, + inputRules: { profile: "agent", allowedKinds: [], maxImages: 0, maxVideos: 0, maxAudios: 0, videoModes: [] }, + }; + assert.equal(providerPresetFor(model), "atlascloud"); + assert.equal(providerPresetFor({ ...model, url: "https://other.test/v1" }), "custom"); +}); + test("a saved MOSS image connection reopens with its provider identity", () => { const preset = PROVIDER_PRESETS.find((item) => item.id === "moss"); assert.ok(preset); diff --git a/tests/test_atlascloud.py b/tests/test_atlascloud.py new file mode 100644 index 000000000..72ae867ee --- /dev/null +++ b/tests/test_atlascloud.py @@ -0,0 +1,22 @@ +"""Atlas Cloud chat requests send reasoning_effort only at the level every model family accepts.""" +from opendirector.integrations.chat_completions import chat_payload + + +ATLAS = {"modelId": "deepseek-ai/deepseek-v4-flash", "url": "https://api.atlascloud.ai/v1"} + + +def test_atlascloud_sends_reasoning_effort_only_for_high(): + assert chat_payload(ATLAS, [], "high")["reasoning_effort"] == "high" + for level in ("auto", "low", "medium"): + assert "reasoning_effort" not in chat_payload(ATLAS, [], level) + + +def test_atlascloud_base_fields_and_other_hosts_unchanged(): + payload = chat_payload(ATLAS, [{"role": "user", "content": "hi"}], "high") + assert payload["model"] == "deepseek-ai/deepseek-v4-flash" + assert payload["stream"] is True + assert payload["max_tokens"] == 8192 + assert "thinking" not in payload + assert payload["messages"] == [{"role": "user", "content": "hi"}] + other = chat_payload({"modelId": "x", "url": "https://api.example.com/v1"}, [], "medium") + assert other["reasoning_effort"] == "medium"