feat(chat): 应用目录只配置成聚合应用
This commit is contained in:
1 parent
5bef77f86c
commit
dab04d4c3e
28 files changed
+797
-138
No files matched your search
@@ -44,6 +44,7 @@ MIGRATED_EXTRA_REGISTRY_KEYS = frozenset({
|
||||
'suggested_questions',
|
||||
'capabilities',
|
||||
'tool_run_progress',
|
||||
'is_aggregate',
|
||||
})
|
||||
|
||||
|
||||
@@ -68,6 +69,13 @@ def _parse_is_active(raw: Any, *, default: bool) -> bool:
|
||||
return coerce_manifest_boolean(raw, context='is_active')
|
||||
|
||||
|
||||
def _parse_is_aggregate(raw: Any, *, default: bool) -> bool:
|
||||
"""Admin is_aggregate 布尔归一化;只有为 true 时才保留目录成员配置。"""
|
||||
if raw is None:
|
||||
return default
|
||||
return coerce_manifest_boolean(raw, context='is_aggregate')
|
||||
|
||||
|
||||
def _parse_bound_schedule_task_id(raw: Any) -> int | None:
|
||||
if raw is None or raw == '':
|
||||
return None
|
||||
@@ -231,12 +239,19 @@ def validate_agent_payload(
|
||||
if 'is_active' in data
|
||||
else is_active_default
|
||||
)
|
||||
is_aggregate_default = bool(getattr(agent, 'is_aggregate', False)) if agent else False
|
||||
is_aggregate = (
|
||||
_parse_is_aggregate(data.get('is_aggregate'), default=is_aggregate_default)
|
||||
if 'is_aggregate' in data
|
||||
else is_aggregate_default
|
||||
)
|
||||
|
||||
return {
|
||||
'name': _strip(data.get('name')),
|
||||
'description': data.get('description'),
|
||||
'icon_url': data.get('icon_url'),
|
||||
'is_active': is_active,
|
||||
'is_aggregate': is_aggregate,
|
||||
'dify_app_id': dify_app_id or None,
|
||||
'dify_api_key': _strip(data.get('dify_api_key')) or None,
|
||||
'api_base_url': _strip(data.get('api_base_url')) or None,
|
||||
@@ -269,7 +284,7 @@ def apply_agent_payload(agent: Agent, normalized: dict[str, Any]) -> None:
|
||||
normalized: validate_agent_payload 的返回值。
|
||||
"""
|
||||
column_fields = (
|
||||
'name', 'description', 'icon_url', 'is_active', 'dify_app_id', 'api_base_url', 'type',
|
||||
'name', 'description', 'icon_url', 'is_active', 'is_aggregate', 'dify_app_id', 'api_base_url', 'type',
|
||||
'agent_code', 'runtime_provider', 'conversation_mode', 'dify_app_type', 'iframe_url',
|
||||
'category', 'sub_category', 'sort_order', 'welcome_message', 'suggested_questions_style',
|
||||
'suggested_questions', 'capabilities', 'file_upload_policy', 'bound_schedule_task_id',
|
||||
|
||||
@@ -53,6 +53,7 @@ def serialize_registry_fields(agent: Agent | Any) -> dict[str, Any]:
|
||||
'category': getattr(agent, 'category', None) or None,
|
||||
'sub_category': getattr(agent, 'sub_category', None) or None,
|
||||
'sort_order': int(getattr(agent, 'sort_order', 0) or 0),
|
||||
'is_aggregate': bool(getattr(agent, 'is_aggregate', False)),
|
||||
'welcome_message': getattr(agent, 'welcome_message', None),
|
||||
'suggested_questions_style': getattr(agent, 'suggested_questions_style', None) or 'plain',
|
||||
'suggested_questions': getattr(agent, 'suggested_questions', None) or [],
|
||||
@@ -69,6 +70,7 @@ def serialize_registry_fields(agent: Agent | Any) -> dict[str, Any]:
|
||||
def serialize_agent_for_admin(agent: Agent) -> dict[str, Any]:
|
||||
"""Agent ORM → 管理端列表/详情 JSON(含 dify_api_key 供编辑表单密码框回填)。"""
|
||||
registry = serialize_registry_fields(agent)
|
||||
from app.services.agent_directory import serialize_directory_members
|
||||
return {
|
||||
'id': agent.id,
|
||||
'name': agent.name,
|
||||
@@ -81,6 +83,7 @@ def serialize_agent_for_admin(agent: Agent) -> dict[str, Any]:
|
||||
'dify_api_key_masked': mask_dify_api_key(agent.dify_api_key),
|
||||
'api_base_url': agent.api_base_url,
|
||||
'extra_config': agent.extra_config if isinstance(agent.extra_config, dict) else {},
|
||||
'directory_members': serialize_directory_members(agent.id) if bool(getattr(agent, 'is_aggregate', False)) else [],
|
||||
**registry,
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user