streambricks 0.2.9__tar.gz → 0.2.10__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.
Files changed (29) hide show
  1. {streambricks-0.2.9 → streambricks-0.2.10}/PKG-INFO +1 -1
  2. {streambricks-0.2.9 → streambricks-0.2.10}/src/streambricks/__init__.py +1 -1
  3. {streambricks-0.2.9 → streambricks-0.2.10}/src/streambricks/widgets/model_widget.py +35 -0
  4. {streambricks-0.2.9 → streambricks-0.2.10}/.copier-answers.yml +0 -0
  5. {streambricks-0.2.9 → streambricks-0.2.10}/.github/FUNDING.yml +0 -0
  6. {streambricks-0.2.9 → streambricks-0.2.10}/.github/copilot-instructions.md +0 -0
  7. {streambricks-0.2.9 → streambricks-0.2.10}/.github/dependabot.yml +0 -0
  8. {streambricks-0.2.9 → streambricks-0.2.10}/.github/workflows/build.yml +0 -0
  9. {streambricks-0.2.9 → streambricks-0.2.10}/.github/workflows/documentation.yml +0 -0
  10. {streambricks-0.2.9 → streambricks-0.2.10}/.gitignore +0 -0
  11. {streambricks-0.2.9 → streambricks-0.2.10}/.pre-commit-config.yaml +0 -0
  12. {streambricks-0.2.9 → streambricks-0.2.10}/LICENSE +0 -0
  13. {streambricks-0.2.9 → streambricks-0.2.10}/README.md +0 -0
  14. {streambricks-0.2.9 → streambricks-0.2.10}/docs/.empty +0 -0
  15. {streambricks-0.2.9 → streambricks-0.2.10}/duties.py +0 -0
  16. {streambricks-0.2.9 → streambricks-0.2.10}/mkdocs.yml +0 -0
  17. {streambricks-0.2.9 → streambricks-0.2.10}/overrides/_dummy.txt +0 -0
  18. {streambricks-0.2.9 → streambricks-0.2.10}/pyproject.toml +0 -0
  19. {streambricks-0.2.9 → streambricks-0.2.10}/src/streambricks/helpers.py +0 -0
  20. {streambricks-0.2.9 → streambricks-0.2.10}/src/streambricks/py.typed +0 -0
  21. {streambricks-0.2.9 → streambricks-0.2.10}/src/streambricks/state.py +0 -0
  22. {streambricks-0.2.9 → streambricks-0.2.10}/src/streambricks/widgets/__init__.py +0 -0
  23. {streambricks-0.2.9 → streambricks-0.2.10}/src/streambricks/widgets/bind_kwargs.py +0 -0
  24. {streambricks-0.2.9 → streambricks-0.2.10}/src/streambricks/widgets/model_selector.py +0 -0
  25. {streambricks-0.2.9 → streambricks-0.2.10}/src/streambricks/widgets/multi_select.py +0 -0
  26. {streambricks-0.2.9 → streambricks-0.2.10}/src/streambricks/widgets/type_helpers.py +0 -0
  27. {streambricks-0.2.9 → streambricks-0.2.10}/tests/__init__.py +0 -0
  28. {streambricks-0.2.9 → streambricks-0.2.10}/tests/conftest.py +0 -0
  29. {streambricks-0.2.9 → streambricks-0.2.10}/tests/test_widgets.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: streambricks
3
- Version: 0.2.9
3
+ Version: 0.2.10
4
4
  Summary: Streamlit widgets and helpers
5
5
  Project-URL: Documentation, https://phil65.github.io/streambricks/
6
6
  Project-URL: Source, https://github.com/phil65/streambricks
@@ -1,4 +1,4 @@
1
- __version__ = "0.2.9"
1
+ __version__ = "0.2.10"
2
2
 
3
3
 
4
4
  from streambricks.widgets.model_widget import (
@@ -32,6 +32,33 @@ if TYPE_CHECKING:
32
32
  T = TypeVar("T")
33
33
  WidgetFunc = Callable[..., T]
34
34
 
35
+ FIELD_METADATA_RENDERERS: dict[str, WidgetFunc[Any]] = {}
36
+
37
+
38
+ def register_field_renderer(field_type: str, renderer: WidgetFunc[Any]) -> None:
39
+ """Register a custom field renderer for a specific field_type."""
40
+ FIELD_METADATA_RENDERERS[field_type] = renderer
41
+
42
+
43
+ def render_model_identifier_field(
44
+ *,
45
+ key: str,
46
+ value: str | None = None,
47
+ label: str | None = None,
48
+ disabled: bool = False,
49
+ help: str | None = None, # noqa: A002
50
+ **field_info: Any,
51
+ ) -> str:
52
+ """Render a model identifier field using model_selector widget."""
53
+ from streambricks.widgets.model_selector import model_selector
54
+
55
+ providers = field_info.get("providers")
56
+ selected_model = model_selector(value=value, providers=providers, expanded=False)
57
+ return selected_model.pydantic_ai_id if selected_model else value or ""
58
+
59
+
60
+ register_field_renderer("model_identifier", render_model_identifier_field)
61
+
35
62
 
36
63
  def render_str_field(
37
64
  *,
@@ -891,6 +918,14 @@ PRIMITIVE_RENDERERS = {
891
918
  def get_field_renderer(field_info: dict[str, Any]) -> WidgetFunc[Any]: # noqa: PLR0911
892
919
  """Get the appropriate renderer for a field based on its type and constraints."""
893
920
  annotation = field_info.get("type") or field_info.get("annotation")
921
+ # Check for custom field type specification in json_schema_extra
922
+ json_schema_extra = field_info.get("json_schema_extra", {})
923
+ if (
924
+ json_schema_extra
925
+ and (field_type := json_schema_extra.get("field_type"))
926
+ in FIELD_METADATA_RENDERERS
927
+ ):
928
+ return FIELD_METADATA_RENDERERS[field_type]
894
929
  if annotation is SecretStr or (
895
930
  isinstance(annotation, type) and issubclass(annotation, SecretStr)
896
931
  ):
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes