Spaces:
Paused
Paused
Download models/nexus_semantic_cache.py from 3SCError404/nexus: direct link, hf CLI and curl.
- Browser
- Download file 1.27 kB
-
https://huggingface.co/spaces/3SCError404/nexus/resolve/main/models/nexus_semantic_cache.py
- Command line
-
hf download hf://spaces/3SCError404/nexus/models/nexus_semantic_cache.py
-
curl -L -o nexus_semantic_cache.py https://huggingface.co/spaces/3SCError404/nexus/resolve/main/models/nexus_semantic_cache.py
1.27 kB
| from sqlalchemy import Column, Integer, Text, ForeignKey, DateTime, Boolean | |
| from sqlalchemy.dialects.postgresql import UUID | |
| from sqlalchemy.sql import func | |
| from pgvector.sqlalchemy import Vector | |
| from core.database import Base | |
| import uuid | |
| class NexusSemanticCache(Base): | |
| __tablename__ = "nexus_semantic_cache" | |
| id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4) | |
| workspace_id = Column(UUID(as_uuid=True), ForeignKey("workspaces.id", ondelete="CASCADE"), nullable=False, index=True) | |
| user_id = Column(UUID(as_uuid=True), ForeignKey("users.id", ondelete="CASCADE"), nullable=False, index=True) | |
| # --- Persona Bifurcation Columns --- | |
| user_role = Column(Text, nullable=False, index=True, server_default='customer_user') | |
| is_agent = Column(Boolean, nullable=False, index=True, server_default='false') | |
| # ----------------------------------- | |
| query_text = Column(Text, nullable=False) | |
| query_embedding = Column(Vector(768), nullable=False) | |
| response_text = Column(Text, nullable=False) | |
| created_at = Column(DateTime(timezone=True), server_default=func.now()) | |
| last_hit_at = Column(DateTime(timezone=True), server_default=func.now(), onupdate=func.now()) | |
| hit_count = Column(Integer, default=0) | |