更新
This commit is contained in:
@@ -7,5 +7,5 @@ __version__ = "1.4.9"
|
||||
|
||||
# 调试模式开启时,登录页显示“演示模式”和“服务器设置”。
|
||||
# 正式发布请保持 False;此时程序只使用下面配置的线上域名。
|
||||
DEBUG_MODE = False
|
||||
DEBUG_MODE = True
|
||||
ONLINE_API_BASE_URL = "https://admin.zhenyangtang.com.cn"
|
||||
|
||||
@@ -3514,7 +3514,7 @@ def _merge_stream_meta(meta: dict[str, Any], payload: Mapping[str, Any]) -> None
|
||||
|
||||
live_fields = (
|
||||
"items", "attachment_count", "submitted_attachment_count", "skipped_attachment_count",
|
||||
"attachment_transfer", "required_sections",
|
||||
"attachment_transfer", "required_sections", "attachment_mode", "attachment_batch_count", "rejected_attachment_count",
|
||||
)
|
||||
event = str(payload.get("event") or "").lower()
|
||||
terminal = event in {"done", "error"}
|
||||
@@ -3574,7 +3574,7 @@ def _merge_stream_meta(meta: dict[str, Any], payload: Mapping[str, Any]) -> None
|
||||
entries = update.get(key)
|
||||
if isinstance(entries, list) and any(
|
||||
isinstance(item, Mapping) and item.get("status") in {
|
||||
"submitted", "failed", "omitted", "skipped",
|
||||
"submitted", "failed", "omitted", "skipped", "rejected",
|
||||
}
|
||||
and (key == "items" or str(item.get("key")) in dict(_REQUIRED_TRANSFER_SECTIONS))
|
||||
for item in entries
|
||||
@@ -3583,7 +3583,7 @@ def _merge_stream_meta(meta: dict[str, Any], payload: Mapping[str, Any]) -> None
|
||||
if "items" in error_receipt_fields:
|
||||
error_receipt_fields.update((
|
||||
"attachment_count", "submitted_attachment_count", "skipped_attachment_count",
|
||||
"attachment_transfer",
|
||||
"attachment_transfer", "attachment_mode", "attachment_batch_count", "rejected_attachment_count",
|
||||
))
|
||||
if terminal and observed and payload.get("transfer_manifest_final") is not True:
|
||||
for key in live_fields:
|
||||
@@ -3657,6 +3657,11 @@ def _transfer_description(meta: Mapping[str, Any], state: str) -> str:
|
||||
lines.append("复用已整理的证据摘要。")
|
||||
elif meta.get("source_form") == "full_context":
|
||||
lines.append("本次正文:来源上下文。")
|
||||
if meta.get("attachment_mode") == "batch_evidence":
|
||||
batch_count = meta.get("attachment_batch_count")
|
||||
if type(batch_count) is int and batch_count > 0:
|
||||
lines.append(f"附件处理:同一模型已进行 {batch_count} 批提交尝试。")
|
||||
lines.append("最终回答依据完整正文与分批提取证据;最终单次请求未重传全部原始附件。")
|
||||
items = meta.get("items")
|
||||
visible_items: list[Mapping[str, Any]] = []
|
||||
if isinstance(items, list):
|
||||
@@ -3664,7 +3669,7 @@ def _transfer_description(meta: Mapping[str, Any], state: str) -> str:
|
||||
statuses = {
|
||||
"prepared": "等待上传", "uploading": "上传中", "uploaded": "已上传,待提交",
|
||||
"submitting": "提交中", "submitted": "引用已提交", "omitted": "未提交", "failed": "提交失败",
|
||||
"skipped": "已跳过",
|
||||
"skipped": "已跳过", "rejected": "上游拒收,未读取",
|
||||
}
|
||||
if meta.get("attachment_transfer") == "uploaded_files":
|
||||
statuses["submitted"] = "已上传并提交"
|
||||
@@ -3679,6 +3684,25 @@ def _transfer_description(meta: Mapping[str, Any], state: str) -> str:
|
||||
status = statuses.get(str(item.get("status")), "等待提交")
|
||||
if item.get("status") == "skipped" and item.get("reason") == "not_found":
|
||||
status = "文件不存在,已跳过"
|
||||
if item.get("status") == "rejected":
|
||||
reason = {"file_count": "数量限制", "file_type": "格式不支持", "file_size": "大小限制",
|
||||
"file_access": "附件不可读取"}.get(str(item.get("reason")))
|
||||
if reason:
|
||||
status = f"上游拒收,未读取({reason})"
|
||||
if item.get("status") == "submitted" and item.get("kind") == "image":
|
||||
text_status = {
|
||||
"processed": "附带本地识别文字,供模型核对",
|
||||
"unreadable": "未取得可用识别文字,保留原图分析",
|
||||
"unavailable": "本地文字识别未完成,保留原图分析",
|
||||
"withheld": "本地识别文字超出本轮容量,未附加;保留原图分析",
|
||||
}.get(str(item.get("text_check_status")))
|
||||
if text_status:
|
||||
status = f"{status};{text_status}"
|
||||
if item.get("status") == "submitted" and item.get("evidence_status") in {"unreadable", "unverified"}:
|
||||
if item.get("evidence_reason") == "context_budget":
|
||||
status = f"{status};本轮综合容量不足,未可靠纳入结论"
|
||||
else:
|
||||
status = f"{status};逐项观察未核实,已向模型说明资料缺口"
|
||||
lines.append(f"{label}({kind}):{status}")
|
||||
submitted_count = meta.get("submitted_attachment_count")
|
||||
valid_submitted_count = type(submitted_count) is int and submitted_count >= 0
|
||||
@@ -3688,9 +3712,10 @@ def _transfer_description(meta: Mapping[str, Any], state: str) -> str:
|
||||
for item in items
|
||||
)
|
||||
if has_video or (not valid_submitted_count and any(
|
||||
item.get("status") == "skipped" for item in visible_items
|
||||
item.get("status") in {"omitted", "skipped", "rejected", "failed"}
|
||||
for item in visible_items
|
||||
)):
|
||||
count = sum(item.get("status") not in {"omitted", "skipped"} for item in visible_items)
|
||||
count = sum(item.get("status") not in {"omitted", "skipped", "rejected", "failed"} for item in visible_items)
|
||||
if type(count) is int and count >= 0:
|
||||
lines.append(f"本请求附件通道:{count} 项;模型实际读取进度不可获取。")
|
||||
return "\n".join(lines)
|
||||
@@ -6233,6 +6258,7 @@ class AiConsultDialog(QDialog):
|
||||
time_text="系统",
|
||||
)
|
||||
return True
|
||||
self._cancel_stream(replaced=self._asking)
|
||||
status = self._append_bubble(
|
||||
"ai",
|
||||
"正在核对当前诊单与患者归属,并读取患者全部纵向资料生成处方草稿。",
|
||||
@@ -6358,6 +6384,10 @@ class AiConsultDialog(QDialog):
|
||||
if str(payload.get("task") or "") != "prescription_generate":
|
||||
status.set_payload("AI返回的不是处方草稿,已停止开方。")
|
||||
return
|
||||
if _required_transfer_sections(payload) or isinstance(payload.get("items"), list):
|
||||
receipt: dict[str, Any] = {}
|
||||
_merge_stream_meta(receipt, {**payload, "event": "done"})
|
||||
status.set_transfer_status(_transfer_description(receipt, "处方草稿资料处理已完成。"))
|
||||
draft = _as_mapping(payload.get("prescription_draft"))
|
||||
herbs = draft.get("herbs")
|
||||
if (
|
||||
@@ -6529,6 +6559,13 @@ class AiConsultDialog(QDialog):
|
||||
if generation != self._generation:
|
||||
return
|
||||
message = friendly_error(error)
|
||||
error_data = getattr(error, "data", None)
|
||||
if isinstance(error_data, Mapping) and (
|
||||
_required_transfer_sections(error_data) or isinstance(error_data.get("items"), list)
|
||||
):
|
||||
receipt: dict[str, Any] = {}
|
||||
_merge_stream_meta(receipt, {**error_data, "event": "error"})
|
||||
status.set_transfer_status(_transfer_description(receipt, "本次请求失败,资料或回复未完成。"))
|
||||
status.set_payload(f"{prefix}:{message}")
|
||||
status.set_time_text("系统")
|
||||
show_toast(self, message, "danger", 4200)
|
||||
@@ -6746,6 +6783,13 @@ class AiConsultDialog(QDialog):
|
||||
state = "资料正文已整理,正在准备提交…"
|
||||
if payload.get("status") == "failed":
|
||||
state = "资料提交失败。"
|
||||
if (
|
||||
self._stream_meta.get("attachment_mode") == "batch_evidence"
|
||||
and payload.get("transfer_manifest_final") is not True
|
||||
and any(item.get("status") != "submitted" for item in _required_transfer_sections(self._stream_meta) or []
|
||||
if isinstance(item, Mapping))
|
||||
):
|
||||
state = "正在分批提交附件并提取资料,完整病历尚未提交综合分析…"
|
||||
if phase == "cancelled":
|
||||
state = _cancel_description(self._stream_meta)
|
||||
self._update_transfer_status(state)
|
||||
|
||||
Reference in New Issue
Block a user