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
8 changes: 6 additions & 2 deletions pkg-py/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [UNRELEASED]

* The chat input no longer submits incomplete text when the user has activated IME completions (e.g. while typing in Japanese or Chinese). (#85)
### New features

* Added new `message_content()` and `message_content_chunk()` generic (`singledispatch`) functions. These functions aren't intended to be called directly by users, but instead, provide an opportunity to teach `Chat.append_message()`/`Chat.append_message_stream()` to extract message contents from different types of objects. (#96)

### Bug fixes

* The chat input no longer submits incomplete text when the user has activated IME completions (e.g. while typing in Japanese or Chinese). (#85)

## [0.1.0] - 2025-08-07

This first release of the `shinychat` package simply copies the `Chat` and `MarkdownStream` components exactly as they are in version 1.4.0 of `shiny`. Future versions of `shiny` will import these components from `shinychat`. By maintaining these components via a separate library, we can ship features more quickly and independently of `shiny`.

13 changes: 12 additions & 1 deletion pkg-py/src/shinychat/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
from . import playwright, types
from ._chat import Chat, chat_ui
from ._chat_normalize import message_content, message_content_chunk
from ._markdown_stream import MarkdownStream, output_markdown_stream

__all__ = ["Chat", "chat_ui", "MarkdownStream", "output_markdown_stream"]
__all__ = [
"Chat",
"chat_ui",
"MarkdownStream",
"output_markdown_stream",
"message_content",
"message_content_chunk",
"types",
"playwright",
]
8 changes: 4 additions & 4 deletions pkg-py/src/shinychat/_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@
is_chatlas_chat_client,
set_chatlas_state,
)
from ._chat_normalize import normalize_message, normalize_message_chunk
from ._chat_normalize import message_content, message_content_chunk
from ._chat_provider_types import (
AnthropicMessage,
AnthropicMessage, # pyright: ignore[reportAttributeAccessIssue]
GoogleMessage,
LangChainMessage,
OllamaMessage,
Expand Down Expand Up @@ -636,7 +636,7 @@ async def append_message(
self._pending_messages.append((message, False, "append", None))
return

msg = normalize_message(message)
msg = message_content(message)
msg = await self._transform_message(msg)
if msg is None:
return
Expand Down Expand Up @@ -753,7 +753,7 @@ async def _append_message_chunk(
self._current_stream_id = stream_id

# Normalize various message types into a ChatMessage()
msg = normalize_message_chunk(message)
msg = message_content_chunk(message)

if operation == "replace":
self._current_stream_message = (
Expand Down
Loading