prompt = prompt.replace(escape_sequence, escaped_sequence)
        return prompt
[docs]    @abstractmethod
    def format_request_payload(self, prompt: str, model_kwargs: Dict) -> bytes:
        """Formats the request body according to the input schema of
        the model. Returns bytes or seekable file like object in the
        format specified in the content_type request header.
        """
[docs]    @abstractmethod
    def format_response_payload(self, output: bytes) -> str:
        """Formats the response body according to the output
        schema of the model. Returns the data type that is
        received from the response.
        """
[docs]class GPT2ContentFormatter(ContentFormatterBase):
    """Content handler for GPT2"""
[docs]    def format_request_payload(self, prompt: str, model_kwargs: Dict) -> bytes:
        prompt = ContentFormatterBase.escape_special_characters(prompt)
        request_payload = json.dumps(
            {"inputs": {"input_string": [f'"{prompt}"']}, "parameters": model_kwargs}
        )
        return str.encode(request_payload)
[docs]    def format_response_payload(self, output: bytes) -> str:
        return json.loads(output)[0]["0"]
[docs]class OSSContentFormatter(GPT2ContentFormatter):
    """Deprecated: Kept for backwards compatibility
    Content handler for LLMs from the OSS catalog."""
    content_formatter: Any = None
[docs]    def __init__(self) -> None:
        super().__init__()
        warnings.warn(
            """`OSSContentFormatter` will be deprecated in the future. 
                      Please use `GPT2ContentFormatter` instead.  
                      """
        )
[docs]class HFContentFormatter(ContentFormatterBase):