mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 07:10:42 +00:00
fix(cli): streamline local model probes
This commit is contained in:
@@ -4,7 +4,6 @@ import path from "node:path";
|
||||
import { Readable } from "node:stream";
|
||||
import { pipeline } from "node:stream/promises";
|
||||
import type { Command } from "commander";
|
||||
import { agentCommand } from "../agents/agent-command.js";
|
||||
import { resolveAgentDir, resolveDefaultAgentId } from "../agents/agent-scope.js";
|
||||
import {
|
||||
listProfilesForProvider,
|
||||
@@ -13,6 +12,10 @@ import {
|
||||
import { updateAuthProfileStoreWithLock } from "../agents/auth-profiles/store.js";
|
||||
import { resolveMemorySearchConfig } from "../agents/memory-search.js";
|
||||
import { loadModelCatalog } from "../agents/model-catalog.js";
|
||||
import {
|
||||
completeWithPreparedSimpleCompletionModel,
|
||||
prepareSimpleCompletionModelForAgent,
|
||||
} from "../agents/simple-completion-runtime.js";
|
||||
import { getRuntimeConfig } from "../config/config.js";
|
||||
import { resolveAgentModelPrimaryValue } from "../config/model-input.js";
|
||||
import type { OpenClawConfig } from "../config/types.openclaw.js";
|
||||
@@ -79,7 +82,6 @@ import {
|
||||
runWebSearch,
|
||||
} from "../web-search/runtime.js";
|
||||
import { runCommandWithRuntime } from "./cli-utils.js";
|
||||
import { createDefaultDeps } from "./deps.js";
|
||||
import { removeCommandByName } from "./program/command-tree.js";
|
||||
import { collectOption } from "./program/helpers.js";
|
||||
|
||||
@@ -576,34 +578,54 @@ async function runModelRun(params: {
|
||||
const cfg = getRuntimeConfig();
|
||||
const agentId = resolveDefaultAgentId(cfg);
|
||||
if (params.transport === "local") {
|
||||
const result = await agentCommand(
|
||||
{
|
||||
message: params.prompt,
|
||||
agentId,
|
||||
model: params.model,
|
||||
json: false,
|
||||
modelRun: true,
|
||||
promptMode: "none",
|
||||
cleanupBundleMcpOnRunEnd: true,
|
||||
const prepared = await prepareSimpleCompletionModelForAgent({
|
||||
cfg,
|
||||
agentId,
|
||||
modelRef: params.model,
|
||||
allowMissingApiKeyModes: ["aws-sdk"],
|
||||
skipPiDiscovery: true,
|
||||
});
|
||||
if ("error" in prepared) {
|
||||
throw new Error(prepared.error);
|
||||
}
|
||||
const result = await completeWithPreparedSimpleCompletionModel({
|
||||
model: prepared.model,
|
||||
auth: prepared.auth,
|
||||
context: {
|
||||
messages: [
|
||||
{
|
||||
role: "user",
|
||||
content: params.prompt,
|
||||
timestamp: Date.now(),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
...defaultRuntime,
|
||||
log: () => {},
|
||||
options: {
|
||||
maxTokens:
|
||||
typeof prepared.model.maxTokens === "number" && Number.isFinite(prepared.model.maxTokens)
|
||||
? prepared.model.maxTokens
|
||||
: undefined,
|
||||
},
|
||||
createDefaultDeps(),
|
||||
);
|
||||
});
|
||||
const text = result.content
|
||||
.map((block) => (block.type === "text" ? block.text : ""))
|
||||
.join("")
|
||||
.trim();
|
||||
return {
|
||||
ok: true,
|
||||
capability: "model.run",
|
||||
transport: "local" as const,
|
||||
provider: result?.meta?.agentMeta?.provider,
|
||||
model: result?.meta?.agentMeta?.model,
|
||||
provider: prepared.selection.provider,
|
||||
model: prepared.selection.modelId,
|
||||
attempts: [],
|
||||
outputs: (result?.payloads ?? []).map((payload) => ({
|
||||
text: payload.text,
|
||||
mediaUrl: payload.mediaUrl,
|
||||
mediaUrls: payload.mediaUrls,
|
||||
})),
|
||||
outputs: text
|
||||
? [
|
||||
{
|
||||
text,
|
||||
mediaUrl: null,
|
||||
},
|
||||
]
|
||||
: [],
|
||||
} satisfies CapabilityEnvelope;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user