主要修改: 1. 服务端新增 Thread 模型,用于存储对话列表信息,但不保存实际的历史记录 2. langgraph 配置了 InMemorySaver,添加 thread_id 参数,消息对话保存在内存中(服务重启后丢失) 3. 添加获取历史记录的 API 接口,从内存中获取 4. 添加 Graph 的单例模式,get_runnable_agent 导致的重复创建 Agent 实例的情况。 5. 优化 Agent 管理页面,更容易配置,更容易调试 6. 添加独立页面的侧边栏。
21 lines
913 B
Python
21 lines
913 B
Python
from sqlalchemy import Column, String, Integer, DateTime, Text, ForeignKey
|
|
from sqlalchemy.sql import func
|
|
from sqlalchemy.orm import relationship
|
|
from sqlalchemy.dialects.mysql import JSON
|
|
|
|
from server.models import Base
|
|
|
|
|
|
class Thread(Base):
|
|
"""对话线程表"""
|
|
__tablename__ = "thread"
|
|
|
|
id = Column(String(64), primary_key=True, index=True, comment="线程ID")
|
|
user_id = Column(String(64), index=True, nullable=False, comment="用户ID")
|
|
agent_id = Column(String(64), index=True, nullable=False, comment="智能体ID")
|
|
title = Column(String(255), nullable=True, comment="标题")
|
|
create_at = Column(DateTime, default=func.now(), comment="创建时间")
|
|
update_at = Column(DateTime, default=func.now(), onupdate=func.now(), comment="更新时间")
|
|
|
|
description = Column(String(255), nullable=True, comment="描述")
|
|
status = Column(Integer, default=1, comment="状态") |