Merge #39 into develop_web from feature/20251219_zy

feat(web): workflow's chat support abort output

* feature/20251219_zy: (1 commits)
  feat(web): workflow's chat support abort output

Signed-off-by: zhaoying <zhaoying@redbearai.com>
Merged-by: zhaoying <zhaoying@redbearai.com>

CR-link: https://codeup.aliyun.com/redbearai/python/redbear-mem-open/change/39
This commit is contained in:
赵莹
2025-12-23 19:48:35 +08:00

View File

@@ -60,7 +60,7 @@ const Chat = forwardRef<ChatRef, { appId: string; graphRef: GraphRef }>(({ appId
const handleSave = (values: StartVariableItem[]) => {
setVariables([...values])
}
const handleClusterSend = () => {
const handleSend = () => {
if (loading || !appId) return
let isCanSend = true
const params: Record<string, any> = {}
@@ -99,36 +99,41 @@ const Chat = forwardRef<ChatRef, { appId: string; graphRef: GraphRef }>(({ appId
const handleStreamMessage = (data: SSEMessage[]) => {
setStreamLoading(false)
data.map(item => {
data.forEach(item => {
const { chunk } = item.data as { chunk: string; };
switch(item.event) {
case 'message':
setChatList(prev => {
const lastChat = { ...prev[prev.length - 1] }
lastChat.content = lastChat.content + chunk
return [
...prev.slice(0, prev.length - 1),
lastChat
]
const newList = [...prev]
const lastIndex = newList.length - 1
if (lastIndex >= 0) {
newList[lastIndex] = {
...newList[lastIndex],
content: newList[lastIndex].content + chunk
}
}
return newList
})
break
case 'workflow_end':
setChatList(prev => {
const lastChat = { ...prev[prev.length - 1] }
lastChat.content = lastChat.content === '' ? null : lastChat.content
return [
...prev.slice(0, prev.length - 1),
lastChat
]
const newList = [...prev]
const lastIndex = newList.length - 1
if (lastIndex >= 0) {
newList[lastIndex] = {
...newList[lastIndex],
content: newList[lastIndex].content === '' ? null : newList[lastIndex].content
}
}
return newList
})
setStreamLoading(false);
break;
setStreamLoading(false)
break
}
})
};
}
form.setFieldValue('message', undefined)
draftRun(appId, {
message: message,
@@ -178,13 +183,13 @@ const Chat = forwardRef<ChatRef, { appId: string; graphRef: GraphRef }>(({ appId
<Input
className="rb:h-11 rb:shadow-[0px_2px_8px_0px_rgba(33,35,50,0.1)]"
placeholder={t('application.chatPlaceholder')}
onPressEnter={handleClusterSend}
onPressEnter={handleSend}
/>
</Form.Item>
</Form>
<img src={ChatSendIcon} className={clsx("rb:w-11 rb:h-11 rb:cursor-pointer", {
'rb:opacity-50': loading,
})} onClick={handleClusterSend} />
})} onClick={handleSend} />
</div>
<VariableConfigModal