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,
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 || "";
}
}

View File

@ -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;
}