mirror of
				https://github.com/langgenius/dify.git
				synced 2025-10-27 00:48:43 +00:00 
			
		
		
		
	
		
			
	
	
		
			36 lines
		
	
	
		
			1012 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
		
		
			
		
	
	
			36 lines
		
	
	
		
			1012 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
|   | import { useMemo } from 'react' | ||
|  | import { useIsChatMode, useWorkflow, useWorkflowVariables } from '../../hooks' | ||
|  | import type { ValueSelector } from '../../types' | ||
|  | import { VarType } from '../../types' | ||
|  | 
 | ||
|  | type Params = { | ||
|  |   nodeId: string | ||
|  | } | ||
|  | const useIsVarFileAttribute = ({ | ||
|  |   nodeId, | ||
|  | }: Params) => { | ||
|  |   const isChatMode = useIsChatMode() | ||
|  |   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, | ||
|  |       isChatMode, | ||
|  |       isConstant: false, | ||
|  |     }) | ||
|  |     return varType === VarType.file | ||
|  |   } | ||
|  |   return { | ||
|  |     getIsVarFileAttribute, | ||
|  |   } | ||
|  | } | ||
|  | 
 | ||
|  | export default useIsVarFileAttribute |