pydantic_input(
key: str,
model: Type[BaseModel],
group_optional_fields: GroupOptionalFieldsStrategy = 'no',
lowercase_labels: bool = False,
ignore_empty_values: bool = False
) → Dict
Auto-generates input UI elements for a selected Pydantic class.
Args:
key
(str): A string that identifies the form. Each form must have its own key.model
(Type[BaseModel]): The input model. Either a class or instance based on PydanticBaseModel
or Pythondataclass
.group_optional_fields
(str, optional): Ifsidebar
, optional input elements will be rendered on the sidebar. Ifexpander
, optional input elements will be rendered inside an expander element. Defaults tono
.lowercase_labels
(bool): IfTrue
, all input element labels will be lowercased. Defaults toFalse
.ignore_empty_values
(bool): IfTrue
, empty values for strings and numbers will not be stored in the session state. Defaults toFalse
.
Returns:
Dict
: A dictionary with the current state of the input data.
pydantic_output(output_data: Any) → None
Auto-generates output UI elements for all properties of a (Pydantic-based) model instance.
Args:
output_data
(Any): The output data.
pydantic_form(
key: str,
model: Type[~T],
submit_label: str = 'Submit',
clear_on_submit: bool = False,
group_optional_fields: GroupOptionalFieldsStrategy = 'no',
lowercase_labels: bool = False,
ignore_empty_values: bool = False
) → Union[~T, NoneType]
Auto-generates a Streamlit form based on the given (Pydantic-based) input class.
Args:
key
(str): A string that identifies the form. Each form must have its own key.model
(Type[BaseModel]): The input model. Either a class or instance based on PydanticBaseModel
or Pythondataclass
.submit_label
(str): A short label explaining to the user what this button is for. Defaults to “Submit”.clear_on_submit
(bool): If True, all widgets inside the form will be reset to their default values after the user presses the Submit button. Defaults to False.group_optional_fields
(str, optional): Ifsidebar
, optional input elements will be rendered on the sidebar. Ifexpander
, optional input elements will be rendered inside an expander element. Defaults tono
.lowercase_labels
(bool): IfTrue
, all input element labels will be lowercased. Defaults toFalse
.ignore_empty_values
(bool): IfTrue
, empty values for strings and numbers will not be stored in the session state. Defaults toFalse
.
Returns:
Optional[BaseModel]
: An instance of the given input class, if the submit button is used and the input data passes the Pydantic validation.
An enumeration.
This file was automatically generated via lazydocs.