From cbb634f9c133c726a00faf8199ba8954e18d4b05 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期二, 15 十月 2024 14:33:45 +0800 Subject: [PATCH] 智能体列表增加排序和类型字段 --- app/api/agent.py | 12 ++---------- 1 files changed, 2 insertions(+), 10 deletions(-) diff --git a/app/api/agent.py b/app/api/agent.py index cded0f8..416db71 100644 --- a/app/api/agent.py +++ b/app/api/agent.py @@ -26,15 +26,8 @@ @router.get("/list", response_model=ResponseList) async def agent_list(db: Session = Depends(get_db)): - agents = db.query(AgentModel).all() - result = [ - { - "id": item.id, - "name": item.name, - "agent_type": item.agent_type - } - for item in agents - ] + agents = db.query(AgentModel).order_by(AgentModel.sort.asc()).all() + result = [item.to_dict() for item in agents] return ResponseList(code=200, msg="", data=result) @@ -64,4 +57,3 @@ else: return ResponseList(code=200, msg="Unsupported agent type") - -- Gitblit v1.8.0