feat: 阿里巴巴千问模型支持 Function calling

This commit is contained in:
EvanWu 2025-08-05 17:42:52 +08:00
parent fe484fd38a
commit 4e3f166d67
2 changed files with 15 additions and 2 deletions

View File

@ -11,6 +11,7 @@ import {
useChatStore, useChatStore,
ChatMessageTool, ChatMessageTool,
usePluginStore, usePluginStore,
FunctionToolItem,
} from "@/app/store"; } from "@/app/store";
import { import {
preProcessImageContentForAlibabaDashScope, preProcessImageContentForAlibabaDashScope,
@ -56,6 +57,7 @@ interface RequestParam {
repetition_penalty?: number; repetition_penalty?: number;
top_p: number; top_p: number;
max_tokens?: number; max_tokens?: number;
tools?: FunctionToolItem[];
} }
interface RequestPayload { interface RequestPayload {
model: string; model: string;
@ -229,11 +231,16 @@ export class QwenApi implements LLMApi {
.getAsTools( .getAsTools(
useChatStore.getState().currentSession().mask?.plugin || [], 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( return streamWithThink(
chatPath, chatPath,
requestPayload, requestPayload,
headers, headers,
tools as any, [],
funcs, funcs,
controller, controller,
// parseSSE // parseSSE
@ -266,7 +273,7 @@ export class QwenApi implements LLMApi {
}); });
} else { } else {
// @ts-ignore // @ts-ignore
runTools[index]["function"]["arguments"] += args; runTools[index]["function"]["arguments"] += args || "";
} }
} }

View File

@ -347,6 +347,12 @@ export function showPlugins(provider: ServiceProvider, model: string) {
if (provider == ServiceProvider.Google && !model.includes("vision")) { if (provider == ServiceProvider.Google && !model.includes("vision")) {
return true; return true;
} }
if (
provider == ServiceProvider.Alibaba &&
(model.includes("qwen") || model.includes("deepseek"))
) {
return true;
}
return false; return false;
} }