Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

1.2 KB
Raw Blame
import type { ValueSelector } from '../../types'
import { useAtomValue } from 'jotai'
import { useMemo } from 'react'
import { isChatflowAtom } from '@/app/components/workflow/editor-resource/state'
import { useWorkflow } from '../../hooks/use-workflow'
import { useWorkflowVariables } from '../../hooks/use-workflow-variables'
import { VarType } from '../../types'

type Params = {
  nodeId: string
}
const useIsVarFileAttribute = ({ nodeId }: Params) => {
  const isChatflow = useAtomValue(isChatflowAtom)
  const { getBeforeNodesInSameBranch } = useWorkflow()
  const availableNodes = useMemo(() => {
    return getBeforeNodesInSameBranch(nodeId)
  }, [getBeforeNodesInSameBranch, nodeId])
  const { getCurrentVariableType } = useWorkflowVariables()
  const getIsVarFileAttribute = (variable: ValueSelector) => {
    if (variable.length !== 3) return false
    const parentVariable = variable.slice(0, 2)
    const varType = getCurrentVariableType({
      valueSelector: parentVariable,
      availableNodes,
      isChatflow,
      isConstant: false,
    })
    return varType === VarType.file
  }
  return {
    getIsVarFileAttribute,
  }
}

export default useIsVarFileAttribute