def save_conversation(
        self, message: str, message_type: MessageType, **kwargs
    ) -> None:
        """Save context from this conversation to redis."""
        redis_key = self.redis_key_prefix + f":{ChatMessageHistory.__name__}"
        pickled = self.redis_client.get(redis_key)
        if pickled:
            messages: list[BaseMessage] = pickle.loads(pickled)
        else:
            messages = []
        if message_type == MessageType.AIMessage:
            messages.append(AIMessage(content=message))
        elif message_type == MessageType.UserMessage:
            messages.append(UserMessage(content=message))
        elif message_type == MessageType.FunctionMessage:
            messages.append(FunctionMessage(content=message, name=kwargs["name"]))
        elif message_type == MessageType.SystemMessage:
            messages.append(SystemMessage(content=message))
        else:
            raise ValueError(f"Unsupported message type: {message_type}")
        self.save_memory(redis_key, messages)
Save context from this conversation to redis.
autochain/memory/redis_memory.py