feat: new ui
This commit is contained in:
@@ -1,18 +1,19 @@
|
||||
import { GET, POST, DELETE } from './request';
|
||||
import type { ChatItemType } from '@/types/chat';
|
||||
import type { ChatItemType, HistoryItemType } from '@/types/chat';
|
||||
import type { InitChatResponse } from './response/chat';
|
||||
import { RequestPaging } from '../types/index';
|
||||
|
||||
/**
|
||||
* 获取初始化聊天内容
|
||||
*/
|
||||
export const getInitChatSiteInfo = (modelId: string, chatId: '' | string) =>
|
||||
export const getInitChatSiteInfo = (modelId: '' | string, chatId: '' | string) =>
|
||||
GET<InitChatResponse>(`/chat/init?modelId=${modelId}&chatId=${chatId}`);
|
||||
|
||||
/**
|
||||
* 获取历史记录
|
||||
*/
|
||||
export const getChatHistory = () =>
|
||||
GET<{ _id: string; title: string; modelId: string }[]>('/chat/getHistory');
|
||||
export const getChatHistory = (data: RequestPaging) =>
|
||||
POST<HistoryItemType[]>('/chat/getHistory', data);
|
||||
|
||||
/**
|
||||
* 删除一条历史记录
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { getToken } from '../utils/user';
|
||||
import { SYSTEM_PROMPT_HEADER, NEW_CHATID_HEADER } from '@/constants/chat';
|
||||
|
||||
interface StreamFetchProps {
|
||||
@@ -14,8 +13,7 @@ export const streamFetch = ({ url, data, onMessage, abortSignal }: StreamFetchPr
|
||||
const res = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: getToken() || ''
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(data),
|
||||
signal: abortSignal.signal
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
import { GET, POST, DELETE, PUT } from './request';
|
||||
import type { ModelSchema, ModelDataSchema } from '@/types/mongoSchema';
|
||||
import { ModelUpdateParams, ShareModelItem } from '@/types/model';
|
||||
import type { ModelUpdateParams, ShareModelItem } from '@/types/model';
|
||||
import { RequestPaging } from '../types/index';
|
||||
import { Obj2Query } from '@/utils/tools';
|
||||
import type { ModelListResponse } from './response/model';
|
||||
|
||||
/**
|
||||
* 获取模型列表
|
||||
*/
|
||||
export const getMyModels = () => GET<ModelSchema[]>('/model/list');
|
||||
export const getMyModels = () => GET<ModelListResponse>('/model/list');
|
||||
|
||||
/**
|
||||
* 创建一个模型
|
||||
@@ -100,7 +101,7 @@ export const delOneModelData = (dataId: string) =>
|
||||
export const getShareModelList = (data: { searchText?: string } & RequestPaging) =>
|
||||
POST(`/model/share/getModels`, data);
|
||||
/**
|
||||
* 获取收藏的模型
|
||||
* 获取我收藏的模型
|
||||
*/
|
||||
export const getCollectionModels = () => GET<ShareModelItem[]>(`/model/share/getCollection`);
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import axios, { Method, InternalAxiosRequestConfig, AxiosResponse } from 'axios';
|
||||
import { getToken, clearToken } from '@/utils/user';
|
||||
import { clearToken } from '@/utils/user';
|
||||
import { TOKEN_ERROR_CODE } from '@/service/errorCode';
|
||||
|
||||
interface ConfigType {
|
||||
@@ -17,7 +17,7 @@ interface ResponseDataType {
|
||||
*/
|
||||
function requestStart(config: InternalAxiosRequestConfig): InternalAxiosRequestConfig {
|
||||
if (config.headers) {
|
||||
config.headers.Authorization = getToken();
|
||||
// config.headers.Authorization = getToken();
|
||||
}
|
||||
|
||||
return config;
|
||||
|
||||
13
src/api/response/chat.d.ts
vendored
13
src/api/response/chat.d.ts
vendored
@@ -1,12 +1,15 @@
|
||||
import type { ChatPopulate, ModelSchema } from '@/types/mongoSchema';
|
||||
import type { ChatItemType } from '@/types/chat';
|
||||
|
||||
export type InitChatResponse = {
|
||||
export interface InitChatResponse {
|
||||
chatId: string;
|
||||
modelId: string;
|
||||
name: string;
|
||||
avatar: string;
|
||||
intro: string;
|
||||
model: {
|
||||
name: string;
|
||||
avatar: string;
|
||||
intro: string;
|
||||
canUse: boolean;
|
||||
};
|
||||
chatModel: ModelSchema['chat']['chatModel']; // 对话模型名
|
||||
history: ChatItemType[];
|
||||
};
|
||||
}
|
||||
|
||||
6
src/api/response/model.d.ts
vendored
Normal file
6
src/api/response/model.d.ts
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import { ModelListItemType } from '@/types/model';
|
||||
|
||||
export type ModelListResponse = {
|
||||
myModels: ModelListItemType[];
|
||||
myCollectionModels: ModelListItemType[];
|
||||
};
|
||||
1
src/api/response/user.d.ts
vendored
1
src/api/response/user.d.ts
vendored
@@ -1,7 +1,6 @@
|
||||
import type { UserType } from '@/types/user';
|
||||
import type { PromotionRecordSchema } from '@/types/mongoSchema';
|
||||
export interface ResLogin {
|
||||
token: string;
|
||||
user: UserType;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user