mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-22 20:37:48 +00:00
feat: chat error msg (#4826)
* perf: i18n * feat: chat error msg * feat: doc
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "app",
|
||||
"version": "4.9.8",
|
||||
"version": "4.9.9",
|
||||
"private": false,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
|
@@ -35,6 +35,7 @@ import {
|
||||
import { addStatisticalDataToHistoryItem } from '@/global/core/chat/utils';
|
||||
import dynamic from 'next/dynamic';
|
||||
import { useMemoizedFn } from 'ahooks';
|
||||
import ChatBoxDivider from '../../../Divider';
|
||||
|
||||
const ResponseTags = dynamic(() => import('./ResponseTags'));
|
||||
|
||||
@@ -371,7 +372,20 @@ const ChatItem = (props: Props) => {
|
||||
</>
|
||||
)}
|
||||
{/* Example: Response tags. A set of dialogs only needs to be displayed once*/}
|
||||
{i === splitAiResponseResults.length - 1 && <>{children}</>}
|
||||
{i === splitAiResponseResults.length - 1 && (
|
||||
<>
|
||||
{/* error message */}
|
||||
{!!chat.errorMsg && (
|
||||
<Box mt={2}>
|
||||
<ChatBoxDivider icon={'common/errorFill'} text={t('chat:error_message')} />
|
||||
<Box fontSize={'xs'} color={'myGray.500'}>
|
||||
{chat.errorMsg}
|
||||
</Box>
|
||||
</Box>
|
||||
)}
|
||||
{children}
|
||||
</>
|
||||
)}
|
||||
{/* 对话框底部的复制按钮 */}
|
||||
{type == ChatRoleEnum.AI &&
|
||||
value[0]?.type !== 'interactive' &&
|
||||
|
@@ -160,7 +160,7 @@ const Standard = ({
|
||||
<Box fontSize={['32px', '42px']} fontWeight={'bold'} color={'myGray.900'}>
|
||||
¥{item.price}
|
||||
</Box>
|
||||
<Box color={'myGray.500'} h={'40px'} fontSize={'xs'}>
|
||||
<Box color={'myGray.500'} minH={'40px'} fontSize={'xs'}>
|
||||
{t(item.desc as any, { title: feConfigs?.systemTitle })}
|
||||
</Box>
|
||||
|
||||
@@ -183,17 +183,6 @@ const Standard = ({
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
// feature:
|
||||
// if (
|
||||
// item.level === myStandardPlan?.nextSubLevel &&
|
||||
// selectSubMode === myStandardPlan?.nextMode
|
||||
// ) {
|
||||
// return (
|
||||
// <Button mt={4} mb={6} w={'100%'} variant={'whiteBase'} isDisabled>
|
||||
// {t('common:support.wallet.subscription.Next plan')}
|
||||
// </Button>
|
||||
// );
|
||||
// }
|
||||
if (isCurrentPlan) {
|
||||
return (
|
||||
<Button
|
||||
@@ -312,7 +301,7 @@ const RowTabs = ({
|
||||
px={'12px'}
|
||||
py={'7px'}
|
||||
userSelect={'none'}
|
||||
w={['150px', '170px']}
|
||||
w={['150px', '190px']}
|
||||
{...(value === item.value
|
||||
? {
|
||||
color: 'white',
|
||||
|
@@ -55,12 +55,14 @@ async function handler(
|
||||
const isPlugin = app.type === AppTypeEnum.plugin;
|
||||
const isOutLink = authType === GetChatTypeEnum.outLink;
|
||||
|
||||
const commonField =
|
||||
'dataId obj value adminFeedback userGoodFeedback userBadFeedback time hideInUI durationSeconds errorMsg';
|
||||
const fieldMap = {
|
||||
[GetChatTypeEnum.normal]: `dataId obj value adminFeedback userBadFeedback userGoodFeedback time hideInUI durationSeconds ${
|
||||
[GetChatTypeEnum.normal]: `${commonField} ${
|
||||
DispatchNodeResponseKeyEnum.nodeResponse
|
||||
} ${loadCustomFeedbacks ? 'customFeedbacks' : ''}`,
|
||||
[GetChatTypeEnum.outLink]: `dataId obj value userGoodFeedback userBadFeedback adminFeedback time hideInUI durationSeconds ${DispatchNodeResponseKeyEnum.nodeResponse}`,
|
||||
[GetChatTypeEnum.team]: `dataId obj value userGoodFeedback userBadFeedback adminFeedback time hideInUI durationSeconds ${DispatchNodeResponseKeyEnum.nodeResponse}`
|
||||
[GetChatTypeEnum.outLink]: `${commonField} ${DispatchNodeResponseKeyEnum.nodeResponse}`,
|
||||
[GetChatTypeEnum.team]: `${commonField} ${DispatchNodeResponseKeyEnum.nodeResponse}`
|
||||
};
|
||||
|
||||
const { total, histories } = await getChatItems({
|
||||
|
@@ -109,6 +109,12 @@ function checkRes(data: ResponseDataType) {
|
||||
*/
|
||||
function responseError(err: any) {
|
||||
console.log('error->', '请求错误', err);
|
||||
const isOutlinkPage = {
|
||||
'/chat/share': true,
|
||||
'/chat/team': true,
|
||||
'/login': true
|
||||
}[window.location.pathname];
|
||||
|
||||
const data = err?.response?.data || err;
|
||||
|
||||
if (!err) {
|
||||
@@ -123,7 +129,7 @@ function responseError(err: any) {
|
||||
|
||||
// 有报错响应
|
||||
if (data?.code in TOKEN_ERROR_CODE) {
|
||||
if (!['/chat/share', '/chat/team', '/login'].includes(window.location.pathname)) {
|
||||
if (!isOutlinkPage) {
|
||||
clearToken();
|
||||
window.location.replace(
|
||||
getWebReqUrl(`/login?lastRoute=${encodeURIComponent(location.pathname + location.search)}`)
|
||||
@@ -133,13 +139,17 @@ function responseError(err: any) {
|
||||
return Promise.reject({ message: i18nT('common:unauth_token') });
|
||||
}
|
||||
if (
|
||||
data?.statusText === TeamErrEnum.aiPointsNotEnough ||
|
||||
data?.statusText === TeamErrEnum.datasetSizeNotEnough ||
|
||||
data?.statusText === TeamErrEnum.datasetAmountNotEnough ||
|
||||
data?.statusText === TeamErrEnum.appAmountNotEnough ||
|
||||
data?.statusText === TeamErrEnum.pluginAmountNotEnough ||
|
||||
data?.statusText === TeamErrEnum.websiteSyncNotEnough ||
|
||||
data?.statusText === TeamErrEnum.reRankNotEnough
|
||||
data?.statusText &&
|
||||
[
|
||||
TeamErrEnum.aiPointsNotEnough,
|
||||
TeamErrEnum.datasetSizeNotEnough,
|
||||
TeamErrEnum.datasetAmountNotEnough,
|
||||
TeamErrEnum.appAmountNotEnough,
|
||||
TeamErrEnum.pluginAmountNotEnough,
|
||||
TeamErrEnum.websiteSyncNotEnough,
|
||||
TeamErrEnum.reRankNotEnough
|
||||
].includes(data?.statusText) &&
|
||||
!isOutlinkPage
|
||||
) {
|
||||
useSystemStore.getState().setNotSufficientModalType(data.statusText);
|
||||
return Promise.reject(data);
|
||||
|
Reference in New Issue
Block a user