refactor(agent, shipping): 简化代理模型并完善订单抽取业务
- 移除 Agent 的 exposure_mode 与 internal_executor 相关逻辑,清理关联的过滤、序列化代码 - 删除废弃的 AgentRuntimeBinding 模型及其依赖 - 新增订单抽取上传批次、请求快照等数据库迁移与业务逻辑 - 修复附件完整性检测、订单抽取状态映射问题 - 更新多语言错误文案与前端单元测试配置 - 清理平台配置中不再使用的暴露模式配置
This commit is contained in:
1 parent
1f3ecb87b7
commit
61ac6403c4
159 files changed
+12883
-5099
No files matched your search
@@ -149,16 +149,21 @@ def extract_notice_text(
|
||||
file_path: Path,
|
||||
*,
|
||||
retain_payloads: bool = False,
|
||||
eml_attachment_mode: Literal["deep", "preview"] = "deep",
|
||||
preview_only: bool = False,
|
||||
) -> tuple[str, dict[str, Any]]:
|
||||
"""
|
||||
从发货通知附件抽取纯文本(PDF/DOCX/CSV/图片 OCR/EML/HTML 等)。
|
||||
|
||||
核心逻辑:普通文件走 edkb loaders;.eml 委托 eml_parse 做结构化解析(元数据 + 真实附件独立抽取),
|
||||
内嵌 Logo/签名图不进入附件列表,也不参与订单文本拼接。
|
||||
核心逻辑:普通文件走 edkb loaders;.eml 委托 eml_parse 做结构化解析。
|
||||
`deep` 模式递归抽取附件文本,`preview` 模式仅保留邮件头/正文/附件目录。
|
||||
非 EML 的 `preview_only` 只返回文件元信息,避免上传阶段触发 Loader 或 OCR。
|
||||
|
||||
Args:
|
||||
file_path: 已落盘的通知文件路径。
|
||||
retain_payloads: 仅 EML;True 时保留 attachments[*]._payload_bytes 供 Intake 派生资产。
|
||||
eml_attachment_mode: `preview` 仅生成附件目录;`deep` 递归抽取附件文本。
|
||||
preview_only: True 时普通文件不执行文本/OCR 抽取,留待发送后的深度识别阶段。
|
||||
|
||||
Returns:
|
||||
tuple[str, dict]: (抽取文本, meta 含 warnings、file_type;eml 另含 email/attachments/attachment_count)。
|
||||
@@ -168,6 +173,13 @@ def extract_notice_text(
|
||||
ctx = Context(file_type=ext)
|
||||
warnings: list[str] = []
|
||||
|
||||
if preview_only and ext != "eml":
|
||||
return "", {
|
||||
"warnings": warnings,
|
||||
"file_type": ext,
|
||||
"content_mode": "preview",
|
||||
}
|
||||
|
||||
if ext in {"txt", "md", "log"}:
|
||||
return _decode_text(path.read_bytes()).strip(), {"warnings": warnings, "file_type": ext}
|
||||
if ext in {"html", "htm"}:
|
||||
@@ -178,6 +190,7 @@ def extract_notice_text(
|
||||
path.read_bytes(),
|
||||
extract_text=extract_notice_text,
|
||||
retain_payloads=retain_payloads,
|
||||
attachment_mode=eml_attachment_mode,
|
||||
)
|
||||
|
||||
blocks: list[Block] = []
|
||||
@@ -325,6 +338,7 @@ def intake_notice_attachment(
|
||||
task_no: str | None = None,
|
||||
temp_request_id: str | None = None,
|
||||
temp_index: int = 1,
|
||||
eml_attachment_mode: Literal["deep", "preview"] = "preview",
|
||||
) -> NoticeIntakeResult:
|
||||
"""
|
||||
单份发货通知附件的统一接入:落盘 → 抽取 → 截断 → 失败分流。
|
||||
@@ -339,6 +353,7 @@ def intake_notice_attachment(
|
||||
task_no: storage=task 时必填。
|
||||
temp_request_id: storage=temp 时必填。
|
||||
temp_index: storage=temp 时文件序号,避免同名覆盖。
|
||||
eml_attachment_mode: EML 上传模式;`preview` 仅保留附件目录,适合输入栏快览。
|
||||
|
||||
Returns:
|
||||
NoticeIntakeResult: 含 accepted / empty_text / extract_failed 状态与截断后正文。
|
||||
@@ -363,7 +378,7 @@ def intake_notice_attachment(
|
||||
if not temp_request_id:
|
||||
raise ValueError("temp_request_id is required for temp storage")
|
||||
saved_path = save_temp_notice_upload(temp_request_id, temp_index, name, raw_bytes)
|
||||
text, meta = extract_notice_text(saved_path)
|
||||
text, meta = extract_notice_text(saved_path, eml_attachment_mode=eml_attachment_mode)
|
||||
warnings = list(meta.get("warnings") or []) if isinstance(meta, dict) else []
|
||||
except Exception as exc:
|
||||
warnings = [f"notice_extract_failed:{exc}"]
|
||||
@@ -381,7 +396,17 @@ def intake_notice_attachment(
|
||||
saved_path=saved_path,
|
||||
)
|
||||
|
||||
if not str(text or "").strip():
|
||||
preview_accept_without_text = (
|
||||
isinstance(meta, dict)
|
||||
and str(meta.get("file_type") or "").lower() == "eml"
|
||||
and str(meta.get("eml_attachment_mode") or "").lower() == "preview"
|
||||
and (
|
||||
bool(meta.get("attachment_count"))
|
||||
or bool(meta.get("attachments"))
|
||||
or bool(meta.get("email"))
|
||||
)
|
||||
)
|
||||
if not str(text or "").strip() and not preview_accept_without_text:
|
||||
return NoticeIntakeResult(
|
||||
filename=name,
|
||||
source_type=source_type,
|
||||
|
||||
Reference in new issue
Block a user