mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 11:47:41 +00:00
refactor(commands): dedupe auth choice agent model notes
This commit is contained in:
15
src/commands/auth-choice.apply-helpers.ts
Normal file
15
src/commands/auth-choice.apply-helpers.ts
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import type { ApplyAuthChoiceParams } from "./auth-choice.apply.js";
|
||||||
|
|
||||||
|
export function createAuthChoiceAgentModelNoter(
|
||||||
|
params: ApplyAuthChoiceParams,
|
||||||
|
): (model: string) => Promise<void> {
|
||||||
|
return async (model: string) => {
|
||||||
|
if (!params.agentId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await params.prompter.note(
|
||||||
|
`Default model set to ${model} for agent "${params.agentId}".`,
|
||||||
|
"Model configured",
|
||||||
|
);
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
normalizeApiKeyInput,
|
normalizeApiKeyInput,
|
||||||
validateApiKeyInput,
|
validateApiKeyInput,
|
||||||
} from "./auth-choice.api-key.js";
|
} from "./auth-choice.api-key.js";
|
||||||
|
import { createAuthChoiceAgentModelNoter } from "./auth-choice.apply-helpers.js";
|
||||||
import { applyDefaultModelChoice } from "./auth-choice.default-model.js";
|
import { applyDefaultModelChoice } from "./auth-choice.default-model.js";
|
||||||
import { ensureModelAllowlistEntry } from "./model-allowlist.js";
|
import { ensureModelAllowlistEntry } from "./model-allowlist.js";
|
||||||
import {
|
import {
|
||||||
@@ -27,15 +28,7 @@ export async function applyAuthChoiceHuggingface(
|
|||||||
|
|
||||||
let nextConfig = params.config;
|
let nextConfig = params.config;
|
||||||
let agentModelOverride: string | undefined;
|
let agentModelOverride: string | undefined;
|
||||||
const noteAgentModel = async (model: string) => {
|
const noteAgentModel = createAuthChoiceAgentModelNoter(params);
|
||||||
if (!params.agentId) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await params.prompter.note(
|
|
||||||
`Default model set to ${model} for agent "${params.agentId}".`,
|
|
||||||
"Model configured",
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
let hasCredential = false;
|
let hasCredential = false;
|
||||||
let hfKey = "";
|
let hfKey = "";
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import {
|
|||||||
normalizeApiKeyInput,
|
normalizeApiKeyInput,
|
||||||
validateApiKeyInput,
|
validateApiKeyInput,
|
||||||
} from "./auth-choice.api-key.js";
|
} from "./auth-choice.api-key.js";
|
||||||
|
import { createAuthChoiceAgentModelNoter } from "./auth-choice.apply-helpers.js";
|
||||||
import { applyDefaultModelChoice } from "./auth-choice.default-model.js";
|
import { applyDefaultModelChoice } from "./auth-choice.default-model.js";
|
||||||
import {
|
import {
|
||||||
applyAuthProfileConfig,
|
applyAuthProfileConfig,
|
||||||
@@ -23,15 +24,7 @@ export async function applyAuthChoiceXAI(
|
|||||||
|
|
||||||
let nextConfig = params.config;
|
let nextConfig = params.config;
|
||||||
let agentModelOverride: string | undefined;
|
let agentModelOverride: string | undefined;
|
||||||
const noteAgentModel = async (model: string) => {
|
const noteAgentModel = createAuthChoiceAgentModelNoter(params);
|
||||||
if (!params.agentId) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await params.prompter.note(
|
|
||||||
`Default model set to ${model} for agent "${params.agentId}".`,
|
|
||||||
"Model configured",
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
let hasCredential = false;
|
let hasCredential = false;
|
||||||
const optsKey = params.opts?.xaiApiKey?.trim();
|
const optsKey = params.opts?.xaiApiKey?.trim();
|
||||||
|
|||||||
Reference in New Issue
Block a user