mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-09 07:22:55 +00:00
* refactor: extract llm core packages * chore: drop generated llm package artifacts * fix: align llm package export artifacts * test: fix moving main CI expectations * fix: align llm core subpath aliases * fix: use llm package exports * fix: stabilize llm package boundary artifacts * fix: sync llm boundary path contract * test: isolate crabbox provider env * test: pin crabbox configured-provider cases * test: apply crabbox lease provider override
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
import { createAssistantMessageEventStream, type Model } from "@openclaw/llm-core";
|
|
import { afterEach, describe, expect, it } from "vitest";
|
|
import { getApiProvider, registerApiProvider, unregisterApiProviders } from "./api-registry.js";
|
|
|
|
const TEST_SOURCE_ID = "test:llm-runtime-api-registry";
|
|
|
|
const model = {
|
|
id: "test-model",
|
|
name: "Test Model",
|
|
api: "test-api",
|
|
provider: "test-provider",
|
|
baseUrl: "https://example.invalid",
|
|
input: ["text"],
|
|
reasoning: false,
|
|
contextWindow: 1000,
|
|
maxTokens: 100,
|
|
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
} satisfies Model;
|
|
|
|
describe("LLM API registry", () => {
|
|
afterEach(() => {
|
|
unregisterApiProviders(TEST_SOURCE_ID);
|
|
});
|
|
|
|
it("rejects mismatched model API calls", () => {
|
|
registerApiProvider(
|
|
{
|
|
api: "test-api",
|
|
stream: () => createAssistantMessageEventStream(),
|
|
streamSimple: () => createAssistantMessageEventStream(),
|
|
},
|
|
TEST_SOURCE_ID,
|
|
);
|
|
|
|
const provider = getApiProvider("test-api");
|
|
expect(provider).toBeDefined();
|
|
expect(() => provider?.streamSimple({ ...model, api: "other-api" }, { messages: [] })).toThrow(
|
|
"Mismatched api: other-api expected test-api",
|
|
);
|
|
});
|
|
});
|