mirror of
https://github.com/countbot-ai/CountBot.git
synced 2026-09-14 20:46:47 +08:00
432f4f6a59
后端: 重构 agent context/loop/subagent/workflow,增强 agent team API、会话级运行时配置、渠道 handler/manager,以及 QQ、飞书、钉钉、企业微信等渠道能力;同步调整 send_media、spawn、workflow_tool、filesystem 等工具模块,移除 image_uploader。 前端: 重构聊天窗口、消息项、会话面板、工具调用卡片和设置中心;新增团队配置、会话配置、工作流面板、预设选择、虚拟滚动、提示框等组件与 composables;更新 agentTeams/store/types、国际化文案、主题样式与 frontend dist 构建产物。
37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
"""消息模型"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from datetime import datetime, timezone
|
|
from typing import TYPE_CHECKING
|
|
|
|
from sqlalchemy import DateTime, ForeignKey, Index, Integer, String, Text
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
|
|
from backend.database import Base
|
|
|
|
if TYPE_CHECKING:
|
|
from backend.models.session import Session
|
|
|
|
|
|
def utc_now():
|
|
"""返回带时区的UTC时间"""
|
|
return datetime.now(timezone.utc)
|
|
|
|
|
|
class Message(Base):
|
|
"""消息表"""
|
|
|
|
__tablename__ = "messages"
|
|
|
|
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
|
session_id: Mapped[str] = mapped_column(String, ForeignKey("sessions.id"), nullable=False)
|
|
role: Mapped[str] = mapped_column(String, nullable=False)
|
|
content: Mapped[str] = mapped_column(Text, nullable=False)
|
|
message_context: Mapped[str | None] = mapped_column(Text, nullable=True)
|
|
created_at: Mapped[datetime] = mapped_column(DateTime, default=utc_now)
|
|
|
|
session: Mapped["Session"] = relationship("Session", back_populates="messages")
|
|
|
|
__table_args__ = (Index("idx_messages_session", "session_id", "created_at"),)
|