Spaces:
Paused
Paused
Download models/nexus_memory.py from 3SCError404/miracle: direct link, hf CLI and curl.
- Browser
- Download file 1.49 kB
-
https://huggingface.co/spaces/3SCError404/miracle/resolve/main/models/nexus_memory.py
- Command line
-
hf download hf://spaces/3SCError404/miracle/models/nexus_memory.py
-
curl -L -o nexus_memory.py https://huggingface.co/spaces/3SCError404/miracle/resolve/main/models/nexus_memory.py
1.49 kB
| from sqlalchemy import Column, String, Text, ForeignKey | |
| from sqlalchemy.dialects.postgresql import UUID | |
| from sqlalchemy.orm import relationship | |
| from pgvector.sqlalchemy import Vector | |
| from core.database import Base | |
| from core.config import get_settings | |
| from models.base import PrimaryKeyMixin, TimestampMixin | |
| import enum | |
| settings = get_settings() | |
| class MemoryType(str, enum.Enum): | |
| FACT = "fact" | |
| INTERACTION = "interaction" | |
| class NexusMemory(Base, PrimaryKeyMixin, TimestampMixin): | |
| """ | |
| Dedicated semantic memory table for the Master Nexus Agent. | |
| Stores vectorized snapshots of long-term history and crystallized facts. | |
| """ | |
| __tablename__ = "nexus_memories" | |
| workspace_id = Column(UUID(as_uuid=True), ForeignKey("workspaces.id"), nullable=False, index=True) | |
| user_id = Column(UUID(as_uuid=True), ForeignKey("users.id"), nullable=False, index=True) | |
| thread_id = Column(UUID(as_uuid=True), nullable=True, index=True) | |
| # Optional link to original interaction | |
| interaction_id = Column(UUID(as_uuid=True), ForeignKey("nexus_interactions.id"), nullable=True) | |
| content = Column(Text, nullable=False) | |
| memory_type = Column(String(50), default=MemoryType.INTERACTION, index=True) | |
| # Semantic vector for RAG retrieval | |
| embedding = Column(Vector(settings.AI_TEXT_EMBEDDING_DIM), nullable=True) | |
| # Relationships | |
| workspace = relationship("Workspace") | |
| user = relationship("User") | |
| interaction = relationship("NexusInteraction") | |