This commit is contained in:
archer
2023-07-11 15:57:01 +08:00
parent cd77d81135
commit eb768d9c04
47 changed files with 1949 additions and 1280 deletions

View File

@@ -58,15 +58,15 @@ export const putChatHistory = (data: UpdateHistoryProps) =>
*/
export const createShareChat = (
data: ShareChatEditType & {
modelId: string;
appId: string;
}
) => POST<string>(`/chat/shareChat/create`, data);
/**
* get shareChat
*/
export const getShareChatList = (modelId: string) =>
GET<ShareChatSchema[]>(`/chat/shareChat/list?modelId=${modelId}`);
export const getShareChatList = (appId: string) =>
GET<ShareChatSchema[]>(`/chat/shareChat/list`, { appId });
/**
* delete a shareChat
@@ -76,5 +76,5 @@ export const delShareChatById = (id: string) => DELETE(`/chat/shareChat/delete?i
/**
* 初始化分享聊天
*/
export const initShareChatInfo = (data: { shareId: string; password: string }) =>
GET<InitShareChatResponse>(`/chat/shareChat/init?${Obj2Query(data)}`);
export const initShareChatInfo = (data: { shareId: string }) =>
GET<InitShareChatResponse>(`/chat/shareChat/init`, data);

View File

@@ -1,18 +1,23 @@
import { Props } from '@/pages/api/openapi/v1/chat/completions';
import { sseResponseEventEnum } from '@/constants/chat';
import { getErrText } from '@/utils/tools';
import { parseStreamChunk } from '@/utils/adapt';
interface StreamFetchProps {
data: Props;
url?: string;
data: Record<string, any>;
onMessage: (text: string) => void;
abortSignal: AbortController;
}
export const streamFetch = ({ data, onMessage, abortSignal }: StreamFetchProps) =>
export const streamFetch = ({
url = '/api/openapi/v1/chat/completions2',
data,
onMessage,
abortSignal
}: StreamFetchProps) =>
new Promise<{ responseText: string; errMsg: string; newChatId: string | null }>(
async (resolve, reject) => {
try {
const response = await window.fetch('/api/openapi/v1/chat/completions2', {
const response = await window.fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json'

View File

@@ -1,5 +1,6 @@
import type { ChatPopulate, AppSchema } from '@/types/mongoSchema';
import type { ChatItemType } from '@/types/chat';
import { VariableItemType } from '@/types/app';
export interface InitChatResponse {
chatId: string;
@@ -17,13 +18,13 @@ export interface InitChatResponse {
}
export interface InitShareChatResponse {
maxContext: number;
userAvatar: string;
appId: string;
model: {
maxContext: number;
app: {
variableModules?: VariableItemType[];
welcomeText?: string;
name: string;
avatar: string;
intro: string;
};
chatModel: AppSchema['chat']['chatModel']; // 对话模型名
}