Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions chatkit/icons.py
Original file line number Diff line number Diff line change
@@ -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
)
69 changes: 1 addition & 68 deletions chatkit/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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."""
69 changes: 3 additions & 66 deletions chatkit/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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."""
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
22 changes: 22 additions & 0 deletions tests/test_icons.py
Original file line number Diff line number Diff line change
@@ -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")
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.