From ae30d9a75407c912649f11c4f44ff15c869a4f98 Mon Sep 17 00:00:00 2001 From: zhaoqingang <zhaoqg0118@163.com> Date: 星期四, 21 十一月 2024 15:42:42 +0800 Subject: [PATCH] 自研agent会话保存和查询 --- app/models/session_model.py | 16 +++++++++++++++- 1 files changed, 15 insertions(+), 1 deletions(-) diff --git a/app/models/session_model.py b/app/models/session_model.py index 44d0b74..11bd33a 100644 --- a/app/models/session_model.py +++ b/app/models/session_model.py @@ -1,7 +1,7 @@ import json from datetime import datetime from enum import IntEnum -from sqlalchemy import Column, String, Enum as SQLAlchemyEnum, Integer, DateTime +from sqlalchemy import Column, String, Enum as SQLAlchemyEnum, Integer, DateTime, JSON from app.models import AgentType, current_time from app.models.base_model import Base @@ -15,6 +15,9 @@ agent_type = Column(SQLAlchemyEnum(AgentType), nullable=False) # 鐩墠鍙瓨basic鐨勶紝ragflow鍜宐isheng鐨勮皟鎺ュ彛鑾峰彇 create_date = Column(DateTime, default=current_time) # 鍒涘缓鏃堕棿锛岄粯璁ゅ�间负褰撳墠鏃跺尯鏃堕棿 update_date = Column(DateTime, default=current_time, onupdate=current_time) # 鏇存柊鏃堕棿锛岄粯璁ゅ�间负褰撳墠鏃跺尯鏃堕棿锛屾洿鏂版椂鑷姩鏇存柊 + tenant_id = Column(Integer) # 鍒涘缓浜� + message = Column(JSON) # 璇存槑 + # to_dict 鏂规硶 def to_dict(self): return { @@ -25,3 +28,14 @@ 'create_date': self.create_date, 'update_date': self.update_date, } + + def log_to_json(self): + return { + 'id': self.id, + 'name': self.name, + 'agent_type': self.agent_type, + 'agent_id': self.agent_id, + 'create_date': self.create_date, + 'update_date': self.update_date, + 'message': self.message + } -- Gitblit v1.8.0