chore: not use step_boundary field (#7231)

This commit is contained in:
Joel
2024-08-13 17:22:33 +08:00
committed by GitHub
parent 0f59d76997
commit 9381c08c43
3 changed files with 15 additions and 39 deletions

View File

@@ -63,30 +63,25 @@ const RunPanel: FC<RunProps> = ({ hideResult, activeTab = 'RESULT', runID, getRe
const formatNodeList = useCallback((list: NodeTracing[]) => {
const allItems = list.reverse()
const result: NodeTracing[] = []
let iterationIndexInfos: {
start: number
end: number
}[] = []
let iterationIndex = 0
allItems.forEach((item) => {
const { node_type, index, execution_metadata } = item
const { node_type, execution_metadata } = item
if (node_type !== BlockEnum.Iteration) {
let isInIteration = false
let isIterationFirstNode = false
iterationIndexInfos.forEach(({ start, end }) => {
if (index >= start && index < end) {
if (index === start)
isIterationFirstNode = true
const isInIteration = !!execution_metadata?.iteration_id
isInIteration = true
}
})
if (isInIteration) {
const iterationDetails = result[result.length - 1].details!
if (isIterationFirstNode)
iterationDetails!.push([item])
const currentIterationIndex = execution_metadata?.iteration_index
const isIterationFirstNode = iterationIndex !== currentIterationIndex || iterationDetails.length === 0
else
if (isIterationFirstNode) {
iterationDetails!.push([item])
iterationIndex = currentIterationIndex!
}
else {
iterationDetails[iterationDetails.length - 1].push(item)
}
return
}
@@ -96,26 +91,6 @@ const RunPanel: FC<RunProps> = ({ hideResult, activeTab = 'RESULT', runID, getRe
return
}
const { steps_boundary } = execution_metadata
iterationIndexInfos = []
steps_boundary.forEach((boundary, index) => {
if (index === 0) {
iterationIndexInfos.push({
start: boundary,
end: 0,
})
}
else if (index === steps_boundary.length - 1) {
iterationIndexInfos[iterationIndexInfos.length - 1].end = boundary
}
else {
iterationIndexInfos[iterationIndexInfos.length - 1].end = boundary
iterationIndexInfos.push({
start: boundary,
end: 0,
})
}
})
result.push({
...item,
details: [],

View File

@@ -123,7 +123,7 @@ const NodePanel: FC<Props> = ({
<div
className='flex items-center h-[34px] justify-between px-3 bg-gray-100 border-[0.5px] border-gray-200 rounded-lg cursor-pointer'
onClick={handleOnShowIterationDetail}>
<div className='leading-[18px] text-[13px] font-medium text-gray-700'>{t('workflow.nodes.iteration.iteration', { count: nodeInfo.metadata?.iterator_length || (nodeInfo.execution_metadata?.steps_boundary?.length - 1) })}</div>
<div className='leading-[18px] text-[13px] font-medium text-gray-700'>{t('workflow.nodes.iteration.iteration', { count: nodeInfo.metadata?.iterator_length })}</div>
{justShowIterationNavArrow
? (
<RiArrowRightSLine className='w-3.5 h-3.5 text-gray-500' />

View File

@@ -24,7 +24,8 @@ export type NodeTracing = {
total_tokens: number
total_price: number
currency: string
steps_boundary: number[]
iteration_id?: string
iteration_index?: number
}
metadata: {
iterator_length: number