zhangxiao
2024-10-23 db8c55d218c4952aa010cb1a4c5be623a1e4efe1
app/api/agent.py
@@ -1,3 +1,5 @@
import uuid
from fastapi import Depends, APIRouter, Query, HTTPException
from pydantic import BaseModel
from sqlalchemy.orm import Session
@@ -12,16 +14,6 @@
from app.service.token import get_ragflow_token, get_bisheng_token
router = APIRouter()
# Pydantic 模型用于响应
class AgentResponse(BaseModel):
    id: str
    name: str
    agent_type: AgentType
    class Config:
        orm_mode = True
@router.get("/list", response_model=ResponseList)
@@ -57,3 +49,12 @@
    else:
        return ResponseList(code=200, msg="Unsupported agent type")
@router.get("/get-chat-id/{agent_id}", response_model=Response)
async def get_chat_id(agent_id: str, db: Session = Depends(get_db)):
    agent = db.query(AgentModel).filter(AgentModel.id == agent_id).first()
    if not agent:
        return Response(code=404, msg="Agent not found")
    return Response(code=200, msg="", data={"chat_id": uuid.uuid4().hex})