mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 19:08:27 +00:00
Auth: switch Kimi Coding to built-in provider
This commit is contained in:
@@ -19,11 +19,8 @@ import {
|
||||
ZAI_DEFAULT_MODEL_REF,
|
||||
} from "./onboard-auth.credentials.js";
|
||||
import {
|
||||
buildKimiCodeModelDefinition,
|
||||
buildMoonshotModelDefinition,
|
||||
KIMI_CODE_BASE_URL,
|
||||
KIMI_CODE_MODEL_ID,
|
||||
KIMI_CODE_MODEL_REF,
|
||||
KIMI_CODING_MODEL_REF,
|
||||
MOONSHOT_BASE_URL,
|
||||
MOONSHOT_DEFAULT_MODEL_ID,
|
||||
MOONSHOT_DEFAULT_MODEL_REF,
|
||||
@@ -206,29 +203,9 @@ export function applyMoonshotConfig(cfg: OpenClawConfig): OpenClawConfig {
|
||||
|
||||
export function applyKimiCodeProviderConfig(cfg: OpenClawConfig): OpenClawConfig {
|
||||
const models = { ...cfg.agents?.defaults?.models };
|
||||
models[KIMI_CODE_MODEL_REF] = {
|
||||
...models[KIMI_CODE_MODEL_REF],
|
||||
alias: models[KIMI_CODE_MODEL_REF]?.alias ?? "Kimi Code",
|
||||
};
|
||||
|
||||
const providers = { ...cfg.models?.providers };
|
||||
const existingProvider = providers["kimi-code"];
|
||||
const existingModels = Array.isArray(existingProvider?.models) ? existingProvider.models : [];
|
||||
const defaultModel = buildKimiCodeModelDefinition();
|
||||
const hasDefaultModel = existingModels.some((model) => model.id === KIMI_CODE_MODEL_ID);
|
||||
const mergedModels = hasDefaultModel ? existingModels : [...existingModels, defaultModel];
|
||||
const { apiKey: existingApiKey, ...existingProviderRest } = (existingProvider ?? {}) as Record<
|
||||
string,
|
||||
unknown
|
||||
> as { apiKey?: string };
|
||||
const resolvedApiKey = typeof existingApiKey === "string" ? existingApiKey : undefined;
|
||||
const normalizedApiKey = resolvedApiKey?.trim();
|
||||
providers["kimi-code"] = {
|
||||
...existingProviderRest,
|
||||
baseUrl: KIMI_CODE_BASE_URL,
|
||||
api: "openai-completions",
|
||||
...(normalizedApiKey ? { apiKey: normalizedApiKey } : {}),
|
||||
models: mergedModels.length > 0 ? mergedModels : [defaultModel],
|
||||
models[KIMI_CODING_MODEL_REF] = {
|
||||
...models[KIMI_CODING_MODEL_REF],
|
||||
alias: models[KIMI_CODING_MODEL_REF]?.alias ?? "Kimi K2.5",
|
||||
};
|
||||
|
||||
return {
|
||||
@@ -240,10 +217,6 @@ export function applyKimiCodeProviderConfig(cfg: OpenClawConfig): OpenClawConfig
|
||||
models,
|
||||
},
|
||||
},
|
||||
models: {
|
||||
mode: cfg.models?.mode ?? "merge",
|
||||
providers,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -262,7 +235,7 @@ export function applyKimiCodeConfig(cfg: OpenClawConfig): OpenClawConfig {
|
||||
fallbacks: (existingModel as { fallbacks?: string[] }).fallbacks,
|
||||
}
|
||||
: undefined),
|
||||
primary: KIMI_CODE_MODEL_REF,
|
||||
primary: KIMI_CODING_MODEL_REF,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user