Download app/models/semantic_cache.py from abcd118q/Nexus: direct link, hf CLI and curl.
- Browser
- Download file 965 Bytes
-
https://huggingface.co/spaces/abcd118q/Nexus/resolve/main/app/models/semantic_cache.py
- Command line
-
hf download hf://spaces/abcd118q/Nexus/app/models/semantic_cache.py
-
curl -L -o semantic_cache.py https://huggingface.co/spaces/abcd118q/Nexus/resolve/main/app/models/semantic_cache.py
965 Bytes
| from sqlalchemy import text, Float, Index, Integer, Text, func | |
| from sqlalchemy.orm import Mapped, mapped_column | |
| from app.models.base import Base | |
| class SemanticCache(Base): | |
| __tablename__ = "semantic_cache" | |
| cache_key: Mapped[str] = mapped_column(Text, primary_key=True) | |
| model: Mapped[str] = mapped_column(Text, nullable=False, default="") | |
| query_text: Mapped[str] = mapped_column(Text, nullable=False, default="") | |
| response: Mapped[str] = mapped_column(Text, nullable=False) | |
| embedding: Mapped[str] = mapped_column(Text, nullable=False, default="[]") | |
| created_at: Mapped[float] = mapped_column( | |
| Float, server_default=func.extract("epoch", func.now()) | |
| ) | |
| expires_at: Mapped[float] = mapped_column(Float, nullable=False) | |
| hit_count: Mapped[int] = mapped_column(Integer, default=0) | |
| __table_args__ = ( | |
| Index("idx_semantic_cache_expires", "expires_at"), | |
| Index("idx_semantic_cache_model", "model"), | |
| ) | |