feat(chat): 更新发货任务处理逻辑和界面文本
- 移除不必要的状态引用 - 更新上传处理提示文本,使用国际化支持 - 扩展发货任务摘要接口,增加错误信息和短缺信息 - 更新多语言支持的文本,改善用户体验 - 增加批次工作区的汇总信息和操作提示
This commit is contained in:
1 parent
0b083cfdbd
commit
1fc9976ca3
60 files changed
+3876
-639
No files matched your search
@@ -8,6 +8,10 @@ import { getAuthHeaders } from '@/shared/utils/auth';
|
||||
import { applyStreamErrorToMessage, type StreamErrorLabels } from '../utils/streamErrorMessage';
|
||||
import type { ChatMessage, ChatRun, RetrieverResource } from '../types/chat.types';
|
||||
|
||||
export interface SendMessageLifecycleHooks {
|
||||
onAssistantMessageFinished?: (message: ChatMessage, runMessages: ChatMessage[]) => void | Promise<void>;
|
||||
}
|
||||
|
||||
const normalizeResources = (resources: unknown) => {
|
||||
if (!resources) return [];
|
||||
if (Array.isArray(resources)) return resources;
|
||||
@@ -191,15 +195,17 @@ export function useChat() {
|
||||
| { type: 'image' | 'document' | 'audio' | 'video' | 'custom'; transfer_method: 'local_file'; upload_file_id: string }
|
||||
| { type: 'image' | 'document' | 'audio' | 'video' | 'custom'; transfer_method: 'remote_url'; url: string }
|
||||
>,
|
||||
context?: { task_id?: string; batch_no?: string },
|
||||
context?: { task_id?: string; batch_no?: string; display_query?: string },
|
||||
hooks?: SendMessageLifecycleHooks,
|
||||
) => {
|
||||
const displayQuery = String(context?.display_query || query || '').trim();
|
||||
const runViewId = viewId.value;
|
||||
const runMessages = messages.value;
|
||||
const run: ChatRun = {
|
||||
runId: ++runSeq,
|
||||
agentId,
|
||||
viewId: runViewId,
|
||||
query,
|
||||
query: displayQuery,
|
||||
messages: runMessages,
|
||||
conversationId: conversationId.value,
|
||||
status: 'running',
|
||||
@@ -209,7 +215,7 @@ export function useChat() {
|
||||
if (runs.value.length > 30) runs.value = runs.value.slice(0, 30);
|
||||
activeRunId.value = run.runId;
|
||||
|
||||
runMessages.push({ role: 'user', content: query });
|
||||
runMessages.push({ role: 'user', content: displayQuery });
|
||||
let botMsgIndex: number | null = null;
|
||||
let hasAssistantContent = false;
|
||||
let hasTerminalEvent = false;
|
||||
@@ -239,6 +245,7 @@ export function useChat() {
|
||||
files: files && files.length > 0 ? files : undefined,
|
||||
task_id: context?.task_id || undefined,
|
||||
batch_no: context?.batch_no || undefined,
|
||||
display_query: context?.display_query || undefined,
|
||||
}),
|
||||
});
|
||||
|
||||
@@ -359,6 +366,12 @@ export function useChat() {
|
||||
if (messages.value === runMessages) {
|
||||
isThinking.value = false;
|
||||
}
|
||||
if (run.status === 'done' && botMsgIndex !== null) {
|
||||
const botMsg = runMessages[botMsgIndex];
|
||||
if (botMsg) {
|
||||
await hooks?.onAssistantMessageFinished?.(botMsg, runMessages);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user