v4.6.9-alpha (#918)

Co-authored-by: Mufei <327958099@qq.com>
Co-authored-by: heheer <71265218+newfish-cmyk@users.noreply.github.com>
This commit is contained in:
Archer
2024-03-04 00:05:25 +08:00
committed by GitHub
parent f9f0b4bffd
commit 42a8184ea0
153 changed files with 4906 additions and 4307 deletions

View File

@@ -1,12 +1,13 @@
import { GET, POST, DELETE, PUT } from '@/web/common/api/request';
import type { ChatHistoryItemType, chatAppListSchema } from '@fastgpt/global/core/chat/type.d';
import type { ChatHistoryItemType, ChatAppListSchema } from '@fastgpt/global/core/chat/type.d';
import type {
CloseCustomFeedbackParams,
InitChatProps,
InitChatResponse,
InitOutLinkChatProps,
getHistoriesProps
GetHistoriesProps,
InitTeamChatProps
} from '@/global/core/chat/api.d';
import type {
AdminUpdateFeedbackParams,
@@ -16,37 +17,23 @@ import type {
UpdateHistoryProps
} from '@/global/core/chat/api.d';
import { UpdateChatFeedbackProps } from '@fastgpt/global/core/chat/api';
/**
* 根据队伍ID和获取
*/
export const getChatListById = (data: { shareTeamId: string; authToken: string }) =>
POST<chatAppListSchema>(`/proApi/core/chat/init`, data);
/**
* 获取团队分享的对话列表 initTeamChat
* @param data
* @returns
*/
export const getinitTeamChat = (data: { teamId: string; authToken: string; appId: string }) =>
GET(`/proApi/core/chat/initTeamChat`, data);
import { AuthTeamTagTokenProps } from '@fastgpt/global/support/user/team/tag';
import { AppListItemType } from '@fastgpt/global/core/app/type';
/**
* 获取初始化聊天内容
*/
export const getInitChatInfo = (data: InitChatProps) =>
GET<InitChatResponse>(`/core/chat/init`, data);
export const getInitChatInfoTeam = (data: InitChatProps) =>
GET<InitChatResponse>(`/core/chat/init`, data);
export const getInitOutLinkChatInfo = (data: InitOutLinkChatProps) =>
GET<InitChatResponse>(`/core/chat/outLink/init`, data);
export const getTeamChatInfo = (data: { appId: string; chatId: string; outLinkUid?: string }) =>
export const getTeamChatInfo = (data: InitTeamChatProps) =>
GET<InitChatResponse>(`/core/chat/team/init`, data);
/**
* get current window history(appid or shareId)
*/
export const getChatHistories = (data: getHistoriesProps) =>
export const getChatHistories = (data: GetHistoriesProps) =>
POST<ChatHistoryItemType[]>('/core/chat/getHistories', data);
/**
@@ -79,3 +66,18 @@ export const updateChatAdminFeedback = (data: AdminUpdateFeedbackParams) =>
export const closeCustomFeedback = (data: CloseCustomFeedbackParams) =>
POST('/core/chat/feedback/closeCustom', data).catch();
/* team chat */
/**
* Get the app that can be used with this token
*/
export const getMyTokensApps = (data: AuthTeamTagTokenProps) =>
GET<AppListItemType[]>(`/proApi/support/user/team/tag/getAppsByTeamTokens`, data);
/**
* 获取团队分享的对话列表 initTeamChat
* @param data
* @returns
*/
export const getinitTeamChat = (data: { teamId: string; authToken: string; appId: string }) =>
GET(`/proApi/core/chat/initTeamChat`, data);

View File

@@ -4,7 +4,7 @@ import { immer } from 'zustand/middleware/immer';
import type { ChatHistoryItemType } from '@fastgpt/global/core/chat/type.d';
import type {
InitChatResponse,
getHistoriesProps,
GetHistoriesProps,
ClearHistoriesProps,
DelHistoryProps,
UpdateHistoryProps,
@@ -21,7 +21,7 @@ import { defaultChatData } from '@/global/core/chat/constants';
type State = {
histories: ChatHistoryItemType[];
loadHistories: (data: getHistoriesProps) => Promise<null>;
loadHistories: (data: GetHistoriesProps) => Promise<null>;
delOneHistory(data: DelHistoryProps): Promise<void>;
clearHistories(data: ClearHistoriesProps): Promise<void>;
pushHistory: (history: ChatHistoryItemType) => void;

View File

@@ -1,42 +0,0 @@
import { create } from 'zustand';
import { devtools, persist } from 'zustand/middleware';
import { immer } from 'zustand/middleware/immer';
import type { ChatHistoryItemType } from '@fastgpt/global/core/chat/type.d';
import { customAlphabet } from 'nanoid';
const nanoid = customAlphabet(
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWSYZ1234567890_',
24
);
type State = {
localUId: string;
teamShareChatHistory: (ChatHistoryItemType & { delete?: boolean })[];
clearLocalHistory: (shareId?: string) => void;
};
export const useTeamShareChatStore = create<State>()(
devtools(
persist(
immer((set, get) => ({
localUId: `shareChat-${Date.now()}-${nanoid()}`,
teamShareChatHistory: [], // old version field
clearLocalHistory() {
// abandon
set((state) => {
state.teamShareChatHistory = state.teamShareChatHistory.map((item) => ({
...item,
delete: true
}));
});
}
})),
{
name: 'shareChatStore',
partialize: (state) => ({
localUId: state.localUId,
shareChatHistory: state.teamShareChatHistory
})
}
)
)
);