Skip to main content

streamlit component for GhostOS, render form from JSONSchema by react-jsonschema-component

Project description

Streamlit-react-jsonschema

Streamlit component, building form by react-jsonschema-form.

This library is experimental for GhostOS yet.

Installation

install streamlit-react-jsonschema with pip

pip install streamlit_react_jsonschema

Example

see baseline example

from typing import Union, List, Dict
import streamlit as st
import streamlit_react_jsonschema as srj
import inspect
from pydantic import BaseModel, Field


class Student(BaseModel):
    name: str = Field(description="name of the student")
    level: int = Field(description="level of the student")


class SomeClass(BaseModel):
    """
    test class of pydantic model Foo
    """
    name: Union[str, None] = Field(None, description="filed with optional[str]")
    age: int = Field(0, description="bar value")
    some_float: float = Field(description="test about float value")

    students: List[Student] = Field(default_factory=list, description="list of students")
    students_dict: Dict[str, Student] = Field(default_factory=dict, description="dict of students")


st.title("Streamlit-react-jsonschema Example")
with st.expander("source code of the example pydantic class", expanded=True):
    codes = inspect.getsource(SomeClass)
    st.code(codes)

value, submitted = srj.pydantic_form(model=SomeClass)

st.subheader("result:")
st.write(f"submitted: {submitted}")
st.write(f"type of the result: {type(value)}")
st.write(value)
if isinstance(value, BaseModel):
    st.write("model dump value")
    st.write(value.model_dump(exclude_defaults=False))

How to run this example? Check streamlit first~

Dependencies

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

streamlit_react_jsonschema-0.1.6.tar.gz (1.6 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

streamlit_react_jsonschema-0.1.6-py3-none-any.whl (1.6 MB view details)

Uploaded Python 3

File details

Details for the file streamlit_react_jsonschema-0.1.6.tar.gz.

File metadata

  • Download URL: streamlit_react_jsonschema-0.1.6.tar.gz
  • Upload date:
  • Size: 1.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.6 Darwin/23.6.0

File hashes

Hashes for streamlit_react_jsonschema-0.1.6.tar.gz
Algorithm Hash digest
SHA256 d898501dbf1b9a0081b288ce03af3e398ce2ef6ec52e908aeff55dc3e935d8b3
MD5 2196ea1f35b6798181527a2207e4ed0c
BLAKE2b-256 1d3906f39ba92c10a1e3ea8f9b81e4653f44a35e7ba3f33afcd26349235c01cb

See more details on using hashes here.

File details

Details for the file streamlit_react_jsonschema-0.1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for streamlit_react_jsonschema-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 0c585fea463620d7dfe259da7915c3d255d06d9379828e0ff16623797d2cd1c7
MD5 eb5ec9d601a1f159a6f013101058fcf2
BLAKE2b-256 e209b69a475b3660e750a484f965ebc6ddbe3d3edca37474ed3f94bb55793da0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page