Files
JARVIS/backend/app/models/conversation.py
WIN-JHFT4D3SIVT\caoxiaozhu 4972b4e6b1 fix: harden L3 runtime continuity and tool execution
Align the L3 graph, agent service, and sync tool shims on one canonical continuity contract so clarification resumes and persisted snapshots behave consistently. Add targeted regressions and hardening notes covering system-message coalescing, async bridge usage, and continuity rehydration.
2026-04-03 13:14:59 +08:00

28 lines
1.1 KiB
Python

from sqlalchemy import Column, String, Text, Integer, ForeignKey, JSON
from sqlalchemy.orm import relationship
from app.models.base import BaseModel
class Conversation(BaseModel):
__tablename__ = "conversations"
user_id = Column(String(36), ForeignKey("users.id"), nullable=False, index=True)
title = Column(String(500), nullable=True)
message_count = Column(Integer, default=0)
agent_state = Column(JSON, nullable=True)
messages = relationship("Message", back_populates="conversation", cascade="all, delete-orphan")
class Message(BaseModel):
__tablename__ = "messages"
conversation_id = Column(String(36), ForeignKey("conversations.id"), nullable=False, index=True)
role = Column(String(20), nullable=False) # user, assistant, system
content = Column(Text, nullable=False)
model = Column(String(100), nullable=True)
tokens_used = Column(Integer, nullable=True)
attachments = Column(JSON, nullable=True) # 新增: [{file_id, filename, file_type, file_size}]
conversation = relationship("Conversation", back_populates="messages")