ai-chatbot/lib/ai/detail-agent-model-config.ts
Your Name b99eb6cf7a
Some checks failed
Lint / build (20) (push) Has been cancelled
Playwright Tests / test (push) Has been cancelled
fix: enable local moonshot detail agent option
2026-03-21 22:27:00 +08:00

42 lines
1.3 KiB
TypeScript

export const DETAIL_AGENT_LOCAL_MOONSHOT_SETTING_KEY =
"canvas_detail_agent_moonshot_config";
export const DETAIL_AGENT_LOCAL_MOONSHOT_OPTION_ID =
"__moonshot_kimi_k25_local__";
export const DETAIL_AGENT_LOCAL_MOONSHOT_BASE_URL =
"https://api.moonshot.cn/v1";
export const DETAIL_AGENT_LOCAL_MOONSHOT_MODEL_ID = "kimi-k2.5";
export type DetailAgentLocalMoonshotConfig = {
enabled: boolean;
providerName: string;
baseUrl: string;
apiKey: string;
modelId: string;
displayName: string;
};
export function isDetailAgentLocalMoonshotOption(value: unknown) {
return String(value || "").trim() === DETAIL_AGENT_LOCAL_MOONSHOT_OPTION_ID;
}
export function normalizeDetailAgentLocalMoonshotConfig(
value: unknown,
): DetailAgentLocalMoonshotConfig {
const raw =
value && typeof value === "object" && !Array.isArray(value)
? (value as Record<string, unknown>)
: {};
return {
enabled: raw.enabled !== false,
providerName:
String(raw.providerName || "").trim() || "Moonshot AI (Official)",
baseUrl:
String(raw.baseUrl || "").trim() || DETAIL_AGENT_LOCAL_MOONSHOT_BASE_URL,
apiKey: String(raw.apiKey || "").trim(),
modelId:
String(raw.modelId || "").trim() || DETAIL_AGENT_LOCAL_MOONSHOT_MODEL_ID,
displayName: String(raw.displayName || "").trim() || "官方 Kimi K2.5",
};
}