|
|
|
@ -16,11 +16,16 @@ import {
|
|
|
|
ModelTypeEnum,
|
|
|
|
ModelTypeEnum,
|
|
|
|
} from '@/app/components/header/account-setting/model-provider-page/declarations'
|
|
|
|
} from '@/app/components/header/account-setting/model-provider-page/declarations'
|
|
|
|
import useNodeCrud from '@/app/components/workflow/nodes/_base/hooks/use-node-crud'
|
|
|
|
import useNodeCrud from '@/app/components/workflow/nodes/_base/hooks/use-node-crud'
|
|
|
|
import useOneStepRun from '@/app/components/workflow/nodes/_base/hooks/use-one-step-run'
|
|
|
|
|
|
|
|
import { RETRIEVAL_OUTPUT_STRUCT } from '@/app/components/workflow/constants'
|
|
|
|
|
|
|
|
import { checkHasContextBlock, checkHasHistoryBlock, checkHasQueryBlock } from '@/app/components/base/prompt-editor/constants'
|
|
|
|
import { checkHasContextBlock, checkHasHistoryBlock, checkHasQueryBlock } from '@/app/components/base/prompt-editor/constants'
|
|
|
|
|
|
|
|
import type { PanelProps } from '@/types/workflow'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const useConfig = (id: string, payload: LLMNodeType, panelProps?: PanelProps) => {
|
|
|
|
|
|
|
|
const getVarInputs = panelProps?.getInputVars
|
|
|
|
|
|
|
|
const toVarInputs = panelProps?.toVarInputs
|
|
|
|
|
|
|
|
const runInputData = panelProps?.runInputData || {}
|
|
|
|
|
|
|
|
const runInputDataRef = panelProps?.runInputDataRef || { current: {} }
|
|
|
|
|
|
|
|
const setRunInputData = panelProps?.setRunInputData
|
|
|
|
|
|
|
|
|
|
|
|
const useConfig = (id: string, payload: LLMNodeType) => {
|
|
|
|
|
|
|
|
const { nodesReadOnly: readOnly } = useNodesReadOnly()
|
|
|
|
const { nodesReadOnly: readOnly } = useNodesReadOnly()
|
|
|
|
const isChatMode = useIsChatMode()
|
|
|
|
const isChatMode = useIsChatMode()
|
|
|
|
|
|
|
|
|
|
|
|
@ -322,28 +327,6 @@ const useConfig = (id: string, payload: LLMNodeType) => {
|
|
|
|
filterVar: filterMemoryPromptVar,
|
|
|
|
filterVar: filterMemoryPromptVar,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// single run
|
|
|
|
|
|
|
|
const {
|
|
|
|
|
|
|
|
isShowSingleRun,
|
|
|
|
|
|
|
|
hideSingleRun,
|
|
|
|
|
|
|
|
getInputVars,
|
|
|
|
|
|
|
|
runningStatus,
|
|
|
|
|
|
|
|
handleRun,
|
|
|
|
|
|
|
|
handleStop,
|
|
|
|
|
|
|
|
runInputData,
|
|
|
|
|
|
|
|
runInputDataRef,
|
|
|
|
|
|
|
|
setRunInputData,
|
|
|
|
|
|
|
|
runResult,
|
|
|
|
|
|
|
|
toVarInputs,
|
|
|
|
|
|
|
|
} = useOneStepRun<LLMNodeType>({
|
|
|
|
|
|
|
|
id,
|
|
|
|
|
|
|
|
data: inputs,
|
|
|
|
|
|
|
|
defaultRunInputData: {
|
|
|
|
|
|
|
|
'#context#': [RETRIEVAL_OUTPUT_STRUCT],
|
|
|
|
|
|
|
|
'#files#': [],
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const inputVarValues = (() => {
|
|
|
|
const inputVarValues = (() => {
|
|
|
|
const vars: Record<string, any> = {}
|
|
|
|
const vars: Record<string, any> = {}
|
|
|
|
Object.keys(runInputData)
|
|
|
|
Object.keys(runInputData)
|
|
|
|
@ -360,12 +343,12 @@ const useConfig = (id: string, payload: LLMNodeType) => {
|
|
|
|
'#context#': runInputDataRef.current['#context#'],
|
|
|
|
'#context#': runInputDataRef.current['#context#'],
|
|
|
|
'#files#': runInputDataRef.current['#files#'],
|
|
|
|
'#files#': runInputDataRef.current['#files#'],
|
|
|
|
}
|
|
|
|
}
|
|
|
|
setRunInputData(newVars)
|
|
|
|
setRunInputData?.(newVars)
|
|
|
|
}, [runInputDataRef, setRunInputData])
|
|
|
|
}, [runInputDataRef, setRunInputData])
|
|
|
|
|
|
|
|
|
|
|
|
const contexts = runInputData['#context#']
|
|
|
|
const contexts = runInputData['#context#']
|
|
|
|
const setContexts = useCallback((newContexts: string[]) => {
|
|
|
|
const setContexts = useCallback((newContexts: string[]) => {
|
|
|
|
setRunInputData({
|
|
|
|
setRunInputData?.({
|
|
|
|
...runInputDataRef.current,
|
|
|
|
...runInputDataRef.current,
|
|
|
|
'#context#': newContexts,
|
|
|
|
'#context#': newContexts,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
@ -373,7 +356,7 @@ const useConfig = (id: string, payload: LLMNodeType) => {
|
|
|
|
|
|
|
|
|
|
|
|
const visionFiles = runInputData['#files#']
|
|
|
|
const visionFiles = runInputData['#files#']
|
|
|
|
const setVisionFiles = useCallback((newFiles: any[]) => {
|
|
|
|
const setVisionFiles = useCallback((newFiles: any[]) => {
|
|
|
|
setRunInputData({
|
|
|
|
setRunInputData?.({
|
|
|
|
...runInputDataRef.current,
|
|
|
|
...runInputDataRef.current,
|
|
|
|
'#files#': newFiles,
|
|
|
|
'#files#': newFiles,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
@ -390,9 +373,9 @@ const useConfig = (id: string, payload: LLMNodeType) => {
|
|
|
|
})()
|
|
|
|
})()
|
|
|
|
|
|
|
|
|
|
|
|
const varInputs = (() => {
|
|
|
|
const varInputs = (() => {
|
|
|
|
const vars = getInputVars(allVarStrArr)
|
|
|
|
const vars = getVarInputs?.(allVarStrArr) || []
|
|
|
|
if (isShowVars)
|
|
|
|
if (isShowVars)
|
|
|
|
return [...vars, ...toVarInputs(inputs.prompt_config?.jinja2_variables || [])]
|
|
|
|
return [...vars, ...(toVarInputs ? (toVarInputs(inputs.prompt_config?.jinja2_variables || [])) : [])]
|
|
|
|
|
|
|
|
|
|
|
|
return vars
|
|
|
|
return vars
|
|
|
|
})()
|
|
|
|
})()
|
|
|
|
@ -423,8 +406,6 @@ const useConfig = (id: string, payload: LLMNodeType) => {
|
|
|
|
handleSyeQueryChange,
|
|
|
|
handleSyeQueryChange,
|
|
|
|
handleVisionResolutionEnabledChange,
|
|
|
|
handleVisionResolutionEnabledChange,
|
|
|
|
handleVisionResolutionChange,
|
|
|
|
handleVisionResolutionChange,
|
|
|
|
isShowSingleRun,
|
|
|
|
|
|
|
|
hideSingleRun,
|
|
|
|
|
|
|
|
inputVarValues,
|
|
|
|
inputVarValues,
|
|
|
|
setInputVarValues,
|
|
|
|
setInputVarValues,
|
|
|
|
visionFiles,
|
|
|
|
visionFiles,
|
|
|
|
@ -432,15 +413,11 @@ const useConfig = (id: string, payload: LLMNodeType) => {
|
|
|
|
contexts,
|
|
|
|
contexts,
|
|
|
|
setContexts,
|
|
|
|
setContexts,
|
|
|
|
varInputs,
|
|
|
|
varInputs,
|
|
|
|
runningStatus,
|
|
|
|
|
|
|
|
isModelSupportStructuredOutput,
|
|
|
|
isModelSupportStructuredOutput,
|
|
|
|
handleStructureOutputChange,
|
|
|
|
handleStructureOutputChange,
|
|
|
|
structuredOutputCollapsed,
|
|
|
|
structuredOutputCollapsed,
|
|
|
|
setStructuredOutputCollapsed,
|
|
|
|
setStructuredOutputCollapsed,
|
|
|
|
handleStructureOutputEnableChange,
|
|
|
|
handleStructureOutputEnableChange,
|
|
|
|
handleRun,
|
|
|
|
|
|
|
|
handleStop,
|
|
|
|
|
|
|
|
runResult,
|
|
|
|
|
|
|
|
filterJinjia2InputVar,
|
|
|
|
filterJinjia2InputVar,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|