    def _from_sample(self, sample: str | bytes) -> str:
        """
        Create a :class:`~bentoml._internal.io_descriptors.text.Text` IO Descriptor from given inputs.

        Args:
            sample: Given sample text.

        Returns:
            :class:`Text`: IODescriptor from given users inputs.

        Example:

        .. code-block:: python
           :caption: `service.py`

           @svc.api(input=bentoml.io.Text.from_sample('Bento box is'), output=bentoml.io.Text())
           def predict(inputs: str) -> str: ...
        """
        if isinstance(sample, bytes):
            sample = sample.decode("utf-8")
        return sample
Create a :class:`~bentoml._internal.io_descriptors.text.Text` IO Descriptor from given inputs.

Args:
sample: Given sample text.

Returns:
:class:`Text`: IODescriptor from given users inputs.

Example:

.. code-block:: python
:caption: `service.py`

@svc.api(input=bentoml.io.Text.from_sample('Bento box is'), output=bentoml.io.Text())
def predict(inputs: str) -> str: ...
src/bentoml/_internal/io_descriptors/text.py