doc-forge-reds/backend/app/models/generation_point.py

25 lines
1.0 KiB
Python

import uuid
from sqlalchemy import Integer, String, Text, ForeignKey
from sqlalchemy.dialects.postgresql import UUID, JSONB
from sqlalchemy.orm import Mapped, mapped_column, relationship
from app.core.database import Base
from app.models.base import TimestampMixin, UUIDMixin
class GenerationPoint(Base, UUIDMixin, TimestampMixin):
__tablename__ = "generation_points"
template_id: Mapped[uuid.UUID] = mapped_column(
UUID(as_uuid=True), ForeignKey("templates.id", ondelete="CASCADE"), nullable=False, index=True
)
position: Mapped[dict] = mapped_column(JSONB, nullable=False)
prompt: Mapped[str] = mapped_column(Text, nullable=False)
model_id: Mapped[uuid.UUID | None] = mapped_column(
UUID(as_uuid=True), ForeignKey("models.id", ondelete="SET NULL"), nullable=True
)
ref_file_path: Mapped[str | None] = mapped_column(String(500), nullable=True)
order: Mapped[int] = mapped_column(Integer, default=0, nullable=False)
template = relationship("Template")
model = relationship("AIModel")