您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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