mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-28 06:29:32 +00:00
fix: honor provider aliases in model rows
This commit is contained in:
@@ -17,6 +17,7 @@ import type { ModelListAuthIndex } from "./list.auth-index.js";
|
||||
import type { ListRowModel } from "./list.model-row.js";
|
||||
import { toModelRow } from "./list.model-row.js";
|
||||
import type { ConfiguredEntry, ModelRow } from "./list.types.js";
|
||||
import { canonicalizeModelCatalogProviderAlias } from "./provider-aliases.js";
|
||||
import { isLocalBaseUrl, modelKey } from "./shared.js";
|
||||
|
||||
type ConfiguredByKey = Map<string, ConfiguredEntry>;
|
||||
@@ -64,11 +65,26 @@ function loadProviderCatalogModule(): Promise<ProviderCatalogModule> {
|
||||
return providerCatalogModuleLoader.load();
|
||||
}
|
||||
|
||||
function matchesRowFilter(filter: RowFilter, model: { provider: string; baseUrl?: string }) {
|
||||
if (filter.provider && normalizeProviderId(model.provider) !== filter.provider) {
|
||||
function matchesProviderFilter(context: RowBuilderContext, provider: string): boolean {
|
||||
const providerFilter = context.filter.provider;
|
||||
if (!providerFilter) {
|
||||
return true;
|
||||
}
|
||||
const canonicalProvider = canonicalizeModelCatalogProviderAlias(provider, {
|
||||
cfg: context.cfg,
|
||||
metadataSnapshot: context.metadataSnapshot,
|
||||
});
|
||||
return normalizeProviderId(canonicalProvider) === providerFilter;
|
||||
}
|
||||
|
||||
function matchesRowFilter(
|
||||
context: RowBuilderContext,
|
||||
model: { provider: string; baseUrl?: string },
|
||||
) {
|
||||
if (!matchesProviderFilter(context, model.provider)) {
|
||||
return false;
|
||||
}
|
||||
if (filter.local && !isLocalBaseUrl(model.baseUrl ?? "")) {
|
||||
if (context.filter.local && !isLocalBaseUrl(model.baseUrl ?? "")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -163,7 +179,7 @@ async function appendVisibleRow(params: {
|
||||
if (params.seenKeys?.has(params.key)) {
|
||||
return false;
|
||||
}
|
||||
if (!matchesRowFilter(params.context.filter, params.model)) {
|
||||
if (!matchesRowFilter(params.context, params.model)) {
|
||||
return false;
|
||||
}
|
||||
const normalizedModel = normalizeListRowWithProviderPlugin({
|
||||
@@ -438,10 +454,7 @@ export async function appendCatalogSupplementRows(params: {
|
||||
metadataSnapshot: params.context.metadataSnapshot,
|
||||
});
|
||||
for (const entry of catalog) {
|
||||
if (
|
||||
params.context.filter.provider &&
|
||||
normalizeProviderId(entry.provider) !== params.context.filter.provider
|
||||
) {
|
||||
if (!matchesProviderFilter(params.context, entry.provider)) {
|
||||
continue;
|
||||
}
|
||||
const key = modelKey(entry.provider, entry.id);
|
||||
@@ -525,10 +538,7 @@ export async function appendConfiguredRows(params: {
|
||||
? (await loadModelResolverModule()).resolveModelWithRegistry
|
||||
: undefined;
|
||||
for (const entry of params.entries) {
|
||||
if (
|
||||
params.context.filter.provider &&
|
||||
normalizeProviderId(entry.ref.provider) !== params.context.filter.provider
|
||||
) {
|
||||
if (!matchesProviderFilter(params.context, entry.ref.provider)) {
|
||||
continue;
|
||||
}
|
||||
const resolvedModel =
|
||||
|
||||
Reference in New Issue
Block a user