import type { AxiosProgressEvent, GenericAbortSignal } from 'axios' import { post } from '@/utils/request' import { useAuthStore, useSettingStore } from '@/store' export function fetchChatAPI( prompt: string, options?: { conversationId?: string; parentMessageId?: string }, signal?: GenericAbortSignal, ) { return post({ url: '/chat', data: { prompt, options }, signal, }) } export function fetchChatConfig() { return post({ url: '/config', }) } export function fetchChatAPIProcess( params: { prompt: string options?: { conversationId?: string; parentMessageId?: string } signal?: GenericAbortSignal onDownloadProgress?: (progressEvent: AxiosProgressEvent) => void }, ) { const settingStore = useSettingStore() const authStore = useAuthStore() let data: Record = { prompt: params.prompt, options: params.options, } if (authStore.isChatGPTAPI) { data = { ...data, systemMessage: settingStore.systemMessage, temperature: settingStore.temperature, top_p: settingStore.top_p, } } return post({ url: '/chat-process', data, signal: params.signal, onDownloadProgress: params.onDownloadProgress, }) } export function fetchSession() { return post({ url: '/session', }) } export function fetchVerify(token: string) { return post({ url: '/verify', data: { token }, }) }