Merge branch 'develop' into feature/end_zy
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
* @Author: ZhaoYing
|
||||
* @Date: 2026-02-06 21:10:56
|
||||
* @Last Modified by: ZhaoYing
|
||||
* @Last Modified time: 2026-04-07 18:07:38
|
||||
* @Last Modified time: 2026-04-21 14:59:13
|
||||
*/
|
||||
/**
|
||||
* Workflow Chat Component
|
||||
@@ -41,13 +41,17 @@ import type { ChatToolbarRef } from '@/components/Chat/ChatToolbar'
|
||||
import Runtime from './Runtime';
|
||||
import type { FeaturesConfigForm } from '@/views/ApplicationConfig/types';
|
||||
import { replaceVariables } from '@/views/ApplicationConfig/Agent';
|
||||
import { useWorkflowStore } from '@/store/workflow';
|
||||
|
||||
const Chat = forwardRef<ChatRef, { appId: string; graphRef: GraphRef; data: WorkflowConfig | null; features?: FeaturesConfigForm }>(({
|
||||
const Chat = forwardRef<ChatRef, { appId: string; graphRef: GraphRef; data: WorkflowConfig | null; features?: FeaturesConfigForm }>(({ // eslint-disable-line
|
||||
appId, graphRef, features
|
||||
}, ref) => {
|
||||
const { t } = useTranslation()
|
||||
const { message: messageApi } = App.useApp()
|
||||
const { setChatHistory } = useWorkflowStore()
|
||||
const conversationIdRef = useRef<string>('draft')
|
||||
const toolbarRef = useRef<ChatToolbarRef>(null)
|
||||
const abortRef = useRef<(() => void) | null>(null)
|
||||
const [toolbarReady, setToolbarReady] = useState(false)
|
||||
const toolbarCallbackRef = useCallback((node: ChatToolbarRef | null) => {
|
||||
(toolbarRef as React.MutableRefObject<ChatToolbarRef | null>).current = node
|
||||
@@ -62,6 +66,8 @@ const Chat = forwardRef<ChatRef, { appId: string; graphRef: GraphRef; data: Work
|
||||
const [fileList, setFileList] = useState<any[]>([])
|
||||
const [message, setMessage] = useState<string | undefined>(undefined)
|
||||
|
||||
console.log('abortRef', abortRef)
|
||||
|
||||
/**
|
||||
* Opens the chat drawer and loads workflow variables from the start node
|
||||
*/
|
||||
@@ -113,11 +119,14 @@ const Chat = forwardRef<ChatRef, { appId: string; graphRef: GraphRef; data: Work
|
||||
* Closes the drawer and resets all state
|
||||
*/
|
||||
const handleClose = () => {
|
||||
abortRef.current?.()
|
||||
abortRef.current = null;
|
||||
setOpen(false)
|
||||
setToolbarReady(false)
|
||||
setChatList([])
|
||||
setVariables([])
|
||||
setConversationId(null)
|
||||
conversationIdRef.current = 'draft'
|
||||
setMessage(undefined)
|
||||
toolbarRef.current?.setFiles([])
|
||||
toolbarRef.current?.setVariables([])
|
||||
@@ -189,7 +198,7 @@ const Chat = forwardRef<ChatRef, { appId: string; graphRef: GraphRef; data: Work
|
||||
elapsed_time?: string;
|
||||
error?: any;
|
||||
state: Record<string, any>;
|
||||
status?: 'completed' | 'failed',
|
||||
status?: 'completed' | 'failed' | 'running',
|
||||
citations?: {
|
||||
document_id: string;
|
||||
file_name: string;
|
||||
@@ -231,6 +240,7 @@ const Chat = forwardRef<ChatRef, { appId: string; graphRef: GraphRef; data: Work
|
||||
node_name: name,
|
||||
node_type: type,
|
||||
icon,
|
||||
status: 'running',
|
||||
content: {},
|
||||
}
|
||||
} else {
|
||||
@@ -240,6 +250,7 @@ const Chat = forwardRef<ChatRef, { appId: string; graphRef: GraphRef; data: Work
|
||||
node_name: name,
|
||||
node_type: type,
|
||||
icon,
|
||||
status: 'running',
|
||||
content: {},
|
||||
})
|
||||
}
|
||||
@@ -344,6 +355,7 @@ const Chat = forwardRef<ChatRef, { appId: string; graphRef: GraphRef; data: Work
|
||||
}
|
||||
|
||||
if (conversation_id && conversationId !== conversation_id) {
|
||||
conversationIdRef.current = conversation_id
|
||||
setConversationId(conversation_id)
|
||||
}
|
||||
})
|
||||
@@ -388,7 +400,7 @@ const Chat = forwardRef<ChatRef, { appId: string; graphRef: GraphRef; data: Work
|
||||
])
|
||||
setLoading(true)
|
||||
setStreamLoading(true)
|
||||
draftRun(appId, data, handleStreamMessage)
|
||||
draftRun(appId, data, handleStreamMessage, abort => { abortRef.current = abort })
|
||||
.catch((error) => {
|
||||
const errorInfo = JSON.parse(error.message)
|
||||
setChatList(prev => {
|
||||
@@ -440,6 +452,10 @@ const Chat = forwardRef<ChatRef, { appId: string; graphRef: GraphRef; data: Work
|
||||
}
|
||||
}, [chatList.length, features?.opening_statement, variables])
|
||||
|
||||
useEffect(() => {
|
||||
setChatHistory(conversationIdRef.current, chatList)
|
||||
}, [chatList])
|
||||
|
||||
return (
|
||||
<RbDrawer
|
||||
title={<Flex align="center" gap={10}>
|
||||
|
||||
Reference in New Issue
Block a user