|
|
|
import type { AxiosProgressEvent, GenericAbortSignal } from 'axios'
|
|
|
|
import { post } from '@/utils/request'
|
|
|
|
|
|
|
|
export function fetchChatAPI<T = any>(
|
|
|
|
prompt: string,
|
|
|
|
options?: { conversationId?: string; parentMessageId?: string },
|
|
|
|
signal?: GenericAbortSignal,
|
|
|
|
) {
|
|
|
|
return post<T>({
|
|
|
|
url: '/chat',
|
|
|
|
data: { prompt, options },
|
|
|
|
signal,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
/** 实验性质的函数,用于处理聊天过程中的中间结果 */
|
|
|
|
export function fetchChatAPIProcess<T = any>(
|
|
|
|
params: {
|
|
|
|
prompt: string
|
|
|
|
options?: { conversationId?: string; parentMessageId?: string }
|
|
|
|
signal?: GenericAbortSignal
|
|
|
|
onDownloadProgress?: (progressEvent: AxiosProgressEvent) => void },
|
|
|
|
) {
|
|
|
|
return post<T>({
|
|
|
|
url: '/chat-process',
|
|
|
|
data: { prompt: params.prompt, options: params.options },
|
|
|
|
signal: params.signal,
|
|
|
|
onDownloadProgress: params.onDownloadProgress,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
export function fetchChatConfig<T = any>() {
|
|
|
|
return post<T>({
|
|
|
|
url: '/config',
|
|
|
|
})
|
|
|
|
}
|