feat(shipping-notice): 增强订单抽取功能,添加进度事件和诊断运行管理,优化数据模型和访问控制
This commit is contained in:
1 parent
ce26d6d0c4
commit
c4095b08da
175 files changed
+13064
-1814
No files matched your search
@@ -17,6 +17,7 @@ from app.services.agent_registry.resolver import (
|
||||
normalize_capabilities,
|
||||
resolve_agent_code,
|
||||
resolve_conversation_mode,
|
||||
resolve_effective_role,
|
||||
resolve_capabilities,
|
||||
resolve_handler,
|
||||
resolve_handler_for_agent_code,
|
||||
@@ -33,6 +34,7 @@ __all__ = [
|
||||
'normalize_capabilities',
|
||||
'resolve_agent_code',
|
||||
'resolve_conversation_mode',
|
||||
'resolve_effective_role',
|
||||
'resolve_capabilities',
|
||||
'resolve_handler',
|
||||
'resolve_handler_for_agent_code',
|
||||
|
||||
@@ -183,6 +183,20 @@ def validate_agent_payload(
|
||||
if exposure_mode not in valid_exposure_modes:
|
||||
raise ValidationError(f'无效的 exposure_mode: {exposure_mode}')
|
||||
|
||||
existing_exposure = _strip(getattr(agent, 'exposure_mode', None) if agent else '')
|
||||
if agent is not None and existing_exposure and exposure_mode != existing_exposure:
|
||||
raise ValidationError(
|
||||
'应用与内部执行器不可互相转换',
|
||||
code='AGENT.EXPOSURE_ROLE_IMMUTABLE',
|
||||
)
|
||||
# 新建内部执行器统一使用 Dify Workflow;历史内部记录保留原组合以兼容旧数据。
|
||||
if exposure_mode == 'internal' and agent is None:
|
||||
if runtime_provider != 'dify' or dify_app_type != 'workflow':
|
||||
raise ValidationError(
|
||||
'新建内部执行器必须使用 runtime_provider=dify 与 dify_app_type=workflow',
|
||||
code='AGENT.INTERNAL_EXECUTOR_CONFIG_INVALID',
|
||||
)
|
||||
|
||||
dify_app_id = _strip(data.get('dify_app_id')) or (agent.dify_app_id if agent else '')
|
||||
if runtime_provider in dify_required_providers and not dify_app_id:
|
||||
raise ValidationError('runtime_provider 含 dify 时 dify_app_id 必填')
|
||||
|
||||
@@ -35,7 +35,6 @@ platform:
|
||||
dify_required_providers:
|
||||
- dify
|
||||
- hybrid
|
||||
|
||||
agent_types:
|
||||
generic:
|
||||
label: 通用问答 / 知识库
|
||||
@@ -93,6 +92,7 @@ agent_types:
|
||||
allowed_runtime_providers: [dify]
|
||||
allowed_dify_app_types: [workflow]
|
||||
allowed_exposure_modes: [internal]
|
||||
allowed_effective_roles: [internal_executor]
|
||||
file_check:
|
||||
label: 文件检核
|
||||
conversation_mode_default: task_chat
|
||||
|
||||
@@ -152,6 +152,23 @@ def resolve_conversation_mode(agent) -> str:
|
||||
return _read_string_column(agent, 'conversation_mode', default=_COLUMN_DEFAULTS['conversation_mode'])
|
||||
|
||||
|
||||
def resolve_effective_role(agent) -> str:
|
||||
"""
|
||||
解析 Agent 的运行时角色,不新增数据库字段。
|
||||
|
||||
核心逻辑:internal Provider 统一视为内部执行器,其余注册项继续视为用户入口;
|
||||
历史 conversation_mode 保留用于兼容,但内部执行器运行时不参与聊天呈现。
|
||||
|
||||
Args:
|
||||
agent: Agent ORM 或具备 exposure_mode 属性的代理对象。
|
||||
|
||||
Returns:
|
||||
user_agent 或 internal_executor。
|
||||
"""
|
||||
exposure_mode = _read_string_column(agent, 'exposure_mode', default='workspace')
|
||||
return 'internal_executor' if exposure_mode == 'internal' else 'user_agent'
|
||||
|
||||
|
||||
def resolve_capabilities(agent) -> dict[str, bool]:
|
||||
"""
|
||||
解析 Agent 平台能力声明。
|
||||
|
||||
@@ -15,6 +15,7 @@ from app.services.agent_registry.resolver import (
|
||||
resolve_agent_code,
|
||||
resolve_capabilities,
|
||||
resolve_conversation_mode,
|
||||
resolve_effective_role,
|
||||
resolve_progress_contract,
|
||||
resolve_runtime_provider,
|
||||
)
|
||||
@@ -48,6 +49,7 @@ def serialize_registry_fields(agent: Agent | Any) -> dict[str, Any]:
|
||||
'agent_code': resolve_agent_code(agent),
|
||||
'runtime_provider': resolve_runtime_provider(agent),
|
||||
'conversation_mode': resolve_conversation_mode(agent),
|
||||
'effective_role': resolve_effective_role(agent),
|
||||
'dify_app_type': getattr(agent, 'dify_app_type', None) or 'chatflow',
|
||||
'exposure_mode': getattr(agent, 'exposure_mode', None) or 'workspace',
|
||||
'iframe_url': getattr(agent, 'iframe_url', None),
|
||||
|
||||
Reference in new issue
Block a user