mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-28 05:11:24 +08:00
refactor(ApiService): 重构 fetchChatCompletion 参数类型定义
将参数类型提取为独立的类型定义,支持 messages 或 prompt 两种参数形式
This commit is contained in:
parent
d4a22d3b0c
commit
84f920e54e
@ -81,21 +81,36 @@ export type FetchChatCompletionOptions = {
|
||||
headers?: Record<string, string>
|
||||
}
|
||||
|
||||
export async function fetchChatCompletion({
|
||||
messages,
|
||||
assistant,
|
||||
options,
|
||||
onChunkReceived,
|
||||
topicId
|
||||
}: {
|
||||
messages: StreamTextParams['messages']
|
||||
type BaseParams = {
|
||||
assistant: Assistant
|
||||
options: FetchChatCompletionOptions
|
||||
onChunkReceived: (chunk: Chunk) => void
|
||||
topicId?: string // 添加 topicId 参数
|
||||
}) {
|
||||
}
|
||||
|
||||
type MessagesParams = BaseParams & {
|
||||
messages: StreamTextParams['messages']
|
||||
prompt?: never
|
||||
}
|
||||
|
||||
type PromptParams = BaseParams & {
|
||||
messages?: never
|
||||
prompt: StreamTextParams['prompt']
|
||||
}
|
||||
|
||||
export type FetchChatCompletionParams = MessagesParams | PromptParams
|
||||
|
||||
export async function fetchChatCompletion({
|
||||
messages,
|
||||
prompt,
|
||||
assistant,
|
||||
options,
|
||||
onChunkReceived,
|
||||
topicId
|
||||
}: FetchChatCompletionParams) {
|
||||
logger.info('fetchChatCompletion called with detailed context', {
|
||||
messageCount: messages?.length || 0,
|
||||
prompt: prompt,
|
||||
assistantId: assistant.id,
|
||||
topicId,
|
||||
hasTopicId: !!topicId,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user