























@@ -5,6 +5,21 @@ import { capturePluginRegistration } from "openclaw/plugin-sdk/plugin-test-runti
55import { describe, expect, it, vi } from "vitest";
66import plugin from "./index.js";
778+const LITELLM_DEFAULT_MODEL = {
9+id: "claude-opus-4-6",
10+name: "Claude Opus 4.6",
11+reasoning: true,
12+input: ["text", "image"],
13+cost: {
14+input: 0,
15+output: 0,
16+cacheRead: 0,
17+cacheWrite: 0,
18+},
19+contextWindow: 128_000,
20+maxTokens: 8_192,
21+};
22+823function registerProvider() {
924const captured = capturePluginRegistration(plugin);
1025const provider = captured.providers[0];
@@ -43,29 +58,48 @@ describe("litellm plugin", () => {
4358 toApiKeyCredential,
4459} as never);
456046-expect(result?.models?.providers?.litellm?.baseUrl).toBe("https://litellm.example/v1");
47-expect(result?.models?.providers?.litellm?.api).toBe("openai-completions");
48-expect(result?.auth?.profiles?.["litellm:default"]).toEqual({
61+expect(result).toStrictEqual({
62+auth: {
63+profiles: {
64+"litellm:default": {
65+provider: "litellm",
66+mode: "api_key",
67+},
68+},
69+},
70+agents: {
71+defaults: {
72+models: {
73+"litellm/claude-opus-4-6": {
74+alias: "LiteLLM",
75+},
76+},
77+model: {
78+primary: "litellm/claude-opus-4-6",
79+},
80+},
81+},
82+models: {
83+mode: "merge",
84+providers: {
85+litellm: {
86+baseUrl: "https://litellm.example/v1",
87+api: "openai-completions",
88+models: [LITELLM_DEFAULT_MODEL],
89+},
90+},
91+},
92+});
93+expect(resolveApiKey).toHaveBeenCalledWith({
4994provider: "litellm",
50-mode: "api_key",
95+flagValue: "litellm-test-key",
96+flagName: "--litellm-api-key",
97+envVar: "LITELLM_API_KEY",
5198});
52-expect(result?.agents?.defaults?.model).toMatchObject({
53-primary: "litellm/claude-opus-4-6",
99+expect(toApiKeyCredential).toHaveBeenCalledWith({
100+provider: "litellm",
101+resolved: { key: "litellm-test-key", source: "flag" },
54102});
55-expect(resolveApiKey).toHaveBeenCalledWith(
56-expect.objectContaining({
57-provider: "litellm",
58-flagValue: "litellm-test-key",
59-flagName: "--litellm-api-key",
60-envVar: "LITELLM_API_KEY",
61-}),
62-);
63-expect(toApiKeyCredential).toHaveBeenCalledWith(
64-expect.objectContaining({
65-provider: "litellm",
66-resolved: { key: "litellm-test-key", source: "flag" },
67-}),
68-);
69103} finally {
70104rmSync(agentDir, { recursive: true, force: true });
71105}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。