mirror of
https://github.com/labring/FastGPT.git
synced 2025-08-01 03:48:24 +00:00
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:
@@ -3,9 +3,9 @@ import { POST } from '../api/request';
|
||||
import { useToast } from '@fastgpt/web/hooks/useToast';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
import { getErrText } from '@fastgpt/global/common/error/utils';
|
||||
import { OutLinkChatAuthProps } from '@fastgpt/global/support/permission/chat';
|
||||
|
||||
export const useSpeech = (props?: { shareId?: string }) => {
|
||||
const { shareId } = props || {};
|
||||
export const useSpeech = (props?: OutLinkChatAuthProps) => {
|
||||
const { t } = useTranslation();
|
||||
const mediaRecorder = useRef<MediaRecorder>();
|
||||
// const mediaStream = useRef<MediaStream>();
|
||||
@@ -79,7 +79,13 @@ export const useSpeech = (props?: { shareId?: string }) => {
|
||||
const duration = Math.round((Date.now() - startTimestamp.current) / 1000);
|
||||
|
||||
formData.append('file', blob, 'recording.webm');
|
||||
formData.append('metadata', JSON.stringify({ duration, shareId }));
|
||||
formData.append(
|
||||
'data',
|
||||
JSON.stringify({
|
||||
...props,
|
||||
duration
|
||||
})
|
||||
);
|
||||
|
||||
setIsTransCription(true);
|
||||
try {
|
||||
|
@@ -3,6 +3,6 @@ export const getDocPath = (path: string) => {
|
||||
const feConfigs = useSystemStore.getState().feConfigs;
|
||||
|
||||
if (!feConfigs?.docUrl) return '';
|
||||
if (feConfigs.docUrl.endsWith('/')) return feConfigs.docUrl;
|
||||
if (feConfigs.docUrl.endsWith('/')) return feConfigs.docUrl.slice(0, -1);
|
||||
return feConfigs.docUrl + path;
|
||||
};
|
||||
|
@@ -4,12 +4,11 @@ import { getErrText } from '@fastgpt/global/common/error/utils';
|
||||
import type { AppTTSConfigType } from '@fastgpt/global/core/module/type.d';
|
||||
import { TTSTypeEnum } from '@/constants/app';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
import { useRouter } from 'next/router';
|
||||
import type { OutLinkChatAuthProps } from '@fastgpt/global/support/permission/chat.d';
|
||||
|
||||
export const useAudioPlay = (props?: { ttsConfig?: AppTTSConfigType }) => {
|
||||
export const useAudioPlay = (props?: OutLinkChatAuthProps & { ttsConfig?: AppTTSConfigType }) => {
|
||||
const { t } = useTranslation();
|
||||
const { shareId } = useRouter().query as { shareId?: string };
|
||||
const { ttsConfig } = props || {};
|
||||
const { ttsConfig, shareId, outLinkUid, teamId, teamToken } = props || {};
|
||||
const { toast } = useToast();
|
||||
const [audio, setAudio] = useState<HTMLAudioElement>();
|
||||
const [audioLoading, setAudioLoading] = useState(false);
|
||||
@@ -63,7 +62,10 @@ export const useAudioPlay = (props?: { ttsConfig?: AppTTSConfigType }) => {
|
||||
chatItemId,
|
||||
ttsConfig,
|
||||
input: text,
|
||||
shareId
|
||||
shareId,
|
||||
outLinkUid,
|
||||
teamId,
|
||||
teamToken
|
||||
})
|
||||
});
|
||||
setAudioLoading(false);
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
|
@@ -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
|
||||
})
|
||||
}
|
||||
)
|
||||
)
|
||||
);
|
@@ -1,7 +1,7 @@
|
||||
import { GET, POST, PUT } from '@/web/common/api/request';
|
||||
import { hashStr } from '@fastgpt/global/common/string/tools';
|
||||
import type { ResLogin } from '@/global/support/api/userRes.d';
|
||||
import { UserAuthTypeEnum } from '@fastgpt/global/support/user/constant';
|
||||
import { UserAuthTypeEnum } from '@fastgpt/global/support/user/auth/constants';
|
||||
import { UserUpdateParams } from '@/types/user';
|
||||
import { UserType } from '@fastgpt/global/support/user/type.d';
|
||||
import type {
|
||||
@@ -9,6 +9,7 @@ import type {
|
||||
OauthLoginProps,
|
||||
PostLoginProps
|
||||
} from '@fastgpt/global/support/user/api.d';
|
||||
import { GetWXLoginQRResponse } from '@fastgpt/global/support/user/login/api.d';
|
||||
|
||||
export const sendAuthCode = (data: {
|
||||
username: string;
|
||||
@@ -71,3 +72,9 @@ export const postLogin = ({ password, ...props }: PostLoginProps) =>
|
||||
export const loginOut = () => GET('/support/user/account/loginout');
|
||||
|
||||
export const putUserInfo = (data: UserUpdateParams) => PUT('/support/user/account/update', data);
|
||||
|
||||
export const getWXLoginQR = () =>
|
||||
GET<GetWXLoginQRResponse>('/proApi/support/user/account/login/wx/getQR');
|
||||
|
||||
export const getWXLoginResult = (code: string) =>
|
||||
GET<ResLogin>(`/proApi/support/user/account/login/wx/getResult`, { code });
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import { useState, useMemo, useCallback } from 'react';
|
||||
import { sendAuthCode } from '@/web/support/user/api';
|
||||
import { UserAuthTypeEnum } from '@fastgpt/global/support/user/constant';
|
||||
import { UserAuthTypeEnum } from '@fastgpt/global/support/user/auth/constants';
|
||||
import { useToast } from '@fastgpt/web/hooks/useToast';
|
||||
import { getErrText } from '@fastgpt/global/common/error/utils';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
|
@@ -8,7 +8,7 @@ import {
|
||||
UpdateTeamMemberProps,
|
||||
UpdateTeamProps
|
||||
} from '@fastgpt/global/support/user/team/controller.d';
|
||||
import type { TeamTagsSchema } from '@fastgpt/global/support/user/team/type';
|
||||
import type { TeamTagItemType, TeamTagSchema } from '@fastgpt/global/support/user/team/type';
|
||||
import {
|
||||
TeamItemType,
|
||||
TeamMemberItemType,
|
||||
@@ -25,14 +25,6 @@ export const putUpdateTeam = (data: UpdateTeamProps) =>
|
||||
PUT(`/proApi/support/user/team/update`, data);
|
||||
export const putSwitchTeam = (teamId: string) =>
|
||||
PUT<string>(`/proApi/support/user/team/switch`, { teamId });
|
||||
export const updateTags = (teamId: string, tagsUrl: string) =>
|
||||
POST<TeamTagsSchema[]>(`/proApi/support/user/team/tags/asyncTags`, { teamId, tagsUrl });
|
||||
export const getTeamsTags = (teamId: string) =>
|
||||
GET(`/proApi/support/user/team/tags/list`, { teamId });
|
||||
export const putUpdateTeamTags = (data: any) =>
|
||||
PUT(`/proApi/support/user/team/tags/updateUrl`, data);
|
||||
export const insertTeamsTags = (tags: Array<any>) =>
|
||||
POST(`/proApi/support/user/team/tags/create`, tags);
|
||||
|
||||
/* --------------- team member ---------------- */
|
||||
export const getTeamMembers = (teamId: string) =>
|
||||
@@ -50,6 +42,11 @@ export const updateInviteResult = (data: UpdateInviteProps) =>
|
||||
export const delLeaveTeam = (teamId: string) =>
|
||||
DELETE('/proApi/support/user/team/member/leave', { teamId });
|
||||
|
||||
/* --------------- team tags ---------------- */
|
||||
export const getTeamsTags = () => GET<TeamTagSchema[]>(`/proApi/support/user/team/tag/list`);
|
||||
export const loadTeamTagsByDomain = (domain: string) =>
|
||||
GET<TeamTagItemType[]>(`/proApi/support/user/team/tag/async`, { domain });
|
||||
|
||||
/* team limit */
|
||||
export const checkTeamExportDatasetLimit = (datasetId: string) =>
|
||||
GET(`/support/user/team/limit/exportDatasetLimit`, { datasetId });
|
||||
|
Reference in New Issue
Block a user