From 9443833f94b1753e0cc7d099c9a5641ed928b2fd Mon Sep 17 00:00:00 2001 From: Jiwon Kim Date: Fri, 7 Nov 2025 13:35:54 -0800 Subject: [PATCH 1/2] IconName and WidgetIcon types support vendor: prefixed names --- chatkit/icons.py | 74 +++++++++++++++++++++++++++++++++++++++++++++ chatkit/types.py | 69 +----------------------------------------- chatkit/widgets.py | 69 ++---------------------------------------- tests/test_icons.py | 22 ++++++++++++++ 4 files changed, 100 insertions(+), 134 deletions(-) create mode 100644 chatkit/icons.py create mode 100644 tests/test_icons.py diff --git a/chatkit/icons.py b/chatkit/icons.py new file mode 100644 index 0000000..a5fd7fd --- /dev/null +++ b/chatkit/icons.py @@ -0,0 +1,74 @@ +from typing import Annotated, Literal + +from pydantic import StringConstraints + +VendorIconName = Annotated[str, StringConstraints(pattern=r"^vendor:")] + +IconName = ( + Literal[ + "agent", + "analytics", + "atom", + "batch", + "bolt", + "book-open", + "book-closed", + "book-clock", + "bug", + "calendar", + "chart", + "check", + "check-circle", + "check-circle-filled", + "chevron-left", + "chevron-right", + "circle-question", + "compass", + "confetti", + "cube", + "desktop", + "document", + "dot", + "dots-horizontal", + "dots-vertical", + "empty-circle", + "external-link", + "globe", + "keys", + "lab", + "images", + "info", + "lifesaver", + "lightbulb", + "mail", + "map-pin", + "maps", + "mobile", + "name", + "notebook", + "notebook-pencil", + "page-blank", + "phone", + "play", + "plus", + "profile", + "profile-card", + "reload", + "star", + "star-filled", + "search", + "sparkle", + "sparkle-double", + "square-code", + "square-image", + "square-text", + "suitcase", + "settings-slider", + "user", + "wreath", + "write", + "write-alt", + "write-alt2", + ] + | VendorIconName +) diff --git a/chatkit/types.py b/chatkit/types.py index 728c7ef..ea43de9 100644 --- a/chatkit/types.py +++ b/chatkit/types.py @@ -9,6 +9,7 @@ from chatkit.errors import ErrorCode from .actions import Action +from .icons import IconName from .widgets import WidgetComponent, WidgetRoot T = TypeVar("T") @@ -828,71 +829,3 @@ class EntitySource(SourceBase): FeedbackKind = Literal["positive", "negative"] """Literal type for feedback sentiment.""" - - -IconName = Literal[ - "agent", - "analytics", - "atom", - "batch", - "bolt", - "book-open", - "book-closed", - "book-clock", - "bug", - "calendar", - "chart", - "check", - "check-circle", - "check-circle-filled", - "chevron-left", - "chevron-right", - "circle-question", - "compass", - "confetti", - "cube", - "desktop", - "document", - "dot", - "dots-horizontal", - "dots-vertical", - "empty-circle", - "external-link", - "globe", - "keys", - "lab", - "images", - "info", - "lifesaver", - "lightbulb", - "mail", - "map-pin", - "maps", - "mobile", - "name", - "notebook", - "notebook-pencil", - "page-blank", - "phone", - "play", - "plus", - "profile", - "profile-card", - "reload", - "star", - "star-filled", - "search", - "sparkle", - "sparkle-double", - "square-code", - "square-image", - "square-text", - "suitcase", - "settings-slider", - "user", - "wreath", - "write", - "write-alt", - "write-alt2", -] -"""Literal names of supported progress icons.""" diff --git a/chatkit/widgets.py b/chatkit/widgets.py index e991f2a..8c64bbd 100644 --- a/chatkit/widgets.py +++ b/chatkit/widgets.py @@ -14,7 +14,8 @@ ) from typing_extensions import NotRequired, TypedDict -from chatkit.actions import ActionConfig +from .actions import ActionConfig +from .icons import IconName class ThemeColor(TypedDict): @@ -1039,69 +1040,5 @@ class LineSeries(BaseModel): """Union of all renderable widget components.""" -WidgetIcon = Literal[ - "agent", - "analytics", - "atom", - "batch", - "bolt", - "book-open", - "book-clock", - "book-closed", - "bug", - "calendar", - "chart", - "check", - "check-circle", - "check-circle-filled", - "chevron-left", - "chevron-right", - "circle-question", - "compass", - "confetti", - "cube", - "desktop", - "document", - "dot", - "dots-horizontal", - "dots-vertical", - "empty-circle", - "external-link", - "globe", - "keys", - "lab", - "images", - "info", - "lifesaver", - "lightbulb", - "mail", - "map-pin", - "maps", - "mobile", - "name", - "notebook", - "notebook-pencil", - "page-blank", - "phone", - "play", - "plus", - "profile", - "profile-card", - "reload", - "star", - "star-filled", - "search", - "sparkle", - "sparkle-double", - "square-code", - "square-image", - "square-text", - "suitcase", - "settings-slider", - "user", - "wreath", - "write", - "write-alt", - "write-alt2", -] +WidgetIcon = IconName """Icon names accepted by widgets that render icons.""" diff --git a/tests/test_icons.py b/tests/test_icons.py new file mode 100644 index 0000000..fd80483 --- /dev/null +++ b/tests/test_icons.py @@ -0,0 +1,22 @@ +import pytest +from pydantic import TypeAdapter, ValidationError + +from chatkit.icons import IconName + + +def test_vendor_icon_names_are_valid(): + """Icon names prefixed with `vendor:` are valid.""" + TypeAdapter(IconName).validate_python("vendor:icon-name") + TypeAdapter(IconName).validate_python("vendor:another-icon-name") + + +def test_literal_icon_names_are_valid(): + """Spot check some literal icon names.""" + TypeAdapter(IconName).validate_python("book-open") + TypeAdapter(IconName).validate_python("phone") + TypeAdapter(IconName).validate_python("user") + + +def test_invalid_icon_names_are_rejected(): + with pytest.raises(ValidationError): + TypeAdapter(IconName).validate_python("invalid-icon") From dba50179ccdc3f1eb174a1516821d925b760dea7 Mon Sep 17 00:00:00 2001 From: Jiwon Kim Date: Fri, 7 Nov 2025 13:36:13 -0800 Subject: [PATCH 2/2] bump patch version to 1.1.2 --- pyproject.toml | 2 +- uv.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ced825f..e3dced4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "openai-chatkit" -version = "1.1.1" +version = "1.1.2" description = "A ChatKit backend SDK." readme = "README.md" requires-python = ">=3.10" diff --git a/uv.lock b/uv.lock index 51cf4ea..8f3f1d1 100644 --- a/uv.lock +++ b/uv.lock @@ -819,7 +819,7 @@ wheels = [ [[package]] name = "openai-chatkit" -version = "1.1.1" +version = "1.1.2" source = { virtual = "." } dependencies = [ { name = "openai" },