Merge remote-tracking branch 'origin/main' into feat/trigger

This commit is contained in:
lyzno1
2025-10-30 12:14:47 +08:00
37 changed files with 851 additions and 149 deletions

View File

@ -28,6 +28,9 @@ const useConfig = (id: string, payload: LLMNodeType) => {
const [defaultRolePrefix, setDefaultRolePrefix] = useState<{ user: string; assistant: string }>({ user: '', assistant: '' })
const { inputs, setInputs: doSetInputs } = useNodeCrud<LLMNodeType>(id, payload)
const inputRef = useRef(inputs)
useEffect(() => {
inputRef.current = inputs
}, [inputs])
const { deleteNodeInspectorVars } = useInspectVarsCrud()
@ -118,7 +121,7 @@ const useConfig = (id: string, payload: LLMNodeType) => {
} = useConfigVision(model, {
payload: inputs.vision,
onChange: (newPayload) => {
const newInputs = produce(inputs, (draft) => {
const newInputs = produce(inputRef.current, (draft) => {
draft.vision = newPayload
})
setInputs(newInputs)
@ -149,11 +152,11 @@ const useConfig = (id: string, payload: LLMNodeType) => {
}, [model.provider, currentProvider, currentModel, handleModelChanged])
const handleCompletionParamsChange = useCallback((newParams: Record<string, any>) => {
const newInputs = produce(inputs, (draft) => {
const newInputs = produce(inputRef.current, (draft) => {
draft.model.completion_params = newParams
})
setInputs(newInputs)
}, [inputs, setInputs])
}, [setInputs])
// change to vision model to set vision enabled, else disabled
useEffect(() => {
@ -239,29 +242,29 @@ const useConfig = (id: string, payload: LLMNodeType) => {
// context
const handleContextVarChange = useCallback((newVar: ValueSelector | string) => {
const newInputs = produce(inputs, (draft) => {
const newInputs = produce(inputRef.current, (draft) => {
draft.context.variable_selector = newVar as ValueSelector || []
draft.context.enabled = !!(newVar && newVar.length > 0)
})
setInputs(newInputs)
}, [inputs, setInputs])
}, [setInputs])
const handlePromptChange = useCallback((newPrompt: PromptItem[] | PromptItem) => {
const newInputs = produce(inputRef.current, (draft) => {
draft.prompt_template = newPrompt
})
setInputs(newInputs)
}, [inputs, setInputs])
}, [setInputs])
const handleMemoryChange = useCallback((newMemory?: Memory) => {
const newInputs = produce(inputs, (draft) => {
const newInputs = produce(inputRef.current, (draft) => {
draft.memory = newMemory
})
setInputs(newInputs)
}, [inputs, setInputs])
}, [setInputs])
const handleSyeQueryChange = useCallback((newQuery: string) => {
const newInputs = produce(inputs, (draft) => {
const newInputs = produce(inputRef.current, (draft) => {
if (!draft.memory) {
draft.memory = {
window: {
@ -276,7 +279,7 @@ const useConfig = (id: string, payload: LLMNodeType) => {
}
})
setInputs(newInputs)
}, [inputs, setInputs])
}, [setInputs])
// structure output
const { data: modelList } = useModelList(ModelTypeEnum.textGeneration)
@ -287,22 +290,22 @@ const useConfig = (id: string, payload: LLMNodeType) => {
const [structuredOutputCollapsed, setStructuredOutputCollapsed] = useState(true)
const handleStructureOutputEnableChange = useCallback((enabled: boolean) => {
const newInputs = produce(inputs, (draft) => {
const newInputs = produce(inputRef.current, (draft) => {
draft.structured_output_enabled = enabled
})
setInputs(newInputs)
if (enabled)
setStructuredOutputCollapsed(false)
deleteNodeInspectorVars(id)
}, [inputs, setInputs, deleteNodeInspectorVars, id])
}, [setInputs, deleteNodeInspectorVars, id])
const handleStructureOutputChange = useCallback((newOutput: StructuredOutput) => {
const newInputs = produce(inputs, (draft) => {
const newInputs = produce(inputRef.current, (draft) => {
draft.structured_output = newOutput
})
setInputs(newInputs)
deleteNodeInspectorVars(id)
}, [inputs, setInputs, deleteNodeInspectorVars, id])
}, [setInputs, deleteNodeInspectorVars, id])
const filterInputVar = useCallback((varPayload: Var) => {
return [VarType.number, VarType.string, VarType.secret, VarType.arrayString, VarType.arrayNumber, VarType.file, VarType.arrayFile].includes(varPayload.type)
@ -318,11 +321,11 @@ const useConfig = (id: string, payload: LLMNodeType) => {
// reasoning format
const handleReasoningFormatChange = useCallback((reasoningFormat: 'tagged' | 'separated') => {
const newInputs = produce(inputs, (draft) => {
const newInputs = produce(inputRef.current, (draft) => {
draft.reasoning_format = reasoningFormat
})
setInputs(newInputs)
}, [inputs, setInputs])
}, [setInputs])
const {
availableVars,