streambricks 0.2.2__tar.gz → 0.2.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {streambricks-0.2.2 → streambricks-0.2.3}/PKG-INFO +1 -1
- {streambricks-0.2.2 → streambricks-0.2.3}/src/streambricks/__init__.py +3 -1
- streambricks-0.2.3/src/streambricks/state.py +33 -0
- {streambricks-0.2.2 → streambricks-0.2.3}/.copier-answers.yml +0 -0
- {streambricks-0.2.2 → streambricks-0.2.3}/.github/FUNDING.yml +0 -0
- {streambricks-0.2.2 → streambricks-0.2.3}/.github/copilot-instructions.md +0 -0
- {streambricks-0.2.2 → streambricks-0.2.3}/.github/dependabot.yml +0 -0
- {streambricks-0.2.2 → streambricks-0.2.3}/.github/workflows/build.yml +0 -0
- {streambricks-0.2.2 → streambricks-0.2.3}/.github/workflows/documentation.yml +0 -0
- {streambricks-0.2.2 → streambricks-0.2.3}/.gitignore +0 -0
- {streambricks-0.2.2 → streambricks-0.2.3}/.pre-commit-config.yaml +0 -0
- {streambricks-0.2.2 → streambricks-0.2.3}/LICENSE +0 -0
- {streambricks-0.2.2 → streambricks-0.2.3}/README.md +0 -0
- {streambricks-0.2.2 → streambricks-0.2.3}/docs/.empty +0 -0
- {streambricks-0.2.2 → streambricks-0.2.3}/duties.py +0 -0
- {streambricks-0.2.2 → streambricks-0.2.3}/mkdocs.yml +0 -0
- {streambricks-0.2.2 → streambricks-0.2.3}/overrides/_dummy.txt +0 -0
- {streambricks-0.2.2 → streambricks-0.2.3}/pyproject.toml +0 -0
- {streambricks-0.2.2 → streambricks-0.2.3}/src/streambricks/helpers.py +0 -0
- {streambricks-0.2.2 → streambricks-0.2.3}/src/streambricks/py.typed +0 -0
- {streambricks-0.2.2 → streambricks-0.2.3}/src/streambricks/widgets/__init__.py +0 -0
- {streambricks-0.2.2 → streambricks-0.2.3}/src/streambricks/widgets/model_selector.py +0 -0
- {streambricks-0.2.2 → streambricks-0.2.3}/src/streambricks/widgets/model_widget.py +0 -0
- {streambricks-0.2.2 → streambricks-0.2.3}/src/streambricks/widgets/multi_select.py +0 -0
- {streambricks-0.2.2 → streambricks-0.2.3}/src/streambricks/widgets/type_helpers.py +0 -0
- {streambricks-0.2.2 → streambricks-0.2.3}/tests/__init__.py +0 -0
- {streambricks-0.2.2 → streambricks-0.2.3}/tests/conftest.py +0 -0
- {streambricks-0.2.2 → streambricks-0.2.3}/tests/test_widgets.py +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
__version__ = "0.2.
|
|
1
|
+
__version__ = "0.2.3"
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
from streambricks.widgets.model_widget import (
|
|
@@ -11,9 +11,11 @@ from streambricks.widgets.model_selector import (
|
|
|
11
11
|
model_selector as llm_model_selector,
|
|
12
12
|
)
|
|
13
13
|
from streambricks.helpers import run
|
|
14
|
+
from streambricks.state import get_state
|
|
14
15
|
|
|
15
16
|
__all__ = [
|
|
16
17
|
"MultiSelectItem",
|
|
18
|
+
"get_state",
|
|
17
19
|
"llm_model_selector",
|
|
18
20
|
"model_display",
|
|
19
21
|
"model_edit",
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import TypeVar, cast
|
|
4
|
+
|
|
5
|
+
from pydantic import BaseModel
|
|
6
|
+
import streamlit as st
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
T = TypeVar("T", bound=BaseModel)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def get_state(model_class: type[T], *, key: str | None = None) -> T:
|
|
13
|
+
"""Get or initialize typed state for Streamlit.
|
|
14
|
+
|
|
15
|
+
Args:
|
|
16
|
+
model_class: Pydantic model class defining the state structure
|
|
17
|
+
key: Optional key to use in session_state (defaults to model class name)
|
|
18
|
+
|
|
19
|
+
Returns:
|
|
20
|
+
An instance of the model representing current state
|
|
21
|
+
"""
|
|
22
|
+
state_key = key or model_class.__name__
|
|
23
|
+
|
|
24
|
+
# Initialize state if it doesn't exist
|
|
25
|
+
if state_key not in st.session_state:
|
|
26
|
+
st.session_state[state_key] = model_class()
|
|
27
|
+
|
|
28
|
+
# Ensure state is the correct type
|
|
29
|
+
current_state = st.session_state[state_key]
|
|
30
|
+
if not isinstance(current_state, model_class):
|
|
31
|
+
st.session_state[state_key] = model_class()
|
|
32
|
+
|
|
33
|
+
return cast(T, st.session_state[state_key])
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|