mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-26 08:31:55 +00:00
fix: normalize provider catalog template lookup
This commit is contained in:
@@ -49,6 +49,19 @@ describe("buildSingleProviderApiKeyCatalog", () => {
|
||||
expect(result).toEqual({ provider: "Demo Provider", id: "demo-model" });
|
||||
});
|
||||
|
||||
it("matches provider templates across canonical provider aliases", () => {
|
||||
const result = findCatalogTemplate({
|
||||
entries: [
|
||||
{ provider: "z.ai", id: "glm-4.7" },
|
||||
{ provider: "other", id: "fallback" },
|
||||
],
|
||||
providerId: "z-ai",
|
||||
templateIds: ["GLM-4.7"],
|
||||
});
|
||||
|
||||
expect(result).toEqual({ provider: "z.ai", id: "glm-4.7" });
|
||||
});
|
||||
|
||||
it("returns null when api key is missing", async () => {
|
||||
const result = await buildSingleProviderApiKeyCatalog({
|
||||
ctx: createCatalogContext({}),
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { normalizeProviderId } from "../agents/provider-id.js";
|
||||
import type { ModelProviderConfig } from "../config/types.js";
|
||||
import type { ProviderCatalogContext, ProviderCatalogResult } from "./types.js";
|
||||
|
||||
@@ -10,7 +11,7 @@ export function findCatalogTemplate(params: {
|
||||
.map((templateId) =>
|
||||
params.entries.find(
|
||||
(entry) =>
|
||||
entry.provider.toLowerCase() === params.providerId.toLowerCase() &&
|
||||
normalizeProviderId(entry.provider) === normalizeProviderId(params.providerId) &&
|
||||
entry.id.toLowerCase() === templateId.toLowerCase(),
|
||||
),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user