async def adelete_last_message(self, key: str) -> Optional[ChatMessage]:
        """Async version of Delete last message for a key."""
        async with self._async_session() as session:
            # First, retrieve the current list of messages
            stmt = (
                select(self._table_class.id, self._table_class.value)
                .where(self._table_class.key == key)
                .order_by(self._table_class.id.desc())
                .limit(1)
            )
            result = (await session.execute(stmt)).all()

            if not result:
                # If the key doesn't exist or the array is empty
                return None

            await session.execute(
                delete(self._table_class).where(self._table_class.id == result[0][0])
            )
            await session.commit()

            return ChatMessage.model_validate(result[0][1])
Async version of Delete last message for a key.
llama-index-integrations/storage/chat_store/llama-index-storage-chat-store-sqlite/llama_index/storage/chat_store/sqlite/base.py