mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-03 03:03:24 -04:00
perf(models): lazy-load heavy deps in models list
This commit is contained in:
@@ -99,6 +99,10 @@ describe("models cli", () => {
|
||||
it("shows help for models auth without error exit", async () => {
|
||||
const program = new Command();
|
||||
program.exitOverride();
|
||||
program.configureOutput({
|
||||
writeOut: () => {},
|
||||
writeErr: () => {},
|
||||
});
|
||||
registerModelsCli(program);
|
||||
|
||||
try {
|
||||
|
||||
@@ -2,11 +2,8 @@ import type { Api, Model } from "@mariozechner/pi-ai";
|
||||
import type { ModelRegistry } from "../../agents/pi-model-discovery.js";
|
||||
import type { RuntimeEnv } from "../../runtime.js";
|
||||
import type { ModelRow } from "./list.types.js";
|
||||
import { ensureAuthProfileStore } from "../../agents/auth-profiles.js";
|
||||
import { resolveForwardCompatModel } from "../../agents/model-forward-compat.js";
|
||||
import { parseModelRef } from "../../agents/model-selection.js";
|
||||
import { resolveModel } from "../../agents/pi-embedded-runner/model.js";
|
||||
import { loadConfig } from "../../config/config.js";
|
||||
import { resolveConfiguredEntries } from "./list.configured.js";
|
||||
import { formatErrorWithStack } from "./list.errors.js";
|
||||
import { loadModelRegistry, toModelRow } from "./list.registry.js";
|
||||
@@ -24,6 +21,8 @@ export async function modelsListCommand(
|
||||
runtime: RuntimeEnv,
|
||||
) {
|
||||
ensureFlagCompatibility(opts);
|
||||
const { loadConfig } = await import("../../config/config.js");
|
||||
const { ensureAuthProfileStore } = await import("../../agents/auth-profiles.js");
|
||||
const cfg = loadConfig();
|
||||
const authStore = ensureAuthProfileStore();
|
||||
const providerFilter = (() => {
|
||||
@@ -111,6 +110,7 @@ export async function modelsListCommand(
|
||||
}
|
||||
}
|
||||
if (!model) {
|
||||
const { resolveModel } = await import("../../agents/pi-embedded-runner/model.js");
|
||||
model = resolveModel(entry.ref.provider, entry.ref.model, undefined, cfg).model;
|
||||
}
|
||||
if (opts.local && model && !isLocalBaseUrl(model.baseUrl)) {
|
||||
|
||||
Reference in New Issue
Block a user