mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-29 05:25:43 +02:00
fix(regression): normalize model picker provider endpoint aliases
This commit is contained in:
34
src/auto-reply/reply/directive-handling.model-picker.test.ts
Normal file
34
src/auto-reply/reply/directive-handling.model-picker.test.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
buildModelPickerItems,
|
||||
resolveProviderEndpointLabel,
|
||||
} from "./directive-handling.model-picker.js";
|
||||
|
||||
describe("directive-handling.model-picker", () => {
|
||||
it("dedupes provider aliases when building picker items", () => {
|
||||
expect(
|
||||
buildModelPickerItems([
|
||||
{ provider: "z.ai", id: "glm-5" },
|
||||
{ provider: "z-ai", id: "glm-5" },
|
||||
]),
|
||||
).toEqual([{ provider: "zai", model: "glm-5" }]);
|
||||
});
|
||||
|
||||
it("matches provider endpoint labels across canonical aliases", () => {
|
||||
const result = resolveProviderEndpointLabel("z-ai", {
|
||||
models: {
|
||||
providers: {
|
||||
"z.ai": {
|
||||
baseUrl: "https://api.z.ai/api/paas/v4",
|
||||
api: "responses",
|
||||
},
|
||||
},
|
||||
},
|
||||
} as never);
|
||||
|
||||
expect(result).toEqual({
|
||||
endpoint: "https://api.z.ai/api/paas/v4",
|
||||
api: "responses",
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,4 +1,8 @@
|
||||
import { type ModelRef, normalizeProviderId } from "../../agents/model-selection.js";
|
||||
import {
|
||||
findNormalizedProviderValue,
|
||||
type ModelRef,
|
||||
normalizeProviderId,
|
||||
} from "../../agents/model-selection.js";
|
||||
import type { OpenClawConfig } from "../../config/config.js";
|
||||
|
||||
export type ModelPickerCatalogEntry = {
|
||||
@@ -88,7 +92,7 @@ export function resolveProviderEndpointLabel(
|
||||
string,
|
||||
{ baseUrl?: string; api?: string } | undefined
|
||||
>;
|
||||
const entry = providers[normalized];
|
||||
const entry = findNormalizedProviderValue(providers, normalized);
|
||||
const endpoint = entry?.baseUrl?.trim();
|
||||
const api = entry?.api?.trim();
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user