From 4e3f166d675b4126c85f1e76238ce18678a3e90c Mon Sep 17 00:00:00 2001 From: EvanWu <850123119@qq.com> Date: Tue, 5 Aug 2025 17:42:52 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=20=E9=98=BF=E9=87=8C=E5=B7=B4=E5=B7=B4?= =?UTF-8?q?=E5=8D=83=E9=97=AE=E6=A8=A1=E5=9E=8B=E6=94=AF=E6=8C=81=20Functi?= =?UTF-8?q?on=20calling?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/client/platforms/alibaba.ts | 11 +++++++++-- app/utils.ts | 6 ++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/client/platforms/alibaba.ts b/app/client/platforms/alibaba.ts index ffa483750..46cc3f908 100644 --- a/app/client/platforms/alibaba.ts +++ b/app/client/platforms/alibaba.ts @@ -11,6 +11,7 @@ import { useChatStore, ChatMessageTool, usePluginStore, + FunctionToolItem, } from "@/app/store"; import { preProcessImageContentForAlibabaDashScope, @@ -56,6 +57,7 @@ interface RequestParam { repetition_penalty?: number; top_p: number; max_tokens?: number; + tools?: FunctionToolItem[]; } interface RequestPayload { model: string; @@ -229,11 +231,16 @@ export class QwenApi implements LLMApi { .getAsTools( useChatStore.getState().currentSession().mask?.plugin || [], ); + // console.log("getAsTools", tools, funcs); + const _tools = tools as unknown as FunctionToolItem[]; + if (_tools && _tools.length > 0) { + requestPayload.parameters.tools = _tools; + } return streamWithThink( chatPath, requestPayload, headers, - tools as any, + [], funcs, controller, // parseSSE @@ -266,7 +273,7 @@ export class QwenApi implements LLMApi { }); } else { // @ts-ignore - runTools[index]["function"]["arguments"] += args; + runTools[index]["function"]["arguments"] += args || ""; } } diff --git a/app/utils.ts b/app/utils.ts index 6183e03b0..073d4743c 100644 --- a/app/utils.ts +++ b/app/utils.ts @@ -347,6 +347,12 @@ export function showPlugins(provider: ServiceProvider, model: string) { if (provider == ServiceProvider.Google && !model.includes("vision")) { return true; } + if ( + provider == ServiceProvider.Alibaba && + (model.includes("qwen") || model.includes("deepseek")) + ) { + return true; + } return false; }