perf:优化麦麦观察体验,优化推理检索体验

This commit is contained in:
SengokuCola
2026-05-07 20:15:14 +08:00
parent 2a7722f84e
commit 827cdbd441
23 changed files with 1206 additions and 376 deletions

View File

@@ -367,6 +367,47 @@ async def emit_session_start(
})
async def emit_stage_status(
*,
session_id: str,
session_name: str,
stage: str,
detail: str = "",
round_text: str = "",
agent_state: str = "",
stage_started_at: float,
updated_at: float,
timestamp: float,
) -> None:
"""广播单个聊天流的当前阶段状态。"""
await _broadcast("stage.status", {
"session_id": session_id,
"session_name": session_name,
"stage": stage,
"detail": detail,
"round_text": round_text,
"agent_state": agent_state,
"stage_started_at": stage_started_at,
"updated_at": updated_at,
"timestamp": timestamp,
})
async def emit_stage_removed(
*,
session_id: str,
session_name: str = "",
) -> None:
"""广播聊天流阶段状态移除事件。"""
await _broadcast("stage.removed", {
"session_id": session_id,
"session_name": session_name,
"timestamp": time.time(),
})
async def emit_message_ingested(
session_id: str,
speaker_name: str,
@@ -385,6 +426,26 @@ async def emit_message_ingested(
})
async def emit_message_sent(
session_id: str,
speaker_name: str,
content: str,
message_id: str,
timestamp: float,
source_kind: str = "",
) -> None:
"""广播 MaiSaka 自己发送的消息事件。"""
await _broadcast("message.sent", {
"session_id": session_id,
"speaker_name": speaker_name,
"content": content,
"message_id": message_id,
"source_kind": source_kind,
"timestamp": timestamp,
})
async def emit_cycle_start(
session_id: str,
cycle_id: int,
@@ -404,6 +465,23 @@ async def emit_cycle_start(
})
async def emit_cycle_end(
session_id: str,
cycle_id: int,
time_records: Dict[str, float],
agent_state: str,
) -> None:
"""广播单个推理循环结束事件。"""
await _broadcast("cycle.end", {
"session_id": session_id,
"cycle_id": cycle_id,
"time_records": _normalize_payload_value(time_records),
"agent_state": agent_state,
"timestamp": time.time(),
})
async def emit_timing_gate_result(
session_id: str,
cycle_id: int,