Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
add index
Carlo78a524d11d2e
diff --git a/memgpt/agent_store/db.py b/memgpt/agent_store/db.pyindex 9ec2cbf2d..75f3b6d39 100644--- a/memgpt/agent_store/db.py+++ b/memgpt/agent_store/db.py@@ -164,7 +164,8 @@ def get_db_model(# Add a datetime column, with default value as the current timecreated_at = Column(DateTime(timezone=True))- Index('passage_idx_user', user_id, agent_id,doc_id),+ Index("passage_idx_user", user_id, agent_id, doc_id),+def __repr__(self):return f"<Passage(passage_id='{self.id}', text='{self.text}', embedding='{self.embedding})>"@@ -230,7 +231,8 @@ def get_db_model(# Add a datetime column, with default value as the current timecreated_at = Column(DateTime(timezone=True))- Index('message_idx_user', user_id, agent_id),+ Index("message_idx_user", user_id, agent_id),+def __repr__(self):return f"<Message(message_id='{self.id}', text='{self.text}', embedding='{self.embedding})>"diff --git a/memgpt/metadata.py b/memgpt/metadata.pyindex d19f6606e..2f37fae00 100644--- a/memgpt/metadata.py+++ b/memgpt/metadata.py@@ -147,8 +147,9 @@ class TokenModel(Base):# extra (optional) metadataname = Column(String)- Index(__tablename__+'_idx_user', user_id),- Index(__tablename__+'_idx_token', token),+ Index(__tablename__ + "_idx_user", user_id),+ Index(__tablename__ + "_idx_token", token),+def __repr__(self) -> str:return f"<Token(id='{self.id}', token='{self.token}', name='{self.name}')>"@@ -192,7 +193,7 @@ class AgentModel(Base):# toolstools = Column(JSON)- Index(__tablename__+'_idx_user', user_id),+ Index(__tablename__ + "_idx_user", user_id),def __repr__(self) -> str:return f"<Agent(id='{self.id}', name='{self.name}')>"@@ -227,7 +228,7 @@ class SourceModel(Base):embedding_dim = Column(BIGINT)embedding_model = Column(String)description = Column(String)- Index(__tablename__+'_idx_user', user_id),+ Index(__tablename__ + "_idx_user", user_id),# TODO: add num passages@@ -255,7 +256,7 @@ class AgentSourceMappingModel(Base):user_id = Column(CommonUUID, nullable=False)agent_id = Column(CommonUUID, nullable=False)source_id = Column(CommonUUID, nullable=False)- Index(__tablename__+'_idx_user', user_id, agent_id, source_id),+ Index(__tablename__ + "_idx_user", user_id, agent_id, source_id),def __repr__(self) -> str:return f"<AgentSourceMapping(user_id='{self.user_id}', agent_id='{self.agent_id}', source_id='{self.source_id}')>"@@ -268,7 +269,7 @@ class PresetSourceMapping(Base):user_id = Column(CommonUUID, nullable=False)preset_id = Column(CommonUUID, nullable=False)source_id = Column(CommonUUID, nullable=False)- Index(__tablename__+'_idx_user', user_id, preset_id, source_id),+ Index(__tablename__ + "_idx_user", user_id, preset_id, source_id),def __repr__(self) -> str:return f"<PresetSourceMapping(user_id='{self.user_id}', preset_id='{self.preset_id}', source_id='{self.source_id}')>"@@ -306,7 +307,7 @@ class PresetModel(Base):created_at = Column(DateTime(timezone=True), server_default=func.now())functions_schema = Column(JSON)- Index(__tablename__+'_idx_user', user_id),+ Index(__tablename__ + "_idx_user", user_id),def __repr__(self) -> str:return f"<Preset(id='{self.id}', name='{self.name}')>"diff --git a/memgpt/models/pydantic_models.py b/memgpt/models/pydantic_models.pyindex bc491bf0d..5d1f2940a 100644--- a/memgpt/models/pydantic_models.py+++ b/memgpt/models/pydantic_models.py@@ -74,7 +74,7 @@ class ToolModel(SQLModel, table=True):json_schema: Dict = Field(default_factory=dict, sa_column=Column(JSON), description="The JSON schema of the function.")# optional: user_id (user-specific tools)- user_id: Optional[uuid.UUID] = Field(None, description="The unique identifier of the user associated with the function.",index=True)+ user_id: Optional[uuid.UUID] = Field(None, description="The unique identifier of the user associated with the function.", index=True)# Needed for Column(JSON)class Config:@@ -128,14 +128,14 @@ class HumanModel(SQLModel, table=True):text: str = Field(default=get_human_text(DEFAULT_HUMAN), description="The human text.")name: str = Field(..., description="The name of the human.")id: uuid.UUID = Field(default_factory=uuid.uuid4, description="The unique identifier of the human.", primary_key=True)- user_id: Optional[uuid.UUID] = Field(..., description="The unique identifier of the user associated with the human.",index=True)+ user_id: Optional[uuid.UUID] = Field(..., description="The unique identifier of the user associated with the human.", index=True)class PersonaModel(SQLModel, table=True):text: str = Field(default=get_persona_text(DEFAULT_PERSONA), description="The persona text.")name: str = Field(..., description="The name of the persona.")id: uuid.UUID = Field(default_factory=uuid.uuid4, description="The unique identifier of the persona.", primary_key=True)- user_id: Optional[uuid.UUID] = Field(..., description="The unique identifier of the user associated with the persona.",index=True)+ user_id: Optional[uuid.UUID] = Field(..., description="The unique identifier of the user associated with the persona.", index=True)class SourceModel(SQLModel, table=True):@@ -167,7 +167,7 @@ class JobModel(SQLModel, table=True):status: JobStatus = Field(default=JobStatus.created, description="The status of the job.", sa_column=Column(ChoiceType(JobStatus)))created_at: datetime = Field(default_factory=get_utc_time, description="The unix timestamp of when the job was created.")completed_at: Optional[datetime] = Field(None, description="The unix timestamp of when the job was completed.")- user_id: uuid.UUID = Field(..., description="The unique identifier of the user associated with the job.",index=True)+ user_id: uuid.UUID = Field(..., description="The unique identifier of the user associated with the job.", index=True)metadata_: Optional[dict] = Field({}, sa_column=Column(JSON), description="The metadata of the job.")