DocDoeAI / app /models /generation_cache.py
asnannp's picture
Deploy backend cd4237ff: support routes + rate limit + exam_date nullable + upload 413 fix
7c6ffa6
Raw
History Blame Contribute Delete
1.21 kB
from __future__ import annotations
from datetime import datetime
from typing import Any
from sqlalchemy import DateTime, JSON, String, Text, func
from sqlalchemy.orm import Mapped, mapped_column
from app.core.database import Base
class GenerationCache(Base):
__tablename__ = "generation_cache"
cache_key: Mapped[str] = mapped_column(String(160), primary_key=True)
task_type: Mapped[str] = mapped_column(String(80), index=True, nullable=False)
provider: Mapped[str] = mapped_column(String(80), index=True, nullable=False)
input_hash: Mapped[str] = mapped_column(String(128), index=True, nullable=False)
output_json: Mapped[dict[str, Any] | None] = mapped_column(JSON, nullable=True)
output_text: Mapped[str | None] = mapped_column(Text, nullable=True)
output_file_path: Mapped[str | None] = mapped_column(String(1000), nullable=True)
metadata_json: Mapped[dict[str, Any]] = mapped_column(JSON, default=dict, nullable=False)
created_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True),
server_default=func.now(),
nullable=False,
)
expires_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True)