- 移除 Agent 的 exposure_mode 与 internal_executor 相关逻辑,清理关联的过滤、序列化代码 - 删除废弃的 AgentRuntimeBinding 模型及其依赖 - 新增订单抽取上传批次、请求快照等数据库迁移与业务逻辑 - 修复附件完整性检测、订单抽取状态映射问题 - 更新多语言错误文案与前端单元测试配置 - 清理平台配置中不再使用的暴露模式配置
69 lines
2.6 KiB
Python
69 lines
2.6 KiB
Python
"""
|
|
backend/app/services/agent_registry/admin_schema.py
|
|
|
|
用途:组装 Admin Agent Registry 完整 schema(平台枚举 + Catalog + handler_config schema)。
|
|
依赖:catalog_loader、content_profiles。
|
|
逻辑:GET /api/admin/agents/schema 返回本模块 build_agent_registry_schema()。
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
from app.services.agent_registry.catalog_loader import (
|
|
build_agent_type_catalog,
|
|
get_agent_type_default_capabilities,
|
|
get_default_capabilities,
|
|
get_platform_config,
|
|
get_tool_run_progress_defaults,
|
|
list_type_catalog,
|
|
)
|
|
from app.services.agent_registry.content_profiles import list_content_profiles
|
|
|
|
|
|
def build_agent_registry_schema() -> dict[str, Any]:
|
|
"""
|
|
构建 Admin 表单权威 schema。
|
|
|
|
Returns:
|
|
platform、agent_types、handler_config_schemas、content_profiles 预览键。
|
|
"""
|
|
platform = get_platform_config()
|
|
catalog = build_agent_type_catalog()
|
|
handler_config_schemas = {
|
|
code: deepcopy_schema(entry.get('handler_config_schema'))
|
|
for code, entry in catalog.items()
|
|
if isinstance(entry.get('handler_config_schema'), dict)
|
|
}
|
|
agent_types = []
|
|
for item in list_type_catalog():
|
|
code = item.get('agent_code')
|
|
entry = catalog.get(str(code or '')) or {}
|
|
agent_types.append({
|
|
**item,
|
|
'required_fields': list(entry.get('required_fields') or []),
|
|
'default_capabilities': get_agent_type_default_capabilities(str(code or '')),
|
|
'forced_capabilities': dict(entry.get('forced_capabilities') or {}),
|
|
'progress_contract': deepcopy_schema(entry.get('progress_contract')),
|
|
'default_intent_routes': list(entry.get('default_intent_routes') or []),
|
|
})
|
|
|
|
return {
|
|
'platform': {
|
|
'runtime_providers': list(platform.get('runtime_providers') or []),
|
|
'conversation_modes': list(platform.get('conversation_modes') or []),
|
|
'dify_app_types': list(platform.get('dify_app_types') or []),
|
|
'suggested_questions_styles': list(platform.get('suggested_questions_styles') or []),
|
|
'default_capabilities': get_default_capabilities(),
|
|
'tool_run_progress_defaults': get_tool_run_progress_defaults(),
|
|
},
|
|
'agent_types': agent_types,
|
|
'handler_config_schemas': handler_config_schemas,
|
|
'content_profile_keys': [item['key'] for item in list_content_profiles()],
|
|
}
|
|
|
|
|
|
def deepcopy_schema(value: Any) -> Any:
|
|
import copy
|
|
return copy.deepcopy(value) if value is not None else {}
|