mirror of
https://github.com/langgenius/dify.git
synced 2026-05-05 01:48:04 +08:00
update memory by SSE in preview
This commit is contained in:
@ -13,7 +13,7 @@ import {
|
||||
useWorkflowRun,
|
||||
} from '../../hooks'
|
||||
import { NodeRunningStatus, WorkflowRunningStatus } from '../../types'
|
||||
import { useWorkflowStore } from '../../store'
|
||||
import { useStore, useWorkflowStore } from '../../store'
|
||||
import { DEFAULT_ITER_TIMES, DEFAULT_LOOP_TIMES } from '../../constants'
|
||||
import type {
|
||||
ChatItem,
|
||||
@ -63,6 +63,8 @@ export const useChat = (
|
||||
const { fetchInspectVars } = useSetWorkflowVarsWithValue()
|
||||
const [suggestedQuestions, setSuggestQuestions] = useState<string[]>([])
|
||||
const suggestedQuestionsAbortControllerRef = useRef<AbortController | null>(null)
|
||||
const conversationVariables = useStore(s => s.conversationVariables)
|
||||
const setConversationVariables = useStore(s => s.setConversationVariables)
|
||||
const {
|
||||
setIterTimes,
|
||||
setLoopTimes,
|
||||
@ -499,6 +501,18 @@ export const useChat = (
|
||||
})
|
||||
}
|
||||
},
|
||||
onMemoryUpdate: ({ data }) => {
|
||||
const currentMemoryIndex = conversationVariables.findIndex(item => item.id === data.memory_id)
|
||||
const newList = produce(conversationVariables, (draft) => {
|
||||
if (currentMemoryIndex > -1) {
|
||||
draft[currentMemoryIndex] = {
|
||||
...draft[currentMemoryIndex],
|
||||
...data,
|
||||
}
|
||||
}
|
||||
})
|
||||
setConversationVariables(newList)
|
||||
},
|
||||
},
|
||||
)
|
||||
}, [threadMessages, chatTree.length, updateCurrentQAOnTree, handleResponding, formSettings?.inputsForm, handleRun, notify, t, config?.suggested_questions_after_answer?.enabled, fetchInspectVars, invalidAllLastRun])
|
||||
|
||||
Reference in New Issue
Block a user