

























@@ -12,7 +12,7 @@ import {
1212QIANFAN_DEFAULT_MODEL_REF,
1313} from "./onboard.js";
141415-function expectRecord<T>(value: T | undefined, label: string): T {
15+function expectRecord<T>(value: T | null | undefined, label: string): NonNullable<T> {
1616if (!value) {
1717throw new Error(`Expected ${label}`);
1818}
@@ -32,9 +32,13 @@ describe("qianfan provider plugin", () => {
3232expect(provider.docsPath).toBe("/providers/qianfan");
3333expect(provider.envVars).toEqual(["QIANFAN_API_KEY"]);
3434expect(provider.auth).toHaveLength(1);
35-expect(resolved).toMatchObject({
36-provider: { id: "qianfan" },
37-method: { id: "api-key" },
35+const resolvedChoice = expectRecord(resolved, "Qianfan provider choice");
36+expect({
37+providerId: resolvedChoice.provider.id,
38+methodId: resolvedChoice.method.id,
39+}).toEqual({
40+providerId: "qianfan",
41+methodId: "api-key",
3842});
3943});
4044@@ -54,24 +58,38 @@ describe("qianfan provider plugin", () => {
5458models.find((model) => model.id === "deepseek-v3.2"),
5559"deepseek model",
5660),
57-).toMatchObject({
61+).toEqual({
5862name: "DEEPSEEK V3.2",
63+id: "deepseek-v3.2",
5964reasoning: true,
6065input: ["text"],
6166contextWindow: 98304,
6267maxTokens: 32768,
68+cost: {
69+input: 0,
70+output: 0,
71+cacheRead: 0,
72+cacheWrite: 0,
73+},
6374});
6475expect(
6576expectRecord(
6677models.find((model) => model.id === "ernie-5.0-thinking-preview"),
6778"ernie model",
6879),
69-).toMatchObject({
80+).toEqual({
7081name: "ERNIE-5.0-Thinking-Preview",
82+id: "ernie-5.0-thinking-preview",
7183reasoning: true,
7284input: ["text", "image"],
7385contextWindow: 119000,
7486maxTokens: 64000,
87+cost: {
88+input: 0,
89+output: 0,
90+cacheRead: 0,
91+cacheWrite: 0,
92+},
7593});
7694});
7795@@ -87,10 +105,8 @@ describe("qianfan provider plugin", () => {
87105const modelsConfig = expectRecord(cfg.models, "models config");
88106const providers = expectRecord(modelsConfig.providers, "model providers");
89107const providerConfig = expectRecord(providers.qianfan, "Qianfan provider config");
90-expect(providerConfig).toMatchObject({
91-api: "openai-completions",
92-baseUrl: "https://qianfan.baidubce.com/v2",
93-});
108+expect(providerConfig.api).toBe("openai-completions");
109+expect(providerConfig.baseUrl).toBe("https://qianfan.baidubce.com/v2");
94110const providerModels = expectRecord(providerConfig.models, "Qianfan provider models");
95111expect(providerModels.map((model) => model.id)).toEqual([
96112"deepseek-v3.2",
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。