fix(chat): 智能体支持配置分级显示

This commit is contained in:
sophie committed 2026-06-25 17:37:48 +08:00
1 parent a451951e7a
commit 70d7435b5f
27 files changed
+645 -76

No files matched your search

+5 -10
View File
@@ -12,6 +12,7 @@ from app import db
from app.core.auth.jwt import get_current_user
from app.core.errors import UnauthorizedError
from app.models import Agent, User, AgentGuide
from app.services.agent_category import serialize_agent_list_item, sort_agent_rows
from app.services.minio_service import minio_service
# 定义 Blueprint,将在应用工厂中注册为 /api/agents
@@ -19,13 +20,7 @@ agents_bp = Blueprint('agents', __name__)
def _serialize_agent_row(row) -> dict:
return {
'id': row.id,
'name': row.name,
'description': row.description,
'icon_url': row.icon_url,
'dify_app_type': (row.extra_config or {}).get('dify_app_type') if hasattr(row, 'extra_config') else None,
}
return serialize_agent_list_item(row)
@agents_bp.route('', methods=['GET'])
@@ -61,8 +56,8 @@ def list_user_agents():
if a.is_active
]
# 序列化为前端所需字段
return jsonify([_serialize_agent_row(row) for row in agent_rows])
# [STEP 1] 按 extra_config 分类字段排序后序列化
return jsonify([_serialize_agent_row(row) for row in sort_agent_rows(agent_rows)])
@agents_bp.route('/<int:agent_id>/guides', methods=['GET'])
def list_agent_guides(agent_id):
@@ -112,7 +107,7 @@ def list_public_agents():
.order_by(Agent.id.asc())
.all()
)
return jsonify([_serialize_agent_row(row) for row in agent_rows])
return jsonify([_serialize_agent_row(row) for row in sort_agent_rows(agent_rows)])
# 为了兼容本地无MinIO的环境,暴露一个静态文件读取接口
@agents_bp.route('/guides/files/<path:filename>', methods=['GET'])