zhangqian
2024-11-21 ce9fb375be9a551b4cdc5cb78a759fbcea1eac22
app/api/agent.py
@@ -60,7 +60,7 @@
    elif agent.agent_type == AgentType.BASIC:
        offset = (page - 1) * limit
        records = db.query(SessionModel).filter(SessionModel.agent_id == agent_id).offset(offset).limit(limit).all()
        records = db.query(SessionModel).filter(SessionModel.agent_id == agent_id, SessionModel.tenant_id==current_user.id).offset(offset).limit(limit).all()
        result = [item.to_dict() for item in records]
        return ResponseList(code=200, msg="", data=result)
@@ -105,7 +105,7 @@
                return JSONResponse(status_code=200, content={"code": 400, "message": "Invalid result structure"})
        except Exception as e:
            raise HTTPException(status_code=500, detail=str(e))
    if agent.agent_type == AgentType.BISHENG:
    elif agent.agent_type == AgentType.BISHENG:
        bisheng_service = BishengService(base_url=settings.sgb_base_url)
        try:
            token = get_bisheng_token(db, current_user.id)
@@ -139,6 +139,9 @@
            return JSONResponse(status_code=200, content={"code": 200, "data": combined_logs})
        except Exception as e:
            raise HTTPException(status_code=500, detail=str(e))
    elif agent.agent_type == AgentType.BASIC:
        session = db.query(SessionModel).filter(SessionModel.id == conversation_id).first()
        return JSONResponse(status_code=200, content={"code": 200, "data": session.log_to_json() if session else {}})
    else:
        return JSONResponse(status_code=200, content={"code": 200, "log": "Unsupported agent type"})