feat: llm support struct output (#17994)
Co-authored-by: twwu <twwu@dify.ai> Co-authored-by: zxhlyh <jasonapring2015@outlook.com>
This commit is contained in:
@@ -8,6 +8,8 @@ import type {
|
||||
ValueSelector,
|
||||
Var,
|
||||
} from '@/app/components/workflow/types'
|
||||
import { useIsChatMode } from './use-workflow'
|
||||
import { useStoreApi } from 'reactflow'
|
||||
|
||||
export const useWorkflowVariables = () => {
|
||||
const { t } = useTranslation()
|
||||
@@ -75,3 +77,37 @@ export const useWorkflowVariables = () => {
|
||||
getCurrentVariableType,
|
||||
}
|
||||
}
|
||||
|
||||
export const useWorkflowVariableType = () => {
|
||||
const store = useStoreApi()
|
||||
const {
|
||||
getNodes,
|
||||
} = store.getState()
|
||||
const { getCurrentVariableType } = useWorkflowVariables()
|
||||
|
||||
const isChatMode = useIsChatMode()
|
||||
|
||||
const getVarType = ({
|
||||
nodeId,
|
||||
valueSelector,
|
||||
}: {
|
||||
nodeId: string,
|
||||
valueSelector: ValueSelector,
|
||||
}) => {
|
||||
const node = getNodes().find(n => n.id === nodeId)
|
||||
const isInIteration = !!node?.data.isInIteration
|
||||
const iterationNode = isInIteration ? getNodes().find(n => n.id === node.parentId) : null
|
||||
const availableNodes = [node]
|
||||
|
||||
const type = getCurrentVariableType({
|
||||
parentNode: iterationNode,
|
||||
valueSelector,
|
||||
availableNodes,
|
||||
isChatMode,
|
||||
isConstant: false,
|
||||
})
|
||||
return type
|
||||
}
|
||||
|
||||
return getVarType
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user