File size: 1,494 Bytes
7c6ffa6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | from datetime import datetime
from typing import Any
from sqlalchemy import DateTime, ForeignKey, JSON, String, func
from sqlalchemy.orm import Mapped, mapped_column
from app.core.database import Base
from app.utils.ids import prefixed_id
class Generation(Base):
__tablename__ = "generations"
id: Mapped[str] = mapped_column(
String(40),
primary_key=True,
default=lambda: prefixed_id("gen"),
)
user_id: Mapped[str] = mapped_column(
String(40),
ForeignKey("users.id"),
index=True,
nullable=False,
)
document_id: Mapped[str] = mapped_column(
String(40),
ForeignKey("documents.id"),
index=True,
nullable=False,
)
type: Mapped[str] = mapped_column(String(60), nullable=False)
output_json: Mapped[dict[str, Any]] = mapped_column(JSON, nullable=False)
model_used: Mapped[str] = mapped_column(String(120), nullable=False)
provider_used: Mapped[str | None] = mapped_column(String(120), nullable=True)
generation_time_ms: Mapped[int | None] = mapped_column(nullable=True)
is_mock_output: Mapped[bool | None] = mapped_column(nullable=True)
validation_status: Mapped[str | None] = mapped_column(String(60), nullable=True)
validation_error: Mapped[str | None] = mapped_column(String(1000), nullable=True)
created_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True),
server_default=func.now(),
nullable=False,
)
|