feat: add AI学习助手 agent (KG+RAG ideal) and renshenguo feishu bot
- Add AI学习助手 agent creation script with all 39 tools, 3-layer KG+RAG memory - Add renshenguo (人参果) feishu bot integration (app_service + ws_handler) - Register renshenguo WS client in main.py startup - Add RENSHENGUO_APP_ID / RENSHENGUO_APP_SECRET / RENSHENGUO_AGENT_ID config - Reorganize docs from root into docs/ subdirectories - Move startup scripts to scripts/startup/ - Various backend optimizations and tool improvements Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
"""
|
||||
Agent管理API
|
||||
"""
|
||||
from fastapi import APIRouter, Depends, HTTPException, status, Query
|
||||
from fastapi import APIRouter, Depends, HTTPException, status, Query, Response
|
||||
from sqlalchemy.orm import Session
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import List, Optional, Dict, Any
|
||||
@@ -101,6 +101,7 @@ class AgentResponse(BaseModel):
|
||||
|
||||
@router.get("", response_model=List[AgentResponse])
|
||||
async def get_agents(
|
||||
response: Response,
|
||||
skip: int = Query(0, ge=0, description="跳过记录数"),
|
||||
limit: int = Query(100, ge=1, le=100, description="每页记录数"),
|
||||
search: Optional[str] = Query(None, description="搜索关键词(按名称或描述)"),
|
||||
@@ -152,9 +153,12 @@ async def get_agents(
|
||||
if status:
|
||||
query = query.filter(Agent.status == status)
|
||||
|
||||
# 先获取总数(不带分页)
|
||||
total_count = query.count()
|
||||
|
||||
# 排序和分页
|
||||
agents = query.order_by(Agent.created_at.desc()).offset(skip).limit(limit).all()
|
||||
|
||||
|
||||
# 转换为响应格式,确保user_id和日期时间字段正确处理
|
||||
result = []
|
||||
for agent in agents:
|
||||
@@ -170,7 +174,9 @@ async def get_agents(
|
||||
"created_at": agent.created_at if agent.created_at else datetime.now(),
|
||||
"updated_at": agent.updated_at if agent.updated_at else datetime.now()
|
||||
})
|
||||
|
||||
|
||||
# 通过 X-Total-Count 响应头返回总数,前端借此正确分页
|
||||
response.headers["X-Total-Count"] = str(total_count)
|
||||
return result
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user