fix: toolNode max tokens and toolDescription i18n (#2655)

* fix: toolNode max tokens

* fix: toolNode max tokens

* fix: workflow  tool desc i18n
This commit is contained in:
Archer
2024-09-09 22:26:20 +08:00
committed by GitHub
parent 6a85c8c2b6
commit 08190c2f0d
7 changed files with 69 additions and 60 deletions

View File

@@ -1,8 +1,7 @@
import MyModal from '@fastgpt/web/components/common/MyModal';
import React, { useEffect } from 'react';
import React, { useEffect, useRef } from 'react';
import { useTranslation } from 'next-i18next';
import { Box, ModalBody } from '@chakra-ui/react';
import { useQuery } from '@tanstack/react-query';
import { checkBalancePayResult } from '@/web/support/wallet/bill/api';
import { useToast } from '@fastgpt/web/hooks/useToast';
import { useRouter } from 'next/router';
@@ -24,52 +23,54 @@ const QRCodePayModal = ({
const router = useRouter();
const { t } = useTranslation();
const { toast } = useToast();
const dom = document.getElementById('payQRCode');
const dom = useRef<HTMLDivElement>(null);
useEffect(() => {
if (dom && window.QRCode) {
new window.QRCode(dom, {
text: codeUrl,
width: 128,
height: 128,
colorDark: '#000000',
colorLight: '#ffffff',
correctLevel: window.QRCode.CorrectLevel.H
});
}
}, [dom]);
useQuery(
[billId],
() => {
if (!billId) return null;
return checkBalancePayResult(billId);
},
{
enabled: !!billId,
refetchInterval: 3000,
onSuccess: async (res) => {
if (!res) return;
try {
await onSuccess?.();
toast({
title: res,
status: 'success'
});
} catch (error) {
toast({
title: getErrText(error),
status: 'error'
});
}
setTimeout(() => {
router.reload();
}, 1000);
let timer: NodeJS.Timeout;
const drawCode = () => {
if (dom.current && window.QRCode && !dom.current.innerHTML) {
new window.QRCode(dom.current, {
text: codeUrl,
width: 128,
height: 128,
colorDark: '#000000',
colorLight: '#ffffff',
correctLevel: window.QRCode.CorrectLevel.H
});
}
}
);
};
const check = async () => {
try {
const res = await checkBalancePayResult(billId);
if (res) {
try {
await onSuccess?.();
toast({
title: res,
status: 'success'
});
setTimeout(() => {
router.reload();
}, 1000);
return;
} catch (error) {
toast({
title: getErrText(error),
status: 'error'
});
}
}
} catch (error) {}
drawCode();
timer = setTimeout(check, 2000);
};
check();
return () => clearTimeout(timer);
}, [billId, onSuccess, toast]);
return (
<MyModal isOpen title={t('common:user.Pay')} iconSrc="/imgs/modal/pay.svg">
@@ -79,7 +80,7 @@ const QRCodePayModal = ({
{tip}
</Box>
)}
<Box id={'payQRCode'} display={'inline-block'} h={'128px'}></Box>
<Box ref={dom} id={'payQRCode'} display={'inline-block'} h={'128px'}></Box>
<Box mt={3} textAlign={'center'}>
{t('common:pay.wechat', { price: readPrice })}
</Box>