index.ts 1.0 KB

12345678910111213141516171819202122232425262728
  1. import type { NodeTracing } from '@/types/workflow'
  2. import formatIterationNode from './iteration'
  3. import formatParallelNode from './parallel'
  4. import formatRetryNode from './retry'
  5. import formatAgentNode from './agent'
  6. import { cloneDeep } from 'lodash-es'
  7. const formatToTracingNodeList = (list: NodeTracing[], t: any) => {
  8. const allItems = cloneDeep([...list]).sort((a, b) => a.index - b.index)
  9. /*
  10. * First handle not change list structure node
  11. * Because Handle struct node will put the node in different
  12. */
  13. const formattedAgentList = formatAgentNode(allItems)
  14. const formattedRetryList = formatRetryNode(formattedAgentList) // retry one node
  15. // would change the structure of the list. Iteration and parallel can include each other.
  16. const formattedIterationList = formatIterationNode(formattedRetryList, t)
  17. const formattedParallelList = formatParallelNode(formattedIterationList, t)
  18. const result = formattedParallelList
  19. // console.log(allItems)
  20. // console.log(result)
  21. return result
  22. }
  23. export default formatToTracingNodeList