feat(agent): 增强 Agent 配置,新增结构化字段与聊天功能支持
This commit is contained in:
1 parent
ac4262cd75
commit
c8ce77199e
183 files changed
+11690
-2300
No files matched your search
@@ -0,0 +1,64 @@
|
||||
"""
|
||||
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_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 []),
|
||||
'forced_capabilities': dict(entry.get('forced_capabilities') 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 {}
|
||||
Reference in new issue
Block a user