| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 |
- 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
- }
- console.log(authStore.isChatGPTAPI)
- // 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 post<T>({
- url: '/weixin/jsapiSign',
- data: { url }
- })
- }
- export function fetchPay<T>(openid: string) {
- return get<T>({
- url: '/weixin/pay',
- data: { openid }
- })
- }
- export function fetchRedirectUrl<T>(url: string, state?: string) {
- return post<T>({
- url: '/weixin/redirectUrl',
- data: { url, state }
- })
- }
- export function fetchMyMember<T>() {
- return get<T>({
- url: '/membership/get'
- })
- }
- export function fetchGetMemberships<T>() {
- return get<Array<T>>({
- url: '/membership/plans'
- })
- }
- export function fetchMembershipRenew<T>(planId: string | number) {
- return post<T>({
- url: '/membership/renew',
- data: {
- planId,
- type: 'JSAPI',
- openid: window.sessionStorage.getItem('openid')
- }
- })
- }
- export function fetchUserBalance<T>() {
- return get<T>({
- url: '/userBalance/get'
- })
- }
- export function fetchUserBalanceRecords<T>() {
- return get<Array<T>>({
- url: '/userBalance/records/get'
- })
- }
- export function fetchWithdraw<T>(data: any) {
- return post<Array<T>>({
- url: '/withdraw/apply',
- data: data
- })
- }
- export function fetchCommissionRecords<T>() {
- return get<Array<T>>({
- url: '/commission/records/get'
- })
- }
- export function fetchSystemMessage<T>() {
- return get<T>({
- url: '/sys-config/system_message'
- })
- }
- export function fetchMasks<T>(num: number) {
- return get<T>({
- url: '/admin/mask/getRandom/' + num
- })
- }
- export function fetchGetMask<T>(id: any) {
- return get<T>({
- url: `/admin/mask/get/${id}`
- })
- }
- export function fetchGetMoments<T>(data: any) {
- return post<T>({
- url: `/moments`,
- data: data
- })
- }
- export function fetchGetMomentsDetail<T>(id: any) {
- return get<T>({
- url: `/moments/get/${id}`
- })
- }
- export function fetchChatRoles<T>(num: number) {
- return get<T>({
- url: '/chatRole/getRandom/' + num
- })
- }
- export function fetchGetChatRole<T>(id: any) {
- return get<T>({
- url: '/chatRole/get/' + id
- })
- }
- export function fetchGetCompany<T>(id: any) {
- return get<T>({
- url: '/org/' + id
- })
- }
|