

























@@ -10,7 +10,6 @@ import {
1010import { captureEnv } from "openclaw/plugin-sdk/test-env";
1111import { afterEach, describe, expect, it, vi } from "vitest";
1212import {
13-applyDeepInfraProviderConfig,
1413applyDeepInfraConfig,
1514DEEPINFRA_BASE_URL,
1615DEEPINFRA_DEFAULT_MODEL_REF,
@@ -36,53 +35,6 @@ describe("DeepInfra provider config", () => {
3635});
3736});
383739-describe("applyDeepInfraProviderConfig", () => {
40-it("does not set provider models (discovery populates them at runtime)", () => {
41-const result = applyDeepInfraProviderConfig(emptyCfg, DEEPINFRA_DEFAULT_MODEL_REF);
42-expect(result.models?.providers?.deepinfra).toBeUndefined();
43-});
44-45-it("sets DeepInfra alias on the provided model ref", () => {
46-const result = applyDeepInfraProviderConfig(emptyCfg, DEEPINFRA_DEFAULT_MODEL_REF);
47-const agentModel = result.agents?.defaults?.models?.[DEEPINFRA_DEFAULT_MODEL_REF];
48-expect(agentModel).toEqual({ alias: "DeepInfra" });
49-});
50-51-it("attaches the alias to a non-default model ref when provided", () => {
52-const fallbackRef = "deepinfra/other/awesome-model";
53-const result = applyDeepInfraProviderConfig(emptyCfg, fallbackRef);
54-expect(result.agents?.defaults?.models?.[fallbackRef]?.alias).toBe("DeepInfra");
55-expect(result.agents?.defaults?.models?.[DEEPINFRA_DEFAULT_MODEL_REF]).toBeUndefined();
56-});
57-58-it("preserves existing alias if already set", () => {
59-const cfg: OpenClawConfig = {
60-agents: {
61-defaults: {
62-models: {
63-[DEEPINFRA_DEFAULT_MODEL_REF]: { alias: "My Custom Alias" },
64-},
65-},
66-},
67-};
68-const result = applyDeepInfraProviderConfig(cfg, DEEPINFRA_DEFAULT_MODEL_REF);
69-const agentModel = result.agents?.defaults?.models?.[DEEPINFRA_DEFAULT_MODEL_REF];
70-expect(agentModel?.alias).toBe("My Custom Alias");
71-});
72-73-it("does not change the default model selection", () => {
74-const cfg: OpenClawConfig = {
75-agents: {
76-defaults: {
77-model: { primary: "openai/gpt-5" },
78-},
79-},
80-};
81-const result = applyDeepInfraProviderConfig(cfg, DEEPINFRA_DEFAULT_MODEL_REF);
82-expect(resolveAgentModelPrimaryValue(result.agents?.defaults?.model)).toBe("openai/gpt-5");
83-});
84-});
85-8638describe("applyDeepInfraConfig", () => {
8739it("sets the provided model ref as the primary default", () => {
8840const result = applyDeepInfraConfig(emptyCfg, DEEPINFRA_DEFAULT_MODEL_REF);
@@ -103,6 +55,22 @@ describe("DeepInfra provider config", () => {
10355expect(resolveAgentModelPrimaryValue(result.agents?.defaults?.model)).toBe(fallbackRef);
10456expect(result.agents?.defaults?.models?.[fallbackRef]?.alias).toBe("DeepInfra");
10557});
58+59+it("preserves an existing alias on the selected model", () => {
60+const cfg: OpenClawConfig = {
61+agents: {
62+defaults: {
63+models: {
64+[DEEPINFRA_DEFAULT_MODEL_REF]: { alias: "My Custom Alias" },
65+},
66+},
67+},
68+};
69+const result = applyDeepInfraConfig(cfg, DEEPINFRA_DEFAULT_MODEL_REF);
70+expect(result.agents?.defaults?.models?.[DEEPINFRA_DEFAULT_MODEL_REF]?.alias).toBe(
71+"My Custom Alias",
72+);
73+});
10674});
1077510876describe("env var resolution", () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。