Skip to content

Commit 2c33586

Browse files
committed
fix(pkg-py): don't import pydantic (via chatlas helpers) unless it's relevant/needed
1 parent 2f64ced commit 2c33586

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pkg-py/src/shinychat/_chat_normalize.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
from htmltools import HTML, Tagifiable
77

8-
from ._chat_normalize_chatlas import tool_request_contents, tool_result_contents
98
from ._chat_types import ChatMessage
109

1110
__all__ = ["message_content", "message_content_chunk"]
@@ -129,6 +128,12 @@ def _(chunk: Tagifiable):
129128
from chatlas import ContentToolRequest, ContentToolResult, Turn
130129
from chatlas.types import Content, ContentText
131130

131+
# Import here to avoid hard dependency on pydantic
132+
from ._chat_normalize_chatlas import (
133+
tool_request_contents,
134+
tool_result_contents,
135+
)
136+
132137
@message_content.register
133138
def _(message: Content):
134139
return ChatMessage(content=str(message))
@@ -164,6 +169,7 @@ def _(chunk: ContentToolResult):
164169
@message_content.register
165170
def _(message: Turn):
166171
from chatlas import ContentToolResult
172+
167173
content = ""
168174
for x in message.contents:
169175
content += message_content(x).content

0 commit comments

Comments
 (0)