| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- import type { AxiosProgressEvent, GenericAbortSignal } from 'axios'
- import { post, get } from '@/utils/request'
- import { useAuthStore, useSettingStore } from '@/store'
- export function fetchChatAPI<T = any>(
- prompt: string,
- options?: { conversationId?: string; parentMessageId?: string },
- signal?: GenericAbortSignal
- ) {
- return post<T>({
- url: '/chat/chat',
- data: { prompt, options },
- signal
- })
- }
- export function fetchChatConfig<T = any>() {
- return post<T>({
- url: '/chat/config'
- })
- }
- export function fetchChatAPIProcess<T = any>(params: {
- prompt: string
- options?: { conversationId?: string; parentMessageId?: string }
- signal?: GenericAbortSignal
- onDownloadProgress?: (progressEvent: AxiosProgressEvent) => void
- }) {
- const settingStore = useSettingStore()
- const authStore = useAuthStore()
- let data: Record<string, any> = {
- prompt: params.prompt,
- options: params.options
- }
- if (authStore.isChatGPTAPI) {
- data = {
- ...data,
- systemMessage: settingStore.systemMessage,
- temperature: settingStore.temperature,
- top_p: settingStore.top_p
- }
- }
- return post<T>({
- url: '/chat/chat-process1',
- data,
- signal: params.signal,
- onDownloadProgress: params.onDownloadProgress
- })
- }
- export function fetchSession<T>() {
- return post<T>({
- url: '/chat/session'
- })
- }
- export function fetchVerify<T>(token: string) {
- return post<T>({
- url: '/verify',
- data: { token }
- })
- }
- export function fetchPhoneLogin<T>(phone: string | number, code: string | number, invitor?: string | number) {
- return post<T>({
- url: '/auth/phoneLogin',
- data: { phone, code, invitor }
- })
- }
- export function fetchMy<T>() {
- return get<T>({
- url: '/users/my'
- })
- }
- export function fetchSendVerify<T>(data: { phone: string | number; token: string; sig: string; sessionId: string }) {
- return post<T>({
- url: '/sms/sendVerify',
- data
- })
- }
- export function fetchOpenid<T>(code: string) {
- return get<T>({
- url: '/weixin/code2openid',
- data: { code }
- })
- }
- export function fetchJsapiSign<T>(url: string) {
- return get<T>({
- url: '/weixin/jsapiSign',
- data: { url }
- })
- }
- export function fetchPay<T>(openid: string) {
- return get<T>({
- url: '/weixin/pay',
- data: { openid }
- })
- }
|