Spaces:
Paused

miracle / models /nexus_interaction.py
dushyantsingh0
backend stabilization
6ba1c48
Raw History Blame Contribute Delete
1.64 kB
from sqlalchemy import Column, String, ForeignKey, Text
from sqlalchemy.dialects.postgresql import UUID, JSONB
from core.database import Base
from models.base import PrimaryKeyMixin, TimestampMixin
class NexusInteraction(Base, PrimaryKeyMixin, TimestampMixin):
"""
Dedicated forensic audit table for the Master Nexus Agent.
Isolates Master Agent activity from general system logs.
"""
__tablename__ = "nexus_interactions"
workspace_id = Column(UUID(as_uuid=True), ForeignKey("workspaces.id"), nullable=False, index=True)
user_id = Column(UUID(as_uuid=True), ForeignKey("users.id"), nullable=False, index=True)
# The conversational session/thread
thread_id = Column(UUID(as_uuid=True), ForeignKey("nexus_threads.id"), nullable=True, index=True)
# Optional ticket connection
ticket_id = Column(UUID(as_uuid=True), ForeignKey("tickets.id"), nullable=True, index=True)
input_query = Column(Text, nullable=False)
ai_answer = Column(Text, nullable=False)
# Trace of which tools were identified or called
tool_trace = Column(JSONB, nullable=True, default=[])
# Extraction parameters (e.g. target_user_id from router)
extracted_params = Column(JSONB, nullable=True, default={})
# Distilled summary of the thread interaction
thread_summary = Column(Text, nullable=True)
status = Column(String(50), nullable=True, default="success")
metadata_json = Column(JSONB, nullable=True, default={})
# Composite index for workspace forensics
# ( SQLAlchemy handled via Index object if complex, but single indices cover these )