mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-16 06:35:56 +08:00
update the log for iteration nodes
This commit is contained in:
parent
78fa1f6868
commit
cd42dbdae8
@ -371,11 +371,28 @@ export const useChat = (
|
|||||||
if (isInIteration) {
|
if (isInIteration) {
|
||||||
const tracing = responseItem.workflowProcess!.tracing!
|
const tracing = responseItem.workflowProcess!.tracing!
|
||||||
const iterations = tracing[tracing.length - 1]
|
const iterations = tracing[tracing.length - 1]
|
||||||
const currIteration = iterations.details![iterations.details!.length - 1]
|
if (iterations && iterations.details) {
|
||||||
currIteration[currIteration.length - 1] = {
|
const iterationIndex = data.execution_metadata?.iteration_index || 0
|
||||||
...data,
|
if (!iterations.details[iterationIndex])
|
||||||
status: NodeRunningStatus.Succeeded,
|
iterations.details[iterationIndex] = []
|
||||||
} as any
|
const currIteration = iterations.details[iterationIndex]
|
||||||
|
const nodeIndex = currIteration.findIndex(node =>
|
||||||
|
node.node_id === data.node_id,
|
||||||
|
)
|
||||||
|
if (data.status === NodeRunningStatus.Succeeded) {
|
||||||
|
if (nodeIndex !== -1) {
|
||||||
|
currIteration[nodeIndex] = {
|
||||||
|
...currIteration[nodeIndex],
|
||||||
|
...data,
|
||||||
|
} as any
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
currIteration.push({
|
||||||
|
...data,
|
||||||
|
} as any)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
handleUpdateChatList(produce(chatListRef.current, (draft) => {
|
handleUpdateChatList(produce(chatListRef.current, (draft) => {
|
||||||
const currentIndex = draft.length - 1
|
const currentIndex = draft.length - 1
|
||||||
draft[currentIndex] = responseItem
|
draft[currentIndex] = responseItem
|
||||||
|
@ -63,6 +63,13 @@ const NodePanel: FC<Props> = ({
|
|||||||
return `${parseFloat((tokens / 1000000).toFixed(3))}M`
|
return `${parseFloat((tokens / 1000000).toFixed(3))}M`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getCount = (iteration_curr_length: number | undefined, iteration_length: number) => {
|
||||||
|
if ((iteration_curr_length && iteration_curr_length < iteration_length) || !iteration_length)
|
||||||
|
return iteration_curr_length
|
||||||
|
|
||||||
|
return iteration_length
|
||||||
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setCollapseState(!nodeInfo.expand)
|
setCollapseState(!nodeInfo.expand)
|
||||||
}, [nodeInfo.expand, setCollapseState])
|
}, [nodeInfo.expand, setCollapseState])
|
||||||
@ -127,7 +134,7 @@ const NodePanel: FC<Props> = ({
|
|||||||
onClick={handleOnShowIterationDetail}
|
onClick={handleOnShowIterationDetail}
|
||||||
>
|
>
|
||||||
<Iteration className='w-4 h-4 text-components-button-tertiary-text flex-shrink-0' />
|
<Iteration className='w-4 h-4 text-components-button-tertiary-text flex-shrink-0' />
|
||||||
<div className='flex-1 text-left system-sm-medium text-components-button-tertiary-text'>{t('workflow.nodes.iteration.iteration', { count: nodeInfo.metadata?.iterator_index || nodeInfo.details?.length })}</div>
|
<div className='flex-1 text-left system-sm-medium text-components-button-tertiary-text'>{t('workflow.nodes.iteration.iteration', { count: getCount(nodeInfo.details?.length, nodeInfo.metadata?.iterator_length) })}</div>
|
||||||
{justShowIterationNavArrow
|
{justShowIterationNavArrow
|
||||||
? (
|
? (
|
||||||
<RiArrowRightSLine className='w-4 h-4 text-components-button-tertiary-text flex-shrink-0' />
|
<RiArrowRightSLine className='w-4 h-4 text-components-button-tertiary-text flex-shrink-0' />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user