mirror of
https://github.com/openclaw/openclaw.git
synced 2026-02-19 18:39:20 -05:00
test(models): add tests for baseUrl and api inheritance
Add test cases to verify: - baseUrl is inherited from provider when model does not specify it - api is inherited from provider when model does not specify it - model-level api takes precedence over provider-level api - both baseUrl and api can be inherited together Co-Authored-By: Claude (claude-opus-4.5) <noreply@anthropic.com>
This commit is contained in:
committed by
Gustavo Madeira Santana
parent
6bf2f0eee6
commit
4656dcef05
@@ -22,8 +22,70 @@ describe("buildInlineProviderModels", () => {
|
||||
const result = buildInlineProviderModels(providers);
|
||||
|
||||
expect(result).toEqual([
|
||||
{ ...makeModel("alpha-model"), provider: "alpha" },
|
||||
{ ...makeModel("beta-model"), provider: "beta" },
|
||||
{ ...makeModel("alpha-model"), provider: "alpha", baseUrl: undefined, api: undefined },
|
||||
{ ...makeModel("beta-model"), provider: "beta", baseUrl: undefined, api: undefined },
|
||||
]);
|
||||
});
|
||||
|
||||
it("inherits baseUrl from provider when model does not specify it", () => {
|
||||
const providers = {
|
||||
custom: {
|
||||
baseUrl: "http://localhost:8000",
|
||||
models: [makeModel("custom-model")],
|
||||
},
|
||||
};
|
||||
|
||||
const result = buildInlineProviderModels(providers);
|
||||
|
||||
expect(result).toHaveLength(1);
|
||||
expect(result[0].baseUrl).toBe("http://localhost:8000");
|
||||
});
|
||||
|
||||
it("inherits api from provider when model does not specify it", () => {
|
||||
const providers = {
|
||||
custom: {
|
||||
api: "anthropic-messages",
|
||||
models: [makeModel("custom-model")],
|
||||
},
|
||||
};
|
||||
|
||||
const result = buildInlineProviderModels(providers);
|
||||
|
||||
expect(result).toHaveLength(1);
|
||||
expect(result[0].api).toBe("anthropic-messages");
|
||||
});
|
||||
|
||||
it("model-level api takes precedence over provider-level api", () => {
|
||||
const providers = {
|
||||
custom: {
|
||||
api: "openai-chat",
|
||||
models: [{ ...makeModel("custom-model"), api: "anthropic-messages" as const }],
|
||||
},
|
||||
};
|
||||
|
||||
const result = buildInlineProviderModels(providers);
|
||||
|
||||
expect(result).toHaveLength(1);
|
||||
expect(result[0].api).toBe("anthropic-messages");
|
||||
});
|
||||
|
||||
it("inherits both baseUrl and api from provider config", () => {
|
||||
const providers = {
|
||||
custom: {
|
||||
baseUrl: "http://localhost:10000",
|
||||
api: "anthropic-messages",
|
||||
models: [makeModel("claude-opus-4.5")],
|
||||
},
|
||||
};
|
||||
|
||||
const result = buildInlineProviderModels(providers);
|
||||
|
||||
expect(result).toHaveLength(1);
|
||||
expect(result[0]).toMatchObject({
|
||||
provider: "custom",
|
||||
baseUrl: "http://localhost:10000",
|
||||
api: "anthropic-messages",
|
||||
name: "claude-opus-4.5",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user