4.8.10 test (#2573)

* feat: more debug response

* fix: debug edge status

* perf: doc

* fix: workflow edge check

* perf: i18n

* package.json

* perf: markdown mask
This commit is contained in:
Archer
2024-08-29 23:19:39 +08:00
committed by GitHub
parent 813eaacfd0
commit 6d00f73e91
22 changed files with 103 additions and 92 deletions

View File

@@ -1,9 +1,8 @@
import React, { useEffect, useMemo } from 'react';
import React, { useMemo } from 'react';
import { Box, Flex } from '@chakra-ui/react';
import { useRouter } from 'next/router';
import { useLoading } from '@fastgpt/web/hooks/useLoading';
import { useSystemStore } from '@/web/common/system/useSystemStore';
import { throttle } from 'lodash';
import { useQuery } from '@tanstack/react-query';
import { useUserStore } from '@/web/support/user/useUserStore';
import { getUnreadCount } from '@/web/support/user/inform/api';

View File

@@ -3,7 +3,7 @@ import { Box, ImageProps, Skeleton } from '@chakra-ui/react';
import MyPhotoView from '@fastgpt/web/components/common/Image/PhotoView';
import { useBoolean } from 'ahooks';
const MdImage = ({ src, ...props }: { src?: string; forbidImgPreview?: boolean } & ImageProps) => {
const MdImage = ({ src, ...props }: { src?: string } & ImageProps) => {
const [isLoaded, { setTrue }] = useBoolean(false);
const [renderSrc, setRenderSrc] = useState(src);

View File

@@ -10,7 +10,7 @@ import RehypeExternalLinks from 'rehype-external-links';
import styles from './index.module.scss';
import dynamic from 'next/dynamic';
import { Link, Button } from '@chakra-ui/react';
import { Link, Button, Box } from '@chakra-ui/react';
import MyTooltip from '@fastgpt/web/components/common/MyTooltip';
import { useTranslation } from 'next-i18next';
import { EventNameEnum, eventBus } from '@/web/common/utils/eventbus';
@@ -29,21 +29,21 @@ const QuestionGuide = dynamic(() => import('./chat/QuestionGuide'), { ssr: false
const Markdown = ({
source = '',
showAnimation = false,
forbidImgPreview = false
isDisabled = false
}: {
source?: string;
showAnimation?: boolean;
forbidImgPreview?: boolean;
isDisabled?: boolean;
}) => {
const components = useMemo<any>(
() => ({
img: (props: any) => <Image {...props} forbidImgPreview={forbidImgPreview} />,
img: Image,
pre: RewritePre,
p: (pProps: any) => <p {...pProps} dir="auto" />,
code: Code,
a: A
}),
[forbidImgPreview]
[]
);
const formatSource = useMemo(() => {
@@ -59,17 +59,20 @@ const Markdown = ({
}, []);
return (
<ReactMarkdown
className={`markdown ${styles.markdown}
<Box position={'relative'}>
<ReactMarkdown
className={`markdown ${styles.markdown}
${showAnimation ? `${formatSource ? styles.waitingAnimation : styles.animation}` : ''}
`}
remarkPlugins={[RemarkMath, [RemarkGfm, { singleTilde: false }], RemarkBreaks]}
rehypePlugins={[RehypeKatex, [RehypeExternalLinks, { target: '_blank' }]]}
components={components}
urlTransform={urlTransform}
>
{formatSource}
</ReactMarkdown>
remarkPlugins={[RemarkMath, [RemarkGfm, { singleTilde: false }], RemarkBreaks]}
rehypePlugins={[RehypeKatex, [RehypeExternalLinks, { target: '_blank' }]]}
components={components}
urlTransform={urlTransform}
>
{formatSource}
</ReactMarkdown>
{isDisabled && <Box position={'absolute'} top={0} right={0} left={0} bottom={0} />}
</Box>
);
};
@@ -107,8 +110,8 @@ function Code(e: any) {
return Component;
}
function Image({ src, forbidImgPreview }: { forbidImgPreview: boolean; src?: string }) {
return <MdImage forbidImgPreview={forbidImgPreview} src={src} />;
function Image({ src }: { src?: string }) {
return <MdImage src={src} />;
}
function A({ children, ...props }: any) {

View File

@@ -326,7 +326,8 @@ export const WholeResponseContent = ({
label={t('common:core.chat.response.context total length')}
value={activeModule?.contextTotalLen}
/>
<Row label={workflowT('response.Error')} value={activeModule?.error} />
<Row label={t('workflow:response.Error')} value={activeModule?.error} />
<Row label={t('chat:response.node_inputs')} value={activeModule?.nodeInputs} />
</>
{/* ai chat */}
<>

View File

@@ -75,7 +75,7 @@ const QRCodePayModal = ({
<MyModal isOpen title={t('common:user.Pay')} iconSrc="/imgs/modal/pay.svg">
<ModalBody textAlign={'center'} py={6} whiteSpace={'pre'}>
{tip && (
<Box fontSize={'sm'} whiteSpace={'normal'} mb={3}>
<Box fontSize={'sm'} whiteSpace={'pre'} mb={3}>
{tip}
</Box>
)}

View File

@@ -578,7 +578,7 @@ const NodeDebugResponse = React.memo(function NodeDebugResponse({
</Box>
)}
</Flex>
{/* result */}
{/* Result card */}
{debugResult.showResult && (
<Card
className="nowheel"
@@ -587,12 +587,11 @@ const NodeDebugResponse = React.memo(function NodeDebugResponse({
top={0}
zIndex={10}
w={'420px'}
minH={'300px'}
maxH={'100%'}
maxH={'max(100%,500px)'}
border={'base'}
>
{/* Status header */}
<Flex h={'54x'} px={4} mb={1} py={3} alignItems={'center'} borderBottom={'base'}>
<Flex h={'54x'} px={4} py={3} alignItems={'center'}>
<MyIcon mr={1} name={'core/workflow/debugResult'} w={'20px'} color={'primary.600'} />
<Box fontWeight={'bold'} flex={'1'}>
{t('common:core.workflow.debug.Run result')}
@@ -627,18 +626,20 @@ const NodeDebugResponse = React.memo(function NodeDebugResponse({
</Button>
)}
</Flex>
{/* Show result */}
<Box overflowY={'auto'}>
{!debugResult.message && !response && (
<EmptyTip text={t('common:core.workflow.debug.Not result')} pt={2} pb={5} />
)}
{debugResult.message && (
<Box color={'red.600'} px={3} py={4}>
{debugResult.message}
</Box>
)}
{response && <WholeResponseContent activeModule={response} showDetail />}
</Box>
{/* Response list */}
{debugResult.status !== 'skipped' && (
<Box borderTop={'base'} mt={1} overflowY={'auto'} minH={'250px'}>
{!debugResult.message && !response && (
<EmptyTip text={t('common:core.workflow.debug.Not result')} pt={2} pb={5} />
)}
{debugResult.message && (
<Box color={'red.600'} px={3} py={4}>
{debugResult.message}
</Box>
)}
{response && <WholeResponseContent activeModule={response} showDetail />}
</Box>
)}
</Card>
)}
<ConfirmModal />

View File

@@ -692,19 +692,7 @@ const WorkflowContextProvider = ({
const newStoreDebugData = {
runtimeNodes: finishedNodes,
// edges need to save status
runtimeEdges: finishedEdges.map((edge) => {
const oldEdge = debugData.runtimeEdges.find(
(item) => item.source === edge.source && item.target === edge.target
);
const status =
oldEdge?.status && oldEdge.status !== RuntimeEdgeStatusEnum.waiting
? oldEdge.status
: edge.status;
return {
...edge,
status
};
}),
runtimeEdges: finishedEdges,
nextRunNodes: nextStepRunNodes,
variables: newVariables
};

View File

@@ -227,7 +227,8 @@ const DataCard = () => {
'& .forbid-switch': { display: 'flex' },
bg: index % 2 === 1 ? 'myGray.200' : 'blue.100'
}}
onClick={() => {
onClickCapture={(e) => {
e.stopPropagation();
if (!collection) return;
setEditDataId(item._id);
}}
@@ -264,11 +265,11 @@ const DataCard = () => {
{/* Data content */}
<Box wordBreak={'break-all'} fontSize={'sm'}>
<Markdown source={item.q} forbidImgPreview />
<Markdown source={item.q} isDisabled />
{!!item.a && (
<>
<MyDivider />
<Markdown source={item.a} forbidImgPreview />
<Markdown source={item.a} isDisabled />
</>
)}
</Box>