ver0.1
This commit is contained in:
@@ -52,6 +52,8 @@ class PendingConsumableConfirmation:
|
||||
model_top1_confidence: float
|
||||
#: 本轮待确认在解析失败时累计次数(首败 + 重试),供 API 计算 retry_remaining。
|
||||
voice_parse_failures: int = 0
|
||||
#: 本场手术中待确认任务入队时的累计序号(自 1 起,入队时递增)。
|
||||
enqueue_ordinal: int = 1
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -87,6 +89,8 @@ class SurgerySessionState:
|
||||
surgery_started_wall: float | None = None
|
||||
#: 术间绑定配置解析出的语音桌面终端 ID;停录时用于推送 end。
|
||||
voice_terminal_id: str | None = None
|
||||
#: 待确认入队已分配到的最大序号(与 ``pending_by_id`` 中 ``enqueue_ordinal`` 一致递增)。
|
||||
pending_ordinal_next: int = 0
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -203,6 +207,32 @@ class SurgerySessionRegistry:
|
||||
return p
|
||||
return None
|
||||
|
||||
def pending_queue_pending_count(self, surgery_id: str) -> int:
|
||||
"""FIFO 中仍为 pending 的条数(与 ``next_pending_confirmation`` 遍历规则一致)。"""
|
||||
run = self._active.get(surgery_id)
|
||||
if run is None:
|
||||
return 0
|
||||
st = run.state
|
||||
n = 0
|
||||
for cid in st.pending_fifo:
|
||||
p = st.pending_by_id.get(cid)
|
||||
if p is not None and p.status == "pending":
|
||||
n += 1
|
||||
return n
|
||||
|
||||
def pending_queue_position_1based(
|
||||
self, surgery_id: str, confirmation_id: str
|
||||
) -> int | None:
|
||||
"""``confirmation_id`` 在当前 ``pending_fifo`` 中的 1-based 位置(队首为 1)。"""
|
||||
run = self._active.get(surgery_id)
|
||||
if run is None:
|
||||
return None
|
||||
st = run.state
|
||||
try:
|
||||
return st.pending_fifo.index(confirmation_id) + 1
|
||||
except ValueError:
|
||||
return None
|
||||
|
||||
async def resolve_pending_confirmation(
|
||||
self,
|
||||
surgery_id: str,
|
||||
@@ -436,6 +466,8 @@ class SurgerySessionRegistry:
|
||||
return None
|
||||
state.last_detail_monotonic[dedupe_key] = now_m
|
||||
|
||||
state.pending_ordinal_next += 1
|
||||
ordinal = state.pending_ordinal_next
|
||||
confirm_id = str(uuid.uuid4())
|
||||
prompt = build_prompt_text(opts)
|
||||
pending = PendingConsumableConfirmation(
|
||||
@@ -446,6 +478,7 @@ class SurgerySessionRegistry:
|
||||
created_at=datetime.now(timezone.utc),
|
||||
model_top1_label=top_key,
|
||||
model_top1_confidence=top_confidence,
|
||||
enqueue_ordinal=ordinal,
|
||||
)
|
||||
state.pending_by_id[confirm_id] = pending
|
||||
state.pending_fifo.append(confirm_id)
|
||||
|
||||
Reference in New Issue
Block a user