46 lines
1.6 KiB
Python
46 lines
1.6 KiB
Python
"""Conductor interaction model for VoIdeaAI.
|
|
|
|
Logs all Дирижёр interactions for self-learning and analytics.
|
|
"""
|
|
|
|
from typing import Optional
|
|
|
|
from sqlalchemy import Float, ForeignKey, Integer, String, Text
|
|
from sqlalchemy.dialects.postgresql import UUID
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from app.core.base import SQLBase, TimestampMixin, UUIDMixin
|
|
|
|
|
|
class ConductorInteraction(SQLBase, UUIDMixin, TimestampMixin):
|
|
__tablename__ = "conductor_interactions"
|
|
|
|
user_id: Mapped[Optional[UUID]] = mapped_column(
|
|
UUID(as_uuid=True),
|
|
ForeignKey("users.id", ondelete="SET NULL"),
|
|
nullable=True,
|
|
index=True,
|
|
)
|
|
session_id: Mapped[Optional[UUID]] = mapped_column(
|
|
UUID(as_uuid=True),
|
|
ForeignKey("sessions.id", ondelete="SET NULL"),
|
|
nullable=True,
|
|
index=True,
|
|
)
|
|
input_text: Mapped[str] = mapped_column(Text, nullable=False)
|
|
detected_intent: Mapped[str] = mapped_column(String(100), nullable=False)
|
|
selected_agent: Mapped[str] = mapped_column(String(100), nullable=False)
|
|
response_text: Mapped[str] = mapped_column(Text, nullable=False)
|
|
user_rating: Mapped[Optional[int]] = mapped_column(
|
|
Integer, nullable=True
|
|
)
|
|
confidence_score: Mapped[int] = mapped_column(
|
|
Integer, default=80, nullable=False
|
|
)
|
|
verification_status: Mapped[str] = mapped_column(
|
|
String(20), default="verified", nullable=False
|
|
)
|
|
was_auto_routed: Mapped[bool] = mapped_column(default=True)
|
|
processing_time_ms: Mapped[float] = mapped_column(Float, default=0.0)
|
|
context: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
|