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