2026-09-09 21:55:37 +08:00
|
|
|
from datetime import datetime
|
|
|
|
|
|
2026-09-10 09:23:22 +08:00
|
|
|
from sqlalchemy import BigInteger, DateTime, Integer, String, text
|
2026-09-09 21:55:37 +08:00
|
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
|
|
|
|
|
|
from app.model.base import Base
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ConversationSession(Base):
|
|
|
|
|
__tablename__ = "svc_conversation_session"
|
2026-09-10 09:23:22 +08:00
|
|
|
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
|
2026-09-09 21:55:37 +08:00
|
|
|
session_id: Mapped[str] = mapped_column(String(64), unique=True)
|
2026-09-10 09:23:22 +08:00
|
|
|
user_id: Mapped[int] = mapped_column(BigInteger)
|
2026-09-09 21:55:37 +08:00
|
|
|
portal: Mapped[str] = mapped_column(String(32))
|
|
|
|
|
agent_type: Mapped[str | None] = mapped_column(String(32))
|
|
|
|
|
status: Mapped[str] = mapped_column(String(16), default="active")
|
2026-09-10 09:23:22 +08:00
|
|
|
clarification_round: Mapped[int] = mapped_column(Integer, default=0)
|
|
|
|
|
message_count: Mapped[int] = mapped_column(Integer, default=0)
|
2026-09-09 21:55:37 +08:00
|
|
|
last_intent: Mapped[str | None] = mapped_column(String(32))
|
|
|
|
|
config_version: Mapped[str | None] = mapped_column(String(64))
|
|
|
|
|
started_at: Mapped[datetime] = mapped_column(
|
2026-09-10 09:23:22 +08:00
|
|
|
DateTime, server_default=text("CURRENT_TIMESTAMP(6)")
|
2026-09-09 21:55:37 +08:00
|
|
|
)
|
|
|
|
|
last_active_at: Mapped[datetime] = mapped_column(
|
2026-09-10 09:23:22 +08:00
|
|
|
DateTime, server_default=text("CURRENT_TIMESTAMP(6)")
|
2026-09-09 21:55:37 +08:00
|
|
|
)
|
2026-09-10 09:23:22 +08:00
|
|
|
ended_at: Mapped[datetime | None] = mapped_column(DateTime)
|
2026-09-09 21:55:37 +08:00
|
|
|
created_at: Mapped[datetime] = mapped_column(
|
2026-09-10 09:23:22 +08:00
|
|
|
DateTime, server_default=text("CURRENT_TIMESTAMP(6)")
|
2026-09-09 21:55:37 +08:00
|
|
|
)
|
|
|
|
|
updated_at: Mapped[datetime] = mapped_column(
|
2026-09-10 09:23:22 +08:00
|
|
|
DateTime, server_default=text("CURRENT_TIMESTAMP(6)")
|
2026-09-09 21:55:37 +08:00
|
|
|
)
|