mirror of https://github.com/langgenius/dify.git
fix: tools value not update caused data outdated
This commit is contained in:
parent
9a13cb5bdf
commit
740f1c5f2c
|
|
@ -10,6 +10,7 @@ import type {
|
|||
} from '@/app/components/workflow/types'
|
||||
import { useIsChatMode } from './use-workflow'
|
||||
import { useStoreApi } from 'reactflow'
|
||||
import { useStore } from '@/app/components/workflow/store'
|
||||
import type { Type } from '../nodes/llm/types'
|
||||
import useMatchSchemaType from '../nodes/_base/components/variable/use-match-schema-type'
|
||||
|
||||
|
|
@ -18,6 +19,11 @@ export const useWorkflowVariables = () => {
|
|||
const workflowStore = useWorkflowStore()
|
||||
const { getMatchedSchemaType } = useMatchSchemaType()
|
||||
|
||||
const buildInTools = useStore(s => s.buildInTools)
|
||||
const customTools = useStore(s => s.customTools)
|
||||
const workflowTools = useStore(s => s.workflowTools)
|
||||
const mcpTools = useStore(s => s.mcpTools)
|
||||
const dataSourceList = useStore(s => s.dataSourceList)
|
||||
const getNodeAvailableVars = useCallback(({
|
||||
parentNode,
|
||||
beforeNodes,
|
||||
|
|
@ -37,11 +43,6 @@ export const useWorkflowVariables = () => {
|
|||
conversationVariables,
|
||||
environmentVariables,
|
||||
ragPipelineVariables,
|
||||
buildInTools,
|
||||
customTools,
|
||||
workflowTools,
|
||||
mcpTools,
|
||||
dataSourceList,
|
||||
} = workflowStore.getState()
|
||||
return toNodeAvailableVars({
|
||||
parentNode,
|
||||
|
|
@ -61,7 +62,7 @@ export const useWorkflowVariables = () => {
|
|||
},
|
||||
getMatchedSchemaType,
|
||||
})
|
||||
}, [t, workflowStore, getMatchedSchemaType])
|
||||
}, [t, workflowStore, getMatchedSchemaType, buildInTools])
|
||||
|
||||
const getCurrentVariableType = useCallback(({
|
||||
parentNode,
|
||||
|
|
@ -71,6 +72,7 @@ export const useWorkflowVariables = () => {
|
|||
availableNodes,
|
||||
isChatMode,
|
||||
isConstant,
|
||||
preferSchemaType,
|
||||
}: {
|
||||
valueSelector: ValueSelector
|
||||
parentNode?: Node | null
|
||||
|
|
@ -79,6 +81,7 @@ export const useWorkflowVariables = () => {
|
|||
availableNodes: any[]
|
||||
isChatMode: boolean
|
||||
isConstant?: boolean
|
||||
preferSchemaType?: boolean
|
||||
}) => {
|
||||
const {
|
||||
conversationVariables,
|
||||
|
|
@ -109,8 +112,9 @@ export const useWorkflowVariables = () => {
|
|||
dataSourceList: dataSourceList ?? [],
|
||||
},
|
||||
getMatchedSchemaType,
|
||||
preferSchemaType,
|
||||
})
|
||||
}, [workflowStore])
|
||||
}, [workflowStore, getVarType, getMatchedSchemaType])
|
||||
|
||||
return {
|
||||
getNodeAvailableVars,
|
||||
|
|
|
|||
|
|
@ -825,6 +825,7 @@ export const getVarType = ({
|
|||
ragVariables = [],
|
||||
allPluginInfoList,
|
||||
getMatchedSchemaType,
|
||||
preferSchemaType,
|
||||
}: {
|
||||
valueSelector: ValueSelector
|
||||
parentNode?: Node | null
|
||||
|
|
@ -838,6 +839,7 @@ export const getVarType = ({
|
|||
ragVariables?: RAGPipelineVariable[]
|
||||
allPluginInfoList: Record<string, ToolWithProvider[]>
|
||||
getMatchedSchemaType: (obj: any) => string
|
||||
preferSchemaType?: boolean
|
||||
}): VarType => {
|
||||
if (isConstant)
|
||||
return VarType.string
|
||||
|
|
@ -934,7 +936,7 @@ export const getVarType = ({
|
|||
const isStructuredOutputVar = !!targetVar.children?.schema?.properties
|
||||
if (isStructuredOutputVar) {
|
||||
if (valueSelector.length === 2) { // root
|
||||
return targetVar.alias || VarType.object
|
||||
return (preferSchemaType && targetVar.schemaType) ? targetVar.schemaType : VarType.object
|
||||
}
|
||||
let currProperties = targetVar.children.schema;
|
||||
(valueSelector as ValueSelector).slice(2).forEach((key, i) => {
|
||||
|
|
@ -955,7 +957,7 @@ export const getVarType = ({
|
|||
curr = curr?.find((v: any) => v.variable === key)
|
||||
|
||||
if (isLast) {
|
||||
type = curr?.type
|
||||
type = (preferSchemaType && curr?.schemaType) ? curr?.schemaType : curr?.type
|
||||
}
|
||||
else {
|
||||
if (curr?.type === VarType.object || curr?.type === VarType.file)
|
||||
|
|
|
|||
|
|
@ -288,6 +288,7 @@ const VarReferencePicker: FC<Props> = ({
|
|||
availableNodes,
|
||||
isChatMode,
|
||||
isConstant: !!isConstant,
|
||||
preferSchemaType,
|
||||
})
|
||||
|
||||
const { isEnv, isChatVar, isRagVar, isValidVar, isException } = useMemo(() => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue