Add possibility to create a new Vector memory and store text data points using openai embeddings.
29 lines
1.2 KiB
Python
29 lines
1.2 KiB
Python
""" This module contains the MemoryModel class, which is a SQLAlchemy model for the memory table in the relational database. """
|
|
from datetime import datetime
|
|
from sqlalchemy import Column, String, DateTime, ForeignKey, UUID
|
|
from sqlalchemy.orm import relationship
|
|
from ..database import Base
|
|
|
|
|
|
class MemoryModel(Base):
|
|
""" Memory model"""
|
|
__tablename__ = "memories"
|
|
|
|
id = Column(UUID, primary_key=True)
|
|
user_id = Column(String, ForeignKey("users.id"), index=True)
|
|
operation_id = Column(String, ForeignKey("operations.id"), index=True)
|
|
memory_name = Column(String, nullable=True)
|
|
memory_category = Column(String, nullable=True)
|
|
created_at = Column(DateTime, default=datetime.utcnow)
|
|
updated_at = Column(DateTime, onupdate=datetime.utcnow)
|
|
methods_list = Column(String, nullable=True)
|
|
attributes_list = Column(String, nullable=True)
|
|
|
|
user = relationship("User", back_populates="memories")
|
|
operation = relationship("Operation", back_populates="memories")
|
|
metadatas = relationship(
|
|
"MetaDatas", back_populates="memory", cascade="all, delete-orphan"
|
|
)
|
|
|
|
def __repr__(self):
|
|
return f"<Memory(id={self.id}, user_id={self.user_id}, created_at={self.created_at}, updated_at={self.updated_at})>"
|