From 4eb8d55ec0a664678895132256c97cc63a80be2b Mon Sep 17 00:00:00 2001
From: zhaoqingang <zhaoqg0118@163.com>
Date: 星期四, 21 十一月 2024 19:56:49 +0800
Subject: [PATCH] 写入记录问题

---
 app/api/agent.py |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/app/api/agent.py b/app/api/agent.py
index 3178144..fe6e6c0 100644
--- a/app/api/agent.py
+++ b/app/api/agent.py
@@ -10,6 +10,7 @@
 from app.config.config import settings
 from app.models.agent_model import AgentType, AgentModel
 from app.models.base_model import get_db
+from app.models.session_model import SessionModel
 from app.models.user_model import UserModel
 from app.service.bisheng import BishengService
 from app.service.dialog import get_session_history
@@ -57,6 +58,12 @@
             raise HTTPException(status_code=500, detail=str(e))
         return ResponseList(code=200, msg="", data=result)
 
+    elif agent.agent_type == AgentType.BASIC:
+        offset = (page - 1) * limit
+        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)
+
     else:
         return ResponseList(code=200, msg="Unsupported agent type")
 
@@ -98,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)
@@ -132,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"})
 

--
Gitblit v1.8.0