Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: add instruction for bentoml.IODescriptor #4975

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/source/guides/iotypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,15 @@ You can also use a Pydantic model directly at the top level for a BentoML Servic

In the above code snippet, all the validated and parsed fields from the incoming request are passed into the ``generate`` method as keyword arguments stored in the ``params`` dictionary. You can access these parameters directly by their field names defined in ``AdsGenerationParams`` as keys in the dictionary.

Pydantic's ``BaseModel`` only supports built-in types in Python as field types. You can use ``bentoml.IODescriptor`` instead of ``pydantic.BaseModel`` to gain support for types such as ``numpy.ndarray``, ``pandas.DataFrame``, and ``torch.Tensor``.

.. code-block:: python

import bentoml

class MyInputParams(bentoml.IODescriptor):
data: np.ndarray[tuple[int], np.dtype[np.float16]]

Files
^^^^^

Expand Down