From 125a7d795f87fbfdb0e25b07730e79471f873fb5 Mon Sep 17 00:00:00 2001 From: QiuYang Shen <1741258352@qq.com> Date: Mon, 28 Jul 2025 11:39:17 +0800 Subject: [PATCH 1/2] feat: add tool call support for moonshot models --- core/llm/autodetect.ts | 1 + core/llm/toolSupport.ts | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/core/llm/autodetect.ts b/core/llm/autodetect.ts index a220b5dbd..02e241815 100644 --- a/core/llm/autodetect.ts +++ b/core/llm/autodetect.ts @@ -188,6 +188,7 @@ function autodetectTemplateType(model: string): TemplateType | undefined { lower.includes("gemini") || lower.includes("grok") || lower.includes("moonshot") || + lower.includes("kimi") || lower.includes("mercury") || /^o\d/.test(lower) ) { diff --git a/core/llm/toolSupport.ts b/core/llm/toolSupport.ts index a3b643c34..99bea4baf 100644 --- a/core/llm/toolSupport.ts +++ b/core/llm/toolSupport.ts @@ -285,6 +285,22 @@ export const PROVIDER_TOOL_SUPPORT: Record boolean> = } } + return false; + }, + moonshot: (model) => { + // support moonshot models + // https://platform.moonshot.ai/docs/pricing/chat#concepts + if ( + model.toLowerCase().startsWith("kimi") && + model.toLowerCase() !== "kimi-thinking-preview" + ) { + return true; + } + + if (model.toLowerCase().startsWith("moonshot")) { + return true; + } + return false; }, }; From 9a4603ba9b90412e9f65a290f31ff1c20777165e Mon Sep 17 00:00:00 2001 From: QiuYang Shen <1741258352@qq.com> Date: Wed, 6 Aug 2025 01:02:31 +0800 Subject: [PATCH 2/2] fix: Function 'autodetectTemplateType' has a complexity of 37. Maximum allowed is 36 --- core/llm/autodetect.ts | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/core/llm/autodetect.ts b/core/llm/autodetect.ts index ad0a8c7e9..571a7a700 100644 --- a/core/llm/autodetect.ts +++ b/core/llm/autodetect.ts @@ -155,6 +155,24 @@ function llmCanGenerateInParallel(provider: string, model: string): boolean { return PARALLEL_PROVIDERS.includes(provider); } +function isProviderHandlesTemplatingOrNoTemplateTypeRequired( + modelName: string, +): boolean { + return ( + modelName.includes("gpt") || + modelName.includes("command") || + modelName.includes("aya") || + modelName.includes("chat-bison") || + modelName.includes("pplx") || + modelName.includes("gemini") || + modelName.includes("grok") || + modelName.includes("moonshot") || + modelName.includes("kimi") || + modelName.includes("mercury") || + /^o\d/.test(modelName) + ); +} + function autodetectTemplateType(model: string): TemplateType | undefined { const lower = model.toLowerCase(); @@ -162,21 +180,10 @@ function autodetectTemplateType(model: string): TemplateType | undefined { return "codellama-70b"; } - if ( - lower.includes("gpt") || - lower.includes("command") || - lower.includes("aya") || - lower.includes("chat-bison") || - lower.includes("pplx") || - lower.includes("gemini") || - lower.includes("grok") || - lower.includes("moonshot") || - lower.includes("kimi") || - lower.includes("mercury") || - /^o\d/.test(lower) - ) { + if (isProviderHandlesTemplatingOrNoTemplateTypeRequired(lower)) { return undefined; } + if (lower.includes("llama3") || lower.includes("llama-3")) { return "llama3"; }