From 4960eb712b152641ce12de2855dad2fb950911fa Mon Sep 17 00:00:00 2001 From: icarus Date: Fri, 29 Aug 2025 21:30:26 +0800 Subject: [PATCH] =?UTF-8?q?fix(ApiService):=20=E4=BF=AE=E5=A4=8Dprompt?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E7=B1=BB=E5=9E=8B=E5=B9=B6=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E8=BD=AC=E6=8D=A2=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 根据vercel/ai#8363问题,将prompt参数类型从StreamTextParams['prompt']改为string 当传入prompt参数时自动转换为messages格式 --- src/renderer/src/services/ApiService.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/renderer/src/services/ApiService.ts b/src/renderer/src/services/ApiService.ts index 5a2e793409..bad99aa836 100644 --- a/src/renderer/src/services/ApiService.ts +++ b/src/renderer/src/services/ApiService.ts @@ -95,7 +95,9 @@ type MessagesParams = BaseParams & { type PromptParams = BaseParams & { messages?: never - prompt: StreamTextParams['prompt'] + // prompt: StreamTextParams['prompt'] + // see https://github.com/vercel/ai/issues/8363 + prompt: string } export type FetchChatCompletionParams = MessagesParams | PromptParams @@ -126,6 +128,14 @@ export async function fetchChatCompletion({ if (isSupportedToolUse(assistant)) { mcpTools.push(...(await fetchMcpTools(assistant))) } + if (prompt) { + messages = [ + { + role: 'user', + content: prompt + } + ] + } // 使用 transformParameters 模块构建参数 const {