diff --git a/docSite/content/zh-cn/docs/development/upgrading/4810.md b/docSite/content/zh-cn/docs/development/upgrading/4810.md index 36a41731dcda..5155404793ee 100644 --- a/docSite/content/zh-cn/docs/development/upgrading/4810.md +++ b/docSite/content/zh-cn/docs/development/upgrading/4810.md @@ -80,3 +80,4 @@ curl --location --request POST 'https://{{host}}/api/admin/initv4810' \ 31. 修复 - 全局变量在 API 中无法持久化。 32. 修复 - OpenAPI,detail=false模式下,不应该返回 tool 调用结果,仅返回文字。(可解决 cow 不适配问题) 33. 修复 - 知识库标签重复加载。 +34. 修复 - Debug 模式下,循环调用边问题。 diff --git a/packages/global/core/workflow/runtime/type.d.ts b/packages/global/core/workflow/runtime/type.d.ts index a7f0ee97732c..1b0875433db6 100644 --- a/packages/global/core/workflow/runtime/type.d.ts +++ b/packages/global/core/workflow/runtime/type.d.ts @@ -96,6 +96,8 @@ export type DispatchNodeResponseType = { error?: Record; customInputs?: Record; customOutputs?: Record; + nodeInputs?: Record; + nodeOutputs?: Record; // bill tokens?: number; diff --git a/packages/service/core/workflow/dispatch/agent/runTool/functionCall.ts b/packages/service/core/workflow/dispatch/agent/runTool/functionCall.ts index 4b035c6f4328..287a9e7a71eb 100644 --- a/packages/service/core/workflow/dispatch/agent/runTool/functionCall.ts +++ b/packages/service/core/workflow/dispatch/agent/runTool/functionCall.ts @@ -254,13 +254,15 @@ export const runToolWithFunctionCall = async ( // console.log(tokens, 'tool'); // Run tool status - workflowStreamResponse?.({ - event: SseResponseEventEnum.flowNodeStatus, - data: { - status: 'running', - name: node.name - } - }); + if (node.showStatus) { + workflowStreamResponse?.({ + event: SseResponseEventEnum.flowNodeStatus, + data: { + status: 'running', + name: node.name + } + }); + } // tool assistant const toolAssistants = toolsRunResponse diff --git a/packages/service/core/workflow/dispatch/agent/runTool/promptCall.ts b/packages/service/core/workflow/dispatch/agent/runTool/promptCall.ts index 92aa035956cc..eac1edc35c9e 100644 --- a/packages/service/core/workflow/dispatch/agent/runTool/promptCall.ts +++ b/packages/service/core/workflow/dispatch/agent/runTool/promptCall.ts @@ -258,13 +258,15 @@ export const runToolWithPromptCall = async ( })(); // Run tool status - workflowStreamResponse?.({ - event: SseResponseEventEnum.flowNodeStatus, - data: { - status: 'running', - name: node.name - } - }); + if (node.showStatus) { + workflowStreamResponse?.({ + event: SseResponseEventEnum.flowNodeStatus, + data: { + status: 'running', + name: node.name + } + }); + } // 合并工具调用的结果,使用 functionCall 格式存储。 const assistantToolMsgParams: ChatCompletionAssistantMessageParam = { diff --git a/packages/service/core/workflow/dispatch/agent/runTool/toolChoice.ts b/packages/service/core/workflow/dispatch/agent/runTool/toolChoice.ts index 1fc5fd8dfa10..8addf07f4948 100644 --- a/packages/service/core/workflow/dispatch/agent/runTool/toolChoice.ts +++ b/packages/service/core/workflow/dispatch/agent/runTool/toolChoice.ts @@ -265,13 +265,15 @@ export const runToolWithToolChoice = async ( // console.log(tokens, 'tool'); // Run tool status - workflowStreamResponse?.({ - event: SseResponseEventEnum.flowNodeStatus, - data: { - status: 'running', - name: node.name - } - }); + if (node.showStatus) { + workflowStreamResponse?.({ + event: SseResponseEventEnum.flowNodeStatus, + data: { + status: 'running', + name: node.name + } + }); + } // tool assistant const toolAssistants = toolsRunResponse diff --git a/packages/service/core/workflow/dispatch/index.ts b/packages/service/core/workflow/dispatch/index.ts index 6c123699a0d5..a8eea6c523f1 100644 --- a/packages/service/core/workflow/dispatch/index.ts +++ b/packages/service/core/workflow/dispatch/index.ts @@ -310,9 +310,11 @@ export async function dispatchWorkFlow(data: Props): Promise; }[]; - if (flat.length === 0) return; + // If there are no running nodes, the workflow is complete + if (!flat.some((item) => item.runStatus === 'run')) return; // Update the node output at the end of the run and get the next nodes const nextNodes = flat.map((item) => nodeOutput(item.node, item.result)).flat(); @@ -454,6 +456,7 @@ export async function dispatchWorkFlow(data: Props): Promise item.sourceHandle) } diff --git a/packages/service/core/workflow/dispatch/init/workflowStart.tsx b/packages/service/core/workflow/dispatch/init/workflowStart.tsx index 406c447a7eac..73c2704a284c 100644 --- a/packages/service/core/workflow/dispatch/init/workflowStart.tsx +++ b/packages/service/core/workflow/dispatch/init/workflowStart.tsx @@ -1,14 +1,18 @@ import { chatValue2RuntimePrompt } from '@fastgpt/global/core/chat/adapt'; import { NodeInputKeyEnum, NodeOutputKeyEnum } from '@fastgpt/global/core/workflow/constants'; -import type { ModuleDispatchProps } from '@fastgpt/global/core/workflow/runtime/type'; +import { DispatchNodeResponseKeyEnum } from '@fastgpt/global/core/workflow/runtime/constants'; +import type { + DispatchNodeResultType, + ModuleDispatchProps +} from '@fastgpt/global/core/workflow/runtime/type'; export type UserChatInputProps = ModuleDispatchProps<{ [NodeInputKeyEnum.userChatInput]: string; }>; -type Response = { +type Response = DispatchNodeResultType<{ [NodeOutputKeyEnum.userChatInput]: string; [NodeOutputKeyEnum.userFiles]: string[]; -}; +}>; export const dispatchWorkflowStart = (props: Record): Response => { const { @@ -19,6 +23,7 @@ export const dispatchWorkflowStart = (props: Record): Response => { const { text, files } = chatValue2RuntimePrompt(query); return { + [DispatchNodeResponseKeyEnum.nodeResponse]: {}, [NodeInputKeyEnum.userChatInput]: text || userChatInput, [NodeOutputKeyEnum.userFiles]: files .map((item) => { diff --git a/packages/service/core/workflow/dispatch/tools/runIfElse.ts b/packages/service/core/workflow/dispatch/tools/runIfElse.ts index cd3fa35d487d..3d10698a2d06 100644 --- a/packages/service/core/workflow/dispatch/tools/runIfElse.ts +++ b/packages/service/core/workflow/dispatch/tools/runIfElse.ts @@ -13,7 +13,6 @@ import { import { ModuleDispatchProps } from '@fastgpt/global/core/workflow/runtime/type'; import { getElseIFLabel, getHandleId } from '@fastgpt/global/core/workflow/utils'; import { getReferenceVariableValue } from '@fastgpt/global/core/workflow/runtime/utils'; -import { replaceRegChars } from '@fastgpt/global/common/string/tools'; type Props = ModuleDispatchProps<{ [NodeInputKeyEnum.condition]: IfElseConditionType; diff --git a/packages/web/components/common/Image/PhotoView.tsx b/packages/web/components/common/Image/PhotoView.tsx index 8d7e060540e6..5d2199aa472d 100644 --- a/packages/web/components/common/Image/PhotoView.tsx +++ b/packages/web/components/common/Image/PhotoView.tsx @@ -5,14 +5,9 @@ import { Box, Image, ImageProps } from '@chakra-ui/react'; import { useSystem } from '../../../hooks/useSystem'; import Loading from '../MyLoading'; -const MyPhotoView = ({ - forbidImgPreview, - ...props -}: ImageProps & { forbidImgPreview?: boolean }) => { +const MyPhotoView = ({ ...props }: ImageProps) => { const { isPc } = useSystem(); - return forbidImgPreview ? ( - - ) : ( + return ( { +const MdImage = ({ src, ...props }: { src?: string } & ImageProps) => { const [isLoaded, { setTrue }] = useBoolean(false); const [renderSrc, setRenderSrc] = useState(src); diff --git a/projects/app/src/components/Markdown/index.tsx b/projects/app/src/components/Markdown/index.tsx index 6f0f3da635a6..1f65bed4a41d 100644 --- a/projects/app/src/components/Markdown/index.tsx +++ b/projects/app/src/components/Markdown/index.tsx @@ -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( () => ({ - img: (props: any) => , + img: Image, pre: RewritePre, p: (pProps: any) =>

, code: Code, a: A }), - [forbidImgPreview] + [] ); const formatSource = useMemo(() => { @@ -59,17 +59,20 @@ const Markdown = ({ }, []); return ( - + - {formatSource} - + remarkPlugins={[RemarkMath, [RemarkGfm, { singleTilde: false }], RemarkBreaks]} + rehypePlugins={[RehypeKatex, [RehypeExternalLinks, { target: '_blank' }]]} + components={components} + urlTransform={urlTransform} + > + {formatSource} + + {isDisabled && } + ); }; @@ -107,8 +110,8 @@ function Code(e: any) { return Component; } -function Image({ src, forbidImgPreview }: { forbidImgPreview: boolean; src?: string }) { - return ; +function Image({ src }: { src?: string }) { + return ; } function A({ children, ...props }: any) { diff --git a/projects/app/src/components/core/chat/components/WholeResponseModal.tsx b/projects/app/src/components/core/chat/components/WholeResponseModal.tsx index db9744105d79..ea10fe620910 100644 --- a/projects/app/src/components/core/chat/components/WholeResponseModal.tsx +++ b/projects/app/src/components/core/chat/components/WholeResponseModal.tsx @@ -326,7 +326,8 @@ export const WholeResponseContent = ({ label={t('common:core.chat.response.context total length')} value={activeModule?.contextTotalLen} /> - + + {/* ai chat */} <> diff --git a/projects/app/src/components/support/wallet/QRCodePayModal.tsx b/projects/app/src/components/support/wallet/QRCodePayModal.tsx index b5a513cd9ff0..927e5e2ebb73 100644 --- a/projects/app/src/components/support/wallet/QRCodePayModal.tsx +++ b/projects/app/src/components/support/wallet/QRCodePayModal.tsx @@ -75,7 +75,7 @@ const QRCodePayModal = ({ {tip && ( - + {tip} )} diff --git a/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/nodes/render/NodeCard.tsx b/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/nodes/render/NodeCard.tsx index 53973c6022f5..cc3d70d9e116 100644 --- a/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/nodes/render/NodeCard.tsx +++ b/projects/app/src/pages/app/detail/components/WorkflowComponents/Flow/nodes/render/NodeCard.tsx @@ -578,7 +578,7 @@ const NodeDebugResponse = React.memo(function NodeDebugResponse({ )} - {/* result */} + {/* Result card */} {debugResult.showResult && ( {/* Status header */} - + {t('common:core.workflow.debug.Run result')} @@ -627,18 +626,20 @@ const NodeDebugResponse = React.memo(function NodeDebugResponse({ )} - {/* Show result */} - - {!debugResult.message && !response && ( - - )} - {debugResult.message && ( - - {debugResult.message} - - )} - {response && } - + {/* Response list */} + {debugResult.status !== 'skipped' && ( + + {!debugResult.message && !response && ( + + )} + {debugResult.message && ( + + {debugResult.message} + + )} + {response && } + + )} )} diff --git a/projects/app/src/pages/app/detail/components/WorkflowComponents/context.tsx b/projects/app/src/pages/app/detail/components/WorkflowComponents/context.tsx index 6abe43ede963..76abaf6c16b1 100644 --- a/projects/app/src/pages/app/detail/components/WorkflowComponents/context.tsx +++ b/projects/app/src/pages/app/detail/components/WorkflowComponents/context.tsx @@ -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 }; diff --git a/projects/app/src/pages/dataset/detail/components/DataCard.tsx b/projects/app/src/pages/dataset/detail/components/DataCard.tsx index 88884ec2d921..769a02cfdcbe 100644 --- a/projects/app/src/pages/dataset/detail/components/DataCard.tsx +++ b/projects/app/src/pages/dataset/detail/components/DataCard.tsx @@ -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 */} - + {!!item.a && ( <> - + )}