Transform Pydantic Models into Streamlit UI components
Streamlit Pydantic
Transform Pydantic Models into Streamlit UI components
Streamlit-pydantic makes it easy to deal with Pydantic objects within Streamlit. It allows to directly generate Input as well as Output UI components based on a Pydantic models.
Getting Started
Installation
Requirements: Python 3.6+.
pip install streamlit-pydantic
Usage
Streamlit-pydantic provides the pydantic_input
and pydantic_output
methods to render input/output UI components from Pydantic models. Those methods can be easily embedded into any streamlit script. For example:
-
Create a script (
my_script.py
) with a Pydantic model and render it viapydantic_input
:from pydantic import BaseModel import streamlit_pydantic as sp class ExampleModel(BaseModel): text: str integer: int test: bool sp.pydantic_input(ExampleModel, "input_data")
-
Run the streamlit server on the python