Merge branch 'dev' into hugo
This commit is contained in:
commit
3264ed1e07
3 files changed
+513
-71
No files matched your search
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
* features/chat/composables/useChat.ts
|
||||
* SSE 流式对话核心:消息列表、runs、发送与接收。
|
||||
*/
|
||||
@@ -71,8 +71,27 @@ const addAttributionParts = (msg: ChatMessage, value: unknown) => {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 把 SSE 事件附带的元数据同步到当前消息对象。
|
||||
*
|
||||
* 说明:
|
||||
* - Text2SQL 在 `message_end` 才会返回 `payload/chat_log_id`,若这里不合并,
|
||||
* 当前页不会立刻出现“查看全部预览”按钮,只能刷新后从历史消息里重新读到。
|
||||
*/
|
||||
const applyEventMetadata = (msg: ChatMessage, data: Record<string, unknown>) => {
|
||||
const metadata = (data?.metadata || {}) as Record<string, unknown>;
|
||||
if (Number.isInteger(data.chat_log_id)) {
|
||||
msg.chat_log_id = Number(data.chat_log_id);
|
||||
}
|
||||
if (typeof data.type === 'string' && data.type.trim()) {
|
||||
msg.type = data.type as ChatMessage['type'];
|
||||
}
|
||||
if (data.payload && typeof data.payload === 'object') {
|
||||
msg.payload = {
|
||||
...(msg.payload && typeof msg.payload === 'object' ? msg.payload as Record<string, unknown> : {}),
|
||||
...(data.payload as Record<string, unknown>),
|
||||
};
|
||||
}
|
||||
addRetrieverResources(msg, data?.retriever_resources);
|
||||
addRetrieverResources(msg, metadata?.retriever_resources);
|
||||
addRetrieverResources(msg, metadata?.retrieverResources);
|
||||
|
||||
Reference in new issue
Block a user