feat(shipping-notice): 添加订单抽取功能,支持异步运行和管理,优化相关数据模型和处理逻辑
This commit is contained in:
1 parent
34d489a2d1
commit
ce26d6d0c4
144 files changed
+12241
-4233
No files matched your search
@@ -1,9 +1,9 @@
|
||||
"""
|
||||
tests/test_shipping_notice_openapi_contract.py
|
||||
|
||||
用途:锁定发货通知动态订单字段、证据观察值与库存连接器 OpenAPI 命名契约。
|
||||
用途:锁定发货通知聊天 Tool 边界与库存连接器 OpenAPI 命名契约。
|
||||
依赖:Flask 测试 client、静态 Dify OpenAPI JSON。
|
||||
逻辑:分别校验动态 builder 输出与脚本生成的静态快照,防止两者发生漂移。
|
||||
逻辑:分别校验动态 builder 与静态快照,确保旧订单抽取 Tool 不再暴露且连接器契约不漂移。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -15,7 +15,7 @@ from typing import Any
|
||||
|
||||
def _assert_connector_contract(spec: dict[str, Any]) -> None:
|
||||
"""
|
||||
校验订单行与库存连接器的字段边界。
|
||||
校验订单抽取 Tool 已下线且库存连接器字段边界保持稳定。
|
||||
|
||||
核心逻辑:订单行只接受动态 fields 数组,每个字段携带稳定 field_id 和 observations;
|
||||
任务状态说明使用 inventory_connector_type,并拒绝旧 inventory_source_type 命名。
|
||||
@@ -26,24 +26,9 @@ def _assert_connector_contract(spec: dict[str, Any]) -> None:
|
||||
Returns:
|
||||
None;契约不符时由 pytest assertion 报错。
|
||||
"""
|
||||
order_schema = spec["paths"]["/tools/submit_order_extraction"]["post"]["requestBody"]["content"][
|
||||
"application/json"
|
||||
]["schema"]["properties"]["orders"]["items"]
|
||||
line_properties = order_schema["properties"]["lines"]["items"]["properties"]
|
||||
assert order_schema["properties"]["lines"]["items"]["additionalProperties"] is False
|
||||
assert set(line_properties) == {"fields"}
|
||||
assert line_properties["fields"]["type"] == "array"
|
||||
field_item = line_properties["fields"]["items"]
|
||||
assert {"field_id", "observations"} <= set(field_item["properties"])
|
||||
observation = field_item["properties"]["observations"]["items"]
|
||||
assert {"value", "document_id", "quote", "confidence"} <= set(observation["properties"])
|
||||
assert not {"sku", "vendor_part_number", "source_type", "hub_code"} & set(line_properties)
|
||||
|
||||
request_schema = spec["paths"]["/tools/submit_order_extraction"]["post"]["requestBody"]["content"][
|
||||
"application/json"
|
||||
]["schema"]
|
||||
assert "schema_version" not in request_schema["properties"]
|
||||
assert request_schema["required"] == ["agent_runtime_context", "input_snapshot_hash", "orders"]
|
||||
paths = spec['paths']
|
||||
assert '/tools/get_order_extraction_context' not in paths
|
||||
assert '/tools/submit_order_extraction' not in paths
|
||||
|
||||
status_description = spec["paths"]["/tools/get_task_status"]["post"]["description"]
|
||||
assert "inventory_connector_type" in status_description
|
||||
|
||||
Reference in new issue
Block a user