feat(file-check): 更新文件检核工具 API Key 配置及相关文档
This commit is contained in:
1 parent
634dee4b81
commit
55cf7ff734
74 files changed
+1525
-1182
No files matched your search
@@ -20,6 +20,7 @@ from app.services.shipping_notice.constants import AUTO_CHAIN_FALLBACK
|
||||
|
||||
|
||||
def cfg_bool(key: str, default: bool = False) -> bool:
|
||||
"""读取 Flask config 布尔值,支持 1/true/yes/on 字符串形式。"""
|
||||
val = current_app.config.get(key)
|
||||
if val is None:
|
||||
return default
|
||||
@@ -29,6 +30,7 @@ def cfg_bool(key: str, default: bool = False) -> bool:
|
||||
|
||||
|
||||
def cfg_int(key: str, default: int = 0, *, min_value: int | None = None) -> int:
|
||||
"""读取 Flask config 整数值,可选 min_value 下限。"""
|
||||
val = current_app.config.get(key)
|
||||
if val is None:
|
||||
parsed = default
|
||||
@@ -43,31 +45,37 @@ def cfg_int(key: str, default: int = 0, *, min_value: int | None = None) -> int:
|
||||
|
||||
|
||||
def auto_progress_enabled() -> bool:
|
||||
"""是否启用 auto_progress 自动推进(SHIPPING_NOTICE_AUTO_PROGRESS_ENABLED)。"""
|
||||
return cfg_bool("SHIPPING_NOTICE_AUTO_PROGRESS_ENABLED", False)
|
||||
|
||||
|
||||
def auto_rpa_inventory_enabled() -> bool:
|
||||
"""是否允许自动触发 RPA 导出库存。"""
|
||||
return cfg_bool("SHIPPING_NOTICE_AUTO_RPA_INVENTORY_ENABLED", True)
|
||||
|
||||
|
||||
def rpa_inventory_timeout_seconds() -> int:
|
||||
"""RPA 库存导出等待超时秒数。"""
|
||||
return cfg_int("SHIPPING_NOTICE_RPA_INVENTORY_TIMEOUT_SECONDS", 120, min_value=5)
|
||||
|
||||
|
||||
def auto_mapping_allow_llm() -> bool:
|
||||
"""字段映射推断是否允许调用 LLM。"""
|
||||
return cfg_bool("SHIPPING_NOTICE_AUTO_MAPPING_ALLOW_LLM", False)
|
||||
|
||||
|
||||
def auto_match_enabled() -> bool:
|
||||
"""auto_progress 是否自动调用 match_inventory。"""
|
||||
return cfg_bool("SHIPPING_NOTICE_AUTO_MATCH_ENABLED", True)
|
||||
|
||||
|
||||
def auto_chain_fallback_enabled() -> bool:
|
||||
"""Hxops chat 是否在 match 后自动串联 export/upload(全局开关)。"""
|
||||
return cfg_bool("SHIPPING_NOTICE_AUTO_CHAIN_FALLBACK", True)
|
||||
|
||||
|
||||
def payload_wants_auto_chain_fallback(payload: dict[str, Any] | None) -> bool:
|
||||
"""True when caller explicitly opts into backend fallback chaining (Hxops workspace/chat)."""
|
||||
"""payload 是否显式请求 Hxops 后端 fallback 串联(auto_chain_fallback=true 且全局开关开启)。"""
|
||||
if not payload or not auto_progress_enabled() or not auto_chain_fallback_enabled():
|
||||
return False
|
||||
val = payload.get(AUTO_CHAIN_FALLBACK)
|
||||
@@ -84,6 +92,7 @@ def merge_tool_payload(
|
||||
*,
|
||||
extra: dict[str, Any] | None = None,
|
||||
) -> dict[str, Any]:
|
||||
"""合并 task_id、lang 与 auto_chain_fallback 等字段,供 workflow 间传递。"""
|
||||
result = tool_payload_for_task(task, payload)
|
||||
if extra:
|
||||
result.update(extra)
|
||||
@@ -93,6 +102,7 @@ def merge_tool_payload(
|
||||
|
||||
|
||||
def tool_payload_for_task(task: ShippingTask, payload: dict[str, Any] | None = None) -> dict[str, Any]:
|
||||
"""从 task 与原始 payload 提取 workflow 间传递的最小字段集(task_id + lang)。"""
|
||||
result: dict[str, Any] = {"task_id": task.task_no}
|
||||
if not payload:
|
||||
return result
|
||||
@@ -102,7 +112,10 @@ def tool_payload_for_task(task: ShippingTask, payload: dict[str, Any] | None = N
|
||||
result["lang"] = lang
|
||||
break
|
||||
return result
|
||||
|
||||
|
||||
def prepend_tool_message(result: dict[str, Any], prefix: str) -> dict[str, Any]:
|
||||
"""将 prefix 消息 prepend 到 Tool 响应 message 字段(自动串联时合并多步提示)。"""
|
||||
note = str(prefix or "").strip()
|
||||
if not note:
|
||||
return result
|
||||
@@ -116,9 +129,12 @@ def prepend_tool_message(result: dict[str, Any], prefix: str) -> dict[str, Any]:
|
||||
|
||||
|
||||
def generate_task_no() -> str:
|
||||
"""生成 SN-YYYYMMDD-XXXXXXXX 格式任务编号。"""
|
||||
return f"SN-{datetime.utcnow().strftime('%Y%m%d')}-{uuid.uuid4().hex[:8].upper()}"
|
||||
|
||||
|
||||
def log_task_event(task: ShippingTask, event_type: str, detail: dict[str, Any] | None = None) -> None:
|
||||
"""写入 ShippingTaskEvent 审计记录(task 尚未 flush 时自动 flush)。"""
|
||||
if task.id is None:
|
||||
db.session.flush()
|
||||
db.session.add(ShippingTaskEvent(
|
||||
|
||||
Reference in new issue
Block a user