def delete_message(self, key: str, idx: int) -> Optional[ChatMessage]:
        """
        Delete specific message for a key.

        Args:
            key: Key to delete message for
            idx: Index of message to delete

        """
        # Find the message to delete
        doc = self._collection.find_one({"session_id": key, "index": idx})
        if doc is None:
            return None

        # Delete the message
        self._collection.delete_one({"session_id": key, "index": idx})

        # Reindex remaining messages
        self._collection.update_many(
            {"session_id": key, "index": {"$gt": idx}}, {"$inc": {"index": -1}}
        )

        return _dict_to_message(doc["message"])

        Delete specific message for a key.

        Args:
            key: Key to delete message for
            idx: Index of message to delete

        
llama-index-integrations/storage/chat_store/llama-index-storage-chat-store-mongo/llama_index/storage/chat_store/mongo/base.py