import type { AxiosProgressEvent, GenericAbortSignal } from 'axios' import { post, get, put } from '@/utils/request' import { useAuthStore, useSettingStore } from '@/store' export function fetchChatAPI( prompt: string, options?: { conversationId?: string; parentMessageId?: string }, signal?: GenericAbortSignal ) { return post({ url: '/chat/chat', data: { prompt, options }, signal }) } export function fetchChatConfig() { return post({ url: '/chat/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 } console.log(authStore.isChatGPTAPI) // if (authStore.isChatGPTAPI) { data = { ...data, systemMessage: settingStore.systemMessage, temperature: settingStore.temperature, top_p: settingStore.top_p } // } return post({ url: '/chat/chat-process1', data, signal: params.signal, onDownloadProgress: params.onDownloadProgress }) } export function fetchSession() { return post({ url: '/chat/session' }) } export function fetchVerify(token: string) { return post({ url: '/verify', data: { token } }) } export function fetchPhoneLogin(phone: string | number, code: string | number, invitor?: string | number) { return post({ url: '/auth/phoneLogin', data: { phone, code, invitor } }) } export function fetchMy() { return get({ url: '/users/my' }) } export function fetchSendVerify(data: { phone: string | number; token: string; sig: string; sessionId: string }) { return post({ url: '/sms/sendVerify', data }) } export function fetchOpenid(code: string) { return get({ url: '/weixin/code2openid', data: { code } }) } export function fetchJsapiSign(url: string) { return post({ url: '/weixin/jsapiSign', data: { url } }) } export function fetchPay(openid: string) { return get({ url: '/weixin/pay', data: { openid } }) } export function fetchRedirectUrl(url: string, state?: string) { return post({ url: '/weixin/redirectUrl', data: { url, state } }) } export function fetchMyMember() { return get({ url: '/membership/get' }) } export function fetchGetMemberships() { return get>({ url: '/membership/plans' }) } export function fetchMembershipRenew(planId: string | number) { return post({ url: '/membership/renew', data: { planId, type: 'JSAPI', openid: window.sessionStorage.getItem('openid') } }) } export function fetchUserBalance() { return get({ url: '/userBalance/get' }) } export function fetchUserBalanceRecords() { return get>({ url: '/userBalance/records/get' }) } export function fetchWithdraw(data: any) { return post>({ url: '/withdraw/apply', data: data }) } export function fetchCommissionRecords() { return get>({ url: '/commission/records/get' }) } export function fetchSystemMessage() { return get({ url: '/sys-config/system_message' }) } export function fetchMasks(num: number) { return get({ url: '/admin/mask/getRandom/' + num }) } export function fetchGetMask(id: any) { return get({ url: `/admin/mask/get/${id}` }) } export function fetchGetMoments(data: any) { return post({ url: `/moments`, data: data }) } export function fetchGetMomentsDetail(id: any) { return get({ url: `/moments/get/${id}` }) } export function fetchChatRoles(num: number) { return get({ url: '/chatRole/getRandom/' + num }) } export function fetchGetChatRole(id: any) { return get({ url: '/chatRole/get/' + id }) } export function fetchSendComment(data: any) { return put({ url: '/comment', data: data }) } export function fetchComments(data: any) { return post({ url: '/comment', data: data }) }