mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-06 21:35:52 +08:00
fix(ApiService): 修复prompt参数类型并添加消息转换逻辑
根据vercel/ai#8363问题,将prompt参数类型从StreamTextParams['prompt']改为string 当传入prompt参数时自动转换为messages格式
This commit is contained in:
parent
694ecc5243
commit
4960eb712b
@ -95,7 +95,9 @@ type MessagesParams = BaseParams & {
|
|||||||
|
|
||||||
type PromptParams = BaseParams & {
|
type PromptParams = BaseParams & {
|
||||||
messages?: never
|
messages?: never
|
||||||
prompt: StreamTextParams['prompt']
|
// prompt: StreamTextParams['prompt']
|
||||||
|
// see https://github.com/vercel/ai/issues/8363
|
||||||
|
prompt: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export type FetchChatCompletionParams = MessagesParams | PromptParams
|
export type FetchChatCompletionParams = MessagesParams | PromptParams
|
||||||
@ -126,6 +128,14 @@ export async function fetchChatCompletion({
|
|||||||
if (isSupportedToolUse(assistant)) {
|
if (isSupportedToolUse(assistant)) {
|
||||||
mcpTools.push(...(await fetchMcpTools(assistant)))
|
mcpTools.push(...(await fetchMcpTools(assistant)))
|
||||||
}
|
}
|
||||||
|
if (prompt) {
|
||||||
|
messages = [
|
||||||
|
{
|
||||||
|
role: 'user',
|
||||||
|
content: prompt
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
// 使用 transformParameters 模块构建参数
|
// 使用 transformParameters 模块构建参数
|
||||||
const {
|
const {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user