更新
This commit is contained in:
@@ -3464,7 +3464,10 @@ def _merge_stream_meta(meta: dict[str, Any], payload: Mapping[str, Any]) -> None
|
||||
failure receipt must still correct an earlier reference-sent event.
|
||||
"""
|
||||
|
||||
live_fields = ("items", "attachment_count", "attachment_transfer", "required_sections")
|
||||
live_fields = (
|
||||
"items", "attachment_count", "submitted_attachment_count", "skipped_attachment_count",
|
||||
"attachment_transfer", "required_sections",
|
||||
)
|
||||
event = str(payload.get("event") or "").lower()
|
||||
terminal = event in {"done", "error"}
|
||||
observed = meta.get("_transfer_progress_observed") is True
|
||||
@@ -3482,7 +3485,7 @@ def _merge_stream_meta(meta: dict[str, Any], payload: Mapping[str, Any]) -> None
|
||||
if failed_submission:
|
||||
# Older servers report only the failed columns/code. That is a failed
|
||||
# attachment submission, not a later generation failure. Correct known
|
||||
# items without inventing sources or changing explicitly omitted files.
|
||||
# items without inventing sources or changing omitted/skipped files.
|
||||
for key in ("items", "required_sections"):
|
||||
entries = update.get(key)
|
||||
if isinstance(entries, list) and (
|
||||
@@ -3498,18 +3501,42 @@ def _merge_stream_meta(meta: dict[str, Any], payload: Mapping[str, Any]) -> None
|
||||
} else item
|
||||
for item in previous
|
||||
]
|
||||
previous_items, items = meta.get("items"), update.get("items")
|
||||
if isinstance(previous_items, list) and isinstance(items, list):
|
||||
# A later bulk upload/submission result cannot submit a file that was
|
||||
# already confirmed missing. Retain its original source and skip reason.
|
||||
items = list(items)
|
||||
for index, previous in enumerate(previous_items):
|
||||
if not isinstance(previous, Mapping) or previous.get("status") != "skipped":
|
||||
continue
|
||||
match = next((
|
||||
position for position, item in enumerate(items)
|
||||
if isinstance(item, Mapping)
|
||||
and (item.get("kind"), item.get("label"))
|
||||
== (previous.get("kind"), previous.get("label"))
|
||||
), None)
|
||||
if match is None:
|
||||
items.insert(min(index, len(items)), dict(previous))
|
||||
else:
|
||||
items[match] = {**items[match], **previous}
|
||||
update["items"] = items
|
||||
error_receipt_fields: set[str] = set()
|
||||
if event == "error":
|
||||
for key in ("items", "required_sections"):
|
||||
entries = update.get(key)
|
||||
if isinstance(entries, list) and any(
|
||||
isinstance(item, Mapping) and item.get("status") in {"submitted", "failed", "omitted"}
|
||||
isinstance(item, Mapping) and item.get("status") in {
|
||||
"submitted", "failed", "omitted", "skipped",
|
||||
}
|
||||
and (key == "items" or str(item.get("key")) in dict(_REQUIRED_TRANSFER_SECTIONS))
|
||||
for item in entries
|
||||
):
|
||||
error_receipt_fields.add(key)
|
||||
if "items" in error_receipt_fields:
|
||||
error_receipt_fields.update(("attachment_count", "attachment_transfer"))
|
||||
error_receipt_fields.update((
|
||||
"attachment_count", "submitted_attachment_count", "skipped_attachment_count",
|
||||
"attachment_transfer",
|
||||
))
|
||||
if terminal and observed and payload.get("transfer_manifest_final") is not True:
|
||||
for key in live_fields:
|
||||
if key in meta:
|
||||
@@ -3589,6 +3616,7 @@ def _transfer_description(meta: Mapping[str, Any], state: str) -> str:
|
||||
statuses = {
|
||||
"prepared": "等待上传", "uploading": "上传中", "uploaded": "已上传,待提交",
|
||||
"submitting": "提交中", "submitted": "引用已提交", "omitted": "未提交", "failed": "提交失败",
|
||||
"skipped": "已跳过",
|
||||
}
|
||||
if meta.get("attachment_transfer") == "uploaded_files":
|
||||
statuses["submitted"] = "已上传并提交"
|
||||
@@ -3600,13 +3628,21 @@ def _transfer_description(meta: Mapping[str, Any], state: str) -> str:
|
||||
label = str(item.get("label") or "")
|
||||
if not re.fullmatch(r"(?:图片附件|文档附件|文件附件|音频附件|自定义附件|附件|检查报告|舌象)\s*\d+", label):
|
||||
label = f"{kind}附件{index}"
|
||||
lines.append(f"{label}({kind}):{statuses.get(str(item.get('status')), '等待提交')}")
|
||||
count = meta.get("attachment_count")
|
||||
if isinstance(items, list) and any(
|
||||
status = statuses.get(str(item.get("status")), "等待提交")
|
||||
if item.get("status") == "skipped" and item.get("reason") == "not_found":
|
||||
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
|
||||
count = submitted_count if valid_submitted_count else meta.get("attachment_count")
|
||||
has_video = isinstance(items, list) and any(
|
||||
isinstance(item, Mapping) and _is_video_transfer_item(item)
|
||||
for item in items
|
||||
):
|
||||
count = sum(item.get("status") != "omitted" for item in visible_items)
|
||||
)
|
||||
if has_video or (not valid_submitted_count and any(
|
||||
item.get("status") == "skipped" for item in visible_items
|
||||
)):
|
||||
count = sum(item.get("status") not in {"omitted", "skipped"} for item in visible_items)
|
||||
if type(count) is int and count >= 0:
|
||||
lines.append(f"本请求附件通道:{count} 项;模型实际读取进度不可获取。")
|
||||
return "\n".join(lines)
|
||||
@@ -6642,12 +6678,14 @@ class AiConsultDialog(QDialog):
|
||||
type(index) is int and type(total) is int and 0 < index <= total
|
||||
) else "正在上传附件…"
|
||||
if phase == "attachments" and payload.get("status") == "submitted":
|
||||
items = payload.get("items")
|
||||
items = self._stream_meta.get("items")
|
||||
visible = [item for item in items if isinstance(item, Mapping)
|
||||
and not _is_video_transfer_item(item)] if isinstance(items, list) else []
|
||||
if visible and all(item.get("status") == "omitted" for item in visible):
|
||||
if visible and all(item.get("status") == "skipped" for item in visible):
|
||||
state = "资料正文已提交;不存在的附件已跳过,等待 AI 正文…"
|
||||
elif visible and all(item.get("status") in {"omitted", "skipped"} for item in visible):
|
||||
state = "资料正文已提交;本次附件未提交,等待 AI 正文…"
|
||||
elif payload.get("attachment_count") == 0:
|
||||
elif self._stream_meta.get("submitted_attachment_count") == 0 or self._stream_meta.get("attachment_count") == 0:
|
||||
state = "资料正文已提交,等待 AI 正文…"
|
||||
else:
|
||||
state = "附件引用已提交,等待模型处理…"
|
||||
|
||||
Reference in New Issue
Block a user