mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 19:31:00 +00:00
test(providers): share onboard primary assertions
This commit is contained in:
@@ -1,13 +1,8 @@
|
||||
import {
|
||||
resolveAgentModelFallbackValues,
|
||||
resolveAgentModelPrimaryValue,
|
||||
} from "openclaw/plugin-sdk/provider-onboard";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
createConfigWithFallbacks,
|
||||
createLegacyProviderConfig,
|
||||
EXPECTED_FALLBACKS,
|
||||
} from "../../test/helpers/plugins/onboard-config.js";
|
||||
expectProviderOnboardMergedLegacyConfig,
|
||||
expectProviderOnboardPrimaryAndFallbacks,
|
||||
} from "../../test/helpers/plugins/provider-onboard.js";
|
||||
import { buildMistralModelDefinition as buildBundledMistralModelDefinition } from "./model-definitions.js";
|
||||
import {
|
||||
applyMistralConfig,
|
||||
@@ -22,31 +17,24 @@ describe("mistral onboard", () => {
|
||||
baseUrl: "https://api.mistral.ai/v1",
|
||||
api: "openai-completions",
|
||||
});
|
||||
expect(resolveAgentModelPrimaryValue(cfg.agents?.defaults?.model)).toBe(
|
||||
MISTRAL_DEFAULT_MODEL_REF,
|
||||
);
|
||||
expectProviderOnboardPrimaryAndFallbacks({
|
||||
applyConfig: applyMistralConfig,
|
||||
modelRef: MISTRAL_DEFAULT_MODEL_REF,
|
||||
});
|
||||
});
|
||||
|
||||
it("merges Mistral models and keeps existing provider overrides", () => {
|
||||
const cfg = applyMistralProviderConfig(
|
||||
createLegacyProviderConfig({
|
||||
providerId: "mistral",
|
||||
api: "anthropic-messages",
|
||||
modelId: "custom-model",
|
||||
modelName: "Custom",
|
||||
}),
|
||||
);
|
||||
|
||||
expect(cfg.models?.providers?.mistral?.baseUrl).toBe("https://api.mistral.ai/v1");
|
||||
expect(cfg.models?.providers?.mistral?.api).toBe("openai-completions");
|
||||
expect(cfg.models?.providers?.mistral?.apiKey).toBe("old-key");
|
||||
expect(cfg.models?.providers?.mistral?.models.map((m) => m.id)).toEqual([
|
||||
"custom-model",
|
||||
"mistral-large-latest",
|
||||
]);
|
||||
const mistralDefault = cfg.models?.providers?.mistral?.models.find(
|
||||
(model) => model.id === "mistral-large-latest",
|
||||
);
|
||||
const provider = expectProviderOnboardMergedLegacyConfig({
|
||||
applyProviderConfig: applyMistralProviderConfig,
|
||||
providerId: "mistral",
|
||||
providerApi: "openai-completions",
|
||||
baseUrl: "https://api.mistral.ai/v1",
|
||||
legacyApi: "anthropic-messages",
|
||||
legacyModelId: "custom-model",
|
||||
legacyModelName: "Custom",
|
||||
});
|
||||
expect(provider?.models.map((m) => m.id)).toEqual(["custom-model", "mistral-large-latest"]);
|
||||
const mistralDefault = provider?.models.find((model) => model.id === "mistral-large-latest");
|
||||
expect(mistralDefault?.contextWindow).toBe(262144);
|
||||
expect(mistralDefault?.maxTokens).toBe(16384);
|
||||
});
|
||||
@@ -69,11 +57,4 @@ describe("mistral onboard", () => {
|
||||
const cfg = applyMistralProviderConfig({});
|
||||
expect(cfg.agents?.defaults?.models?.[MISTRAL_DEFAULT_MODEL_REF]?.alias).toBe("Mistral");
|
||||
});
|
||||
|
||||
it("preserves existing model fallbacks", () => {
|
||||
const cfg = applyMistralConfig(createConfigWithFallbacks());
|
||||
expect(resolveAgentModelFallbackValues(cfg.agents?.defaults?.model)).toEqual([
|
||||
...EXPECTED_FALLBACKS,
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user