mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 14:30:45 +00:00
refactor: plan models list registry loading
This commit is contained in:
@@ -5,7 +5,11 @@ import { normalizeLowercaseStringOrEmpty } from "../../shared/string-coerce.js";
|
||||
import { resolveConfiguredEntries } from "./list.configured.js";
|
||||
import { formatErrorWithStack } from "./list.errors.js";
|
||||
import { loadListModelRegistry } from "./list.registry-load.js";
|
||||
import { appendAllModelRowSources, appendConfiguredModelRowSources } from "./list.row-sources.js";
|
||||
import {
|
||||
appendAllModelRowSources,
|
||||
appendConfiguredModelRowSources,
|
||||
modelRowSourcesRequireRegistry,
|
||||
} from "./list.row-sources.js";
|
||||
import { printModelTable } from "./list.table.js";
|
||||
import type { ModelRow } from "./list.types.js";
|
||||
import { loadModelsConfigWithSource } from "./load-config.js";
|
||||
@@ -55,8 +59,12 @@ export async function modelsListCommand(
|
||||
let availableKeys: Set<string> | undefined;
|
||||
let availabilityErrorMessage: string | undefined;
|
||||
const useProviderCatalogFastPath = Boolean(opts.all && providerFilter === "codex");
|
||||
const shouldLoadRegistry = modelRowSourcesRequireRegistry({
|
||||
all: opts.all,
|
||||
useProviderCatalogFastPath,
|
||||
});
|
||||
try {
|
||||
if (!useProviderCatalogFastPath) {
|
||||
if (shouldLoadRegistry) {
|
||||
const loaded = await loadListModelRegistry(cfg, { providerFilter });
|
||||
modelRegistry = loaded.registry;
|
||||
discoveredKeys = loaded.discoveredKeys;
|
||||
|
||||
@@ -16,6 +16,13 @@ type AllModelRowSources = {
|
||||
useProviderCatalogFastPath: boolean;
|
||||
};
|
||||
|
||||
export function modelRowSourcesRequireRegistry(params: {
|
||||
all?: boolean;
|
||||
useProviderCatalogFastPath: boolean;
|
||||
}): boolean {
|
||||
return !(params.all && params.useProviderCatalogFastPath);
|
||||
}
|
||||
|
||||
export async function appendAllModelRowSources(params: AllModelRowSources): Promise<void> {
|
||||
const seenKeys = appendDiscoveredRows({
|
||||
rows: params.rows,
|
||||
|
||||
Reference in New Issue
Block a user