Skip to content

Commit 5c528d0

Browse files
authored
Merge pull request #52 from openai/jiwon/allow-vendor-icons
Allow `vendor:` prefixed icons
2 parents 22ffc00 + dba5017 commit 5c528d0

File tree

6 files changed

+102
-136
lines changed

6 files changed

+102
-136
lines changed

chatkit/icons.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
from typing import Annotated, Literal
2+
3+
from pydantic import StringConstraints
4+
5+
VendorIconName = Annotated[str, StringConstraints(pattern=r"^vendor:")]
6+
7+
IconName = (
8+
Literal[
9+
"agent",
10+
"analytics",
11+
"atom",
12+
"batch",
13+
"bolt",
14+
"book-open",
15+
"book-closed",
16+
"book-clock",
17+
"bug",
18+
"calendar",
19+
"chart",
20+
"check",
21+
"check-circle",
22+
"check-circle-filled",
23+
"chevron-left",
24+
"chevron-right",
25+
"circle-question",
26+
"compass",
27+
"confetti",
28+
"cube",
29+
"desktop",
30+
"document",
31+
"dot",
32+
"dots-horizontal",
33+
"dots-vertical",
34+
"empty-circle",
35+
"external-link",
36+
"globe",
37+
"keys",
38+
"lab",
39+
"images",
40+
"info",
41+
"lifesaver",
42+
"lightbulb",
43+
"mail",
44+
"map-pin",
45+
"maps",
46+
"mobile",
47+
"name",
48+
"notebook",
49+
"notebook-pencil",
50+
"page-blank",
51+
"phone",
52+
"play",
53+
"plus",
54+
"profile",
55+
"profile-card",
56+
"reload",
57+
"star",
58+
"star-filled",
59+
"search",
60+
"sparkle",
61+
"sparkle-double",
62+
"square-code",
63+
"square-image",
64+
"square-text",
65+
"suitcase",
66+
"settings-slider",
67+
"user",
68+
"wreath",
69+
"write",
70+
"write-alt",
71+
"write-alt2",
72+
]
73+
| VendorIconName
74+
)

chatkit/types.py

Lines changed: 1 addition & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from chatkit.errors import ErrorCode
1010

1111
from .actions import Action
12+
from .icons import IconName
1213
from .widgets import WidgetComponent, WidgetRoot
1314

1415
T = TypeVar("T")
@@ -828,71 +829,3 @@ class EntitySource(SourceBase):
828829

829830
FeedbackKind = Literal["positive", "negative"]
830831
"""Literal type for feedback sentiment."""
831-
832-
833-
IconName = Literal[
834-
"agent",
835-
"analytics",
836-
"atom",
837-
"batch",
838-
"bolt",
839-
"book-open",
840-
"book-closed",
841-
"book-clock",
842-
"bug",
843-
"calendar",
844-
"chart",
845-
"check",
846-
"check-circle",
847-
"check-circle-filled",
848-
"chevron-left",
849-
"chevron-right",
850-
"circle-question",
851-
"compass",
852-
"confetti",
853-
"cube",
854-
"desktop",
855-
"document",
856-
"dot",
857-
"dots-horizontal",
858-
"dots-vertical",
859-
"empty-circle",
860-
"external-link",
861-
"globe",
862-
"keys",
863-
"lab",
864-
"images",
865-
"info",
866-
"lifesaver",
867-
"lightbulb",
868-
"mail",
869-
"map-pin",
870-
"maps",
871-
"mobile",
872-
"name",
873-
"notebook",
874-
"notebook-pencil",
875-
"page-blank",
876-
"phone",
877-
"play",
878-
"plus",
879-
"profile",
880-
"profile-card",
881-
"reload",
882-
"star",
883-
"star-filled",
884-
"search",
885-
"sparkle",
886-
"sparkle-double",
887-
"square-code",
888-
"square-image",
889-
"square-text",
890-
"suitcase",
891-
"settings-slider",
892-
"user",
893-
"wreath",
894-
"write",
895-
"write-alt",
896-
"write-alt2",
897-
]
898-
"""Literal names of supported progress icons."""

chatkit/widgets.py

Lines changed: 3 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
)
1515
from typing_extensions import NotRequired, TypedDict
1616

17-
from chatkit.actions import ActionConfig
17+
from .actions import ActionConfig
18+
from .icons import IconName
1819

1920

2021
class ThemeColor(TypedDict):
@@ -1039,69 +1040,5 @@ class LineSeries(BaseModel):
10391040
"""Union of all renderable widget components."""
10401041

10411042

1042-
WidgetIcon = Literal[
1043-
"agent",
1044-
"analytics",
1045-
"atom",
1046-
"batch",
1047-
"bolt",
1048-
"book-open",
1049-
"book-clock",
1050-
"book-closed",
1051-
"bug",
1052-
"calendar",
1053-
"chart",
1054-
"check",
1055-
"check-circle",
1056-
"check-circle-filled",
1057-
"chevron-left",
1058-
"chevron-right",
1059-
"circle-question",
1060-
"compass",
1061-
"confetti",
1062-
"cube",
1063-
"desktop",
1064-
"document",
1065-
"dot",
1066-
"dots-horizontal",
1067-
"dots-vertical",
1068-
"empty-circle",
1069-
"external-link",
1070-
"globe",
1071-
"keys",
1072-
"lab",
1073-
"images",
1074-
"info",
1075-
"lifesaver",
1076-
"lightbulb",
1077-
"mail",
1078-
"map-pin",
1079-
"maps",
1080-
"mobile",
1081-
"name",
1082-
"notebook",
1083-
"notebook-pencil",
1084-
"page-blank",
1085-
"phone",
1086-
"play",
1087-
"plus",
1088-
"profile",
1089-
"profile-card",
1090-
"reload",
1091-
"star",
1092-
"star-filled",
1093-
"search",
1094-
"sparkle",
1095-
"sparkle-double",
1096-
"square-code",
1097-
"square-image",
1098-
"square-text",
1099-
"suitcase",
1100-
"settings-slider",
1101-
"user",
1102-
"wreath",
1103-
"write",
1104-
"write-alt",
1105-
"write-alt2",
1106-
]
1043+
WidgetIcon = IconName
11071044
"""Icon names accepted by widgets that render icons."""

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "openai-chatkit"
3-
version = "1.1.1"
3+
version = "1.1.2"
44
description = "A ChatKit backend SDK."
55
readme = "README.md"
66
requires-python = ">=3.10"

tests/test_icons.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import pytest
2+
from pydantic import TypeAdapter, ValidationError
3+
4+
from chatkit.icons import IconName
5+
6+
7+
def test_vendor_icon_names_are_valid():
8+
"""Icon names prefixed with `vendor:` are valid."""
9+
TypeAdapter(IconName).validate_python("vendor:icon-name")
10+
TypeAdapter(IconName).validate_python("vendor:another-icon-name")
11+
12+
13+
def test_literal_icon_names_are_valid():
14+
"""Spot check some literal icon names."""
15+
TypeAdapter(IconName).validate_python("book-open")
16+
TypeAdapter(IconName).validate_python("phone")
17+
TypeAdapter(IconName).validate_python("user")
18+
19+
20+
def test_invalid_icon_names_are_rejected():
21+
with pytest.raises(ValidationError):
22+
TypeAdapter(IconName).validate_python("invalid-icon")

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)