Repository: mem0ai/mem0
File: embedchain/embedchain.py (Python)

Code before:
        Set the name of the collection. A collection is an isolated space for vectors.

        Using `app.db.set_collection_name` method is preferred to this.

        :param name: Name of the collection.
        :type name: str
        """
        self.db.set_collection_name(name)
        # Create the collection if it does not exist
        self.db._get_or_create_collection(name)
        # TODO: Check whether it is necessary to assign to the `self.collection` attribute,
        # since the main purpose is the creation.

    def reset(self):
        """
        Resets the database. Deletes all embeddings irreversibly.
        `App` does not have to be reinitialized after using this method.
        """
        self.db.reset()
        self.cursor.execute("DELETE FROM data_sources WHERE pipeline_id = ?", (self.config.id,))
        self.connection.commit()
        self.delete_all_chat_history(app_id=self.config.id)
        # Send anonymous telemetry
        self.telemetry.capture(event_name="reset", properties=self._telemetry_props)

    def get_history(self, num_rounds: int = 10, display_format: bool = True, session_id: Optional[str] = None):
        session_id = session_id or "default"
        history = self.llm.memory.get(
            app_id=self.config.id, session_id=session_id, num_rounds=num_rounds, display_format=display_format
        )
        return history

    def delete_session_chat_history(self, session_id: str = "default"):
        self.llm.memory.delete(app_id=self.config.id, session_id=session_id)
        self.llm.update_history(app_id=self.config.id)

    def delete_all_chat_history(self, app_id: str):
        self.llm.memory.delete(app_id=app_id)
        self.llm.update_history(app_id=app_id)


Review comment (suggestion):
```suggestion
    def get_history(self, num_rounds: int = 10, display_format: bool = True, session_id: Optional[str] = "default"):
```

Code after:
        Set the name of the collection. A collection is an isolated space for vectors.

        Using `app.db.set_collection_name` method is preferred to this.

        :param name: Name of the collection.
        :type name: str
        """
        self.db.set_collection_name(name)
        # Create the collection if it does not exist
        self.db._get_or_create_collection(name)
        # TODO: Check whether it is necessary to assign to the `self.collection` attribute,
        # since the main purpose is the creation.

    def reset(self):
        """
        Resets the database. Deletes all embeddings irreversibly.
        `App` does not have to be reinitialized after using this method.
        """
        self.db.reset()
        self.cursor.execute("DELETE FROM data_sources WHERE pipeline_id = ?", (self.config.id,))
        self.connection.commit()
        self.delete_all_chat_history(app_id=self.config.id)
        # Send anonymous telemetry
        self.telemetry.capture(event_name="reset", properties=self._telemetry_props)

    def get_history(self, num_rounds: int = 10, display_format: bool = True, session_id: Optional[str] = "default"):
        history = self.llm.memory.get(
            app_id=self.config.id, session_id=session_id, num_rounds=num_rounds, display_format=display_format
        )
        return history

    def delete_session_chat_history(self, session_id: str = "default"):
        self.llm.memory.delete(app_id=self.config.id, session_id=session_id)
        self.llm.update_history(app_id=self.config.id)

    def delete_all_chat_history(self, app_id: str):
        self.llm.memory.delete(app_id=app_id)
        self.llm.update_history(app_id=app_id)