wwf
2025-05-20 938c3e5a587ce950a94964ea509b9e7f8834dfae
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import type {
  NodeOutPutVar,
  ValueSelector,
} from '@/app/components/workflow/types'
import { InputVarType } from '@/app/components/workflow/types'
 
export const findVariableWhenOnLLMVision = (valueSelector: ValueSelector, availableVars: NodeOutPutVar[]) => {
  const currentVariableNode = availableVars.find((availableVar) => {
    if (valueSelector[0] === 'sys' && availableVar.isStartNode)
      return true
 
    return valueSelector[0] === availableVar.nodeId
  })
  const currentVariable = currentVariableNode?.vars.find((variable) => {
    if (valueSelector[0] === 'sys' && variable.variable === `sys.${valueSelector[1]}`)
      return true
    return variable.variable === valueSelector[1]
  })
 
  let formType = ''
  if (currentVariable?.type === 'array[file]')
    formType = InputVarType.multiFiles
  if (currentVariable?.type === 'file')
    formType = InputVarType.singleFile
 
  return currentVariable && {
    ...currentVariable,
    formType,
  }
}