@@ -29,7 +29,10 @@ const NotSufficientModal = ({ type }: { type: NotSufficientModalType }) => {
|
||||
[TeamErrEnum.datasetSizeNotEnough]: t('common:support.wallet.Dataset_not_sufficient'),
|
||||
[TeamErrEnum.datasetAmountNotEnough]: t('common:support.wallet.Dataset_amount_not_sufficient'),
|
||||
[TeamErrEnum.teamMemberOverSize]: t('common:support.wallet.Team_member_over_size'),
|
||||
[TeamErrEnum.appAmountNotEnough]: t('common:support.wallet.App_amount_not_sufficient')
|
||||
[TeamErrEnum.appAmountNotEnough]: t('common:support.wallet.App_amount_not_sufficient'),
|
||||
[TeamErrEnum.pluginAmountNotEnough]: t('common:support.wallet.App_amount_not_sufficient'),
|
||||
[TeamErrEnum.websiteSyncNotEnough]: t('common:code_error.team_error.website_sync_not_enough'),
|
||||
[TeamErrEnum.reRankNotEnough]: t('common:code_error.team_error.re_rank_not_enough')
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -4,9 +4,9 @@ import { useTranslation } from 'next-i18next';
|
||||
import { Box, ModalBody } from '@chakra-ui/react';
|
||||
import { checkBalancePayResult } from '@/web/support/wallet/bill/api';
|
||||
import { useToast } from '@fastgpt/web/hooks/useToast';
|
||||
import { getErrText } from '@fastgpt/global/common/error/utils';
|
||||
import LightTip from '@fastgpt/web/components/common/LightTip';
|
||||
import QRCode from 'qrcode';
|
||||
import { useRequest2 } from '@fastgpt/web/hooks/useRequest';
|
||||
|
||||
export type QRPayProps = {
|
||||
readPrice: number;
|
||||
@@ -54,35 +54,16 @@ const QRCodePayModal = ({
|
||||
drawCode();
|
||||
}, [drawCode]);
|
||||
|
||||
useEffect(() => {
|
||||
let timer: NodeJS.Timeout;
|
||||
const check = async () => {
|
||||
try {
|
||||
const res = await checkBalancePayResult(billId);
|
||||
if (res) {
|
||||
try {
|
||||
await onSuccess?.();
|
||||
toast({
|
||||
title: res,
|
||||
status: 'success'
|
||||
});
|
||||
return clearTimeout(timer);
|
||||
} catch (error) {
|
||||
toast({
|
||||
title: getErrText(error),
|
||||
status: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (error) {}
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(check, 2000);
|
||||
};
|
||||
|
||||
check();
|
||||
|
||||
return () => clearTimeout(timer);
|
||||
}, [billId, drawCode, onSuccess, toast]);
|
||||
useRequest2(() => checkBalancePayResult(billId), {
|
||||
manual: false,
|
||||
pollingInterval: 2000,
|
||||
onSuccess: (res) => {
|
||||
if (res) {
|
||||
onSuccess?.();
|
||||
}
|
||||
},
|
||||
errorToast: ''
|
||||
});
|
||||
|
||||
return (
|
||||
<MyModal isOpen title={t('common:user.Pay')} iconSrc="/imgs/modal/pay.svg">
|
||||
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
} from '@fastgpt/service/common/string/tiktoken/index';
|
||||
import { pushDataListToTrainingQueueByCollectionId } from '@fastgpt/service/core/dataset/training/controller';
|
||||
import { loadRequestMessages } from '@fastgpt/service/core/chat/utils';
|
||||
import { llmCompletionsBodyFormat } from '@fastgpt/service/core/ai/utils';
|
||||
import { llmCompletionsBodyFormat, llmStreamResponseToText } from '@fastgpt/service/core/ai/utils';
|
||||
|
||||
const reduceQueue = () => {
|
||||
global.qaQueueLen = global.qaQueueLen > 0 ? global.qaQueueLen - 1 : 0;
|
||||
@@ -44,7 +44,7 @@ export async function generateQA(): Promise<any> {
|
||||
{
|
||||
mode: TrainingModeEnum.qa,
|
||||
retryCount: { $gte: 0 },
|
||||
lockTime: { $lte: addMinutes(new Date(), -6) }
|
||||
lockTime: { $lte: addMinutes(new Date(), -10) }
|
||||
},
|
||||
{
|
||||
lockTime: new Date(),
|
||||
@@ -120,12 +120,12 @@ ${replaceVariable(Prompt_AgentQA.fixedText, { text })}`;
|
||||
model: modelData.model,
|
||||
temperature: 0.3,
|
||||
messages: await loadRequestMessages({ messages, useVision: false }),
|
||||
stream: false
|
||||
stream: true
|
||||
},
|
||||
modelData
|
||||
)
|
||||
});
|
||||
const answer = chatResponse.choices?.[0].message?.content || '';
|
||||
const answer = await llmStreamResponseToText(chatResponse);
|
||||
|
||||
const qaArr = formatSplitText(answer, text); // 格式化后的QA对
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ export async function generateVector(): Promise<any> {
|
||||
{
|
||||
mode: TrainingModeEnum.chunk,
|
||||
retryCount: { $gte: 0 },
|
||||
lockTime: { $lte: addMinutes(new Date(), -6) }
|
||||
lockTime: { $lte: addMinutes(new Date(), -3) }
|
||||
},
|
||||
{
|
||||
lockTime: new Date(),
|
||||
|
||||
@@ -101,6 +101,7 @@ function checkRes(data: ResponseDataType) {
|
||||
*/
|
||||
function responseError(err: any) {
|
||||
console.log('error->', '请求错误', err);
|
||||
const data = err?.response?.data || err;
|
||||
|
||||
if (!err) {
|
||||
return Promise.reject({ message: '未知错误' });
|
||||
@@ -108,8 +109,12 @@ function responseError(err: any) {
|
||||
if (typeof err === 'string') {
|
||||
return Promise.reject({ message: err });
|
||||
}
|
||||
if (typeof data === 'string') {
|
||||
return Promise.reject(data);
|
||||
}
|
||||
|
||||
// 有报错响应
|
||||
if (err?.code in TOKEN_ERROR_CODE || err?.response?.data?.code in TOKEN_ERROR_CODE) {
|
||||
if (data?.code in TOKEN_ERROR_CODE) {
|
||||
if (!['/chat/share', '/chat/team', '/login'].includes(window.location.pathname)) {
|
||||
clearToken();
|
||||
window.location.replace(
|
||||
@@ -120,18 +125,18 @@ function responseError(err: any) {
|
||||
return Promise.reject({ message: i18nT('common:unauth_token') });
|
||||
}
|
||||
if (
|
||||
err?.statusText === TeamErrEnum.aiPointsNotEnough ||
|
||||
err?.statusText === TeamErrEnum.datasetSizeNotEnough ||
|
||||
err?.statusText === TeamErrEnum.datasetAmountNotEnough ||
|
||||
err?.statusText === TeamErrEnum.appAmountNotEnough
|
||||
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
|
||||
) {
|
||||
useSystemStore.getState().setNotSufficientModalType(err.statusText);
|
||||
return Promise.reject(err);
|
||||
useSystemStore.getState().setNotSufficientModalType(data.statusText);
|
||||
return Promise.reject(data);
|
||||
}
|
||||
if (err?.response?.data) {
|
||||
return Promise.reject(err?.response?.data);
|
||||
}
|
||||
return Promise.reject(err);
|
||||
return Promise.reject(data);
|
||||
}
|
||||
|
||||
/* 创建请求实例 */
|
||||
|
||||
@@ -63,7 +63,7 @@ export const useInitApp = () => {
|
||||
|
||||
useRequest2(initFetch, {
|
||||
manual: false,
|
||||
pollingInterval: 300000
|
||||
pollingInterval: 300000 // 5 minutes refresh
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user