fix(web): optimize prompt change logic for LLM nodes (#20841)

- Replace inputRef.current with inputs in the `handlePromptChange` function to ensure using the latest state
- Ensure using the latest inputs without overwriting `_isSingleRun` to `true`
pull/20865/head
zhujiruo 12 months ago
parent 85859b6723
commit cede695923

@ -247,11 +247,11 @@ const useConfig = (id: string, payload: LLMNodeType) => {
}, [inputs, setInputs]) }, [inputs, setInputs])
const handlePromptChange = useCallback((newPrompt: PromptItem[] | PromptItem) => { const handlePromptChange = useCallback((newPrompt: PromptItem[] | PromptItem) => {
const newInputs = produce(inputRef.current, (draft) => { const newInputs = produce(inputs, (draft) => {
draft.prompt_template = newPrompt draft.prompt_template = newPrompt
}) })
setInputs(newInputs) setInputs(newInputs)
}, [setInputs]) }, [inputs, setInputs])
const handleMemoryChange = useCallback((newMemory?: Memory) => { const handleMemoryChange = useCallback((newMemory?: Memory) => {
const newInputs = produce(inputs, (draft) => { const newInputs = produce(inputs, (draft) => {

Loading…
Cancel
Save