feat(chat): 新增对话流性能监控功能及相关日志输出
This commit is contained in:
1 parent
e827c5dc38
commit
9d7dad6a4b
19 files changed
+1603
-271
No files matched your search
@@ -227,7 +227,42 @@ export function useChat() {
|
||||
const currentBotMsg = runMessages[botMsgIndex];
|
||||
if (currentBotMsg) applyEventMetadata(currentBotMsg, data);
|
||||
}
|
||||
} else if (eventName === 'chat_perf') {
|
||||
const perf = (data.perf || {}) as Record<string, unknown>;
|
||||
const nodes = Array.isArray(perf.nodes) ? perf.nodes : [];
|
||||
// eslint-disable-next-line no-console
|
||||
console.groupCollapsed(
|
||||
`[chat-perf] request=${String(perf.request_id || '')} total=${String(perf.total_ms ?? '')}ms ttft=${String(perf.ttft_ms ?? '')}ms`,
|
||||
);
|
||||
if (nodes.length > 0) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.table(
|
||||
nodes.map((node) => {
|
||||
const item = node as Record<string, unknown>;
|
||||
return {
|
||||
index: item.index,
|
||||
title: item.title,
|
||||
type: item.node_type,
|
||||
elapsed_ms: item.elapsed_ms,
|
||||
at_ms: item.at_ms,
|
||||
status: item.status,
|
||||
};
|
||||
}),
|
||||
);
|
||||
} else {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(perf);
|
||||
}
|
||||
// eslint-disable-next-line no-console
|
||||
console.groupEnd();
|
||||
} else if (eventName === 'message_end' || eventName === 'workflow_finished') {
|
||||
const relay = (data.hxops_relay || {}) as Record<string, unknown>;
|
||||
if (relay.total_relay_ms != null) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.info(
|
||||
`[chat-perf] hxops relay first_chunk=${String(relay.first_chunk_ms ?? '')}ms total=${String(relay.total_relay_ms ?? '')}ms`,
|
||||
);
|
||||
}
|
||||
run.status = 'done';
|
||||
if (messages.value === runMessages) isThinking.value = false;
|
||||
if (botMsgIndex !== null && Number.isInteger(data.chat_log_id)) {
|
||||
|
||||
Reference in new issue
Block a user