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
6 changes: 6 additions & 0 deletions pkg-py/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [UNRELEASED]

### Bug fixes

* `message_content()` and `message_content_chunk()` correctly extract content from a `chatlas.Turn`. (#133)

## [0.2.2] - 2025-09-10

### Improvements
Expand Down
13 changes: 9 additions & 4 deletions pkg-py/src/shinychat/_chat_normalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys
from functools import singledispatch

from htmltools import HTML, Tagifiable, TagList
from htmltools import HTML, Tagifiable

from ._chat_normalize_chatlas import tool_request_contents, tool_result_contents
from ._chat_types import ChatMessage
Expand Down Expand Up @@ -163,10 +163,15 @@ def _(chunk: ContentToolResult):

@message_content.register
def _(message: Turn):
contents = TagList()
from chatlas import ContentToolResult
content = ""
for x in message.contents:
contents.append(message_content(x).content)
return ChatMessage(content=contents)
content += message_content(x).content
if all(isinstance(x, ContentToolResult) for x in message.contents):
role = "assistant"
else:
role = message.role
return ChatMessage(content=content, role=role)

@message_content_chunk.register
def _(chunk: Turn):
Expand Down