Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
8e9e99e
feat: add partial_reason to AssistantTurn and merge_content_text helper
cpsievert Apr 2, 2026
b042ad7
feat: preserve partial turns on stream interruption via try/finally
cpsievert Apr 2, 2026
d9ceae9
feat: exclude partial turns from token accounting and cost
cpsievert Apr 2, 2026
110c082
feat: display partial turns with [interrupted] in Chat repr
cpsievert Apr 2, 2026
b93e7c0
fix: resolve pyright errors in try/finally blocks
cpsievert Apr 2, 2026
cd51551
feat: add StreamController class for cooperative stream cancellation
cpsievert Apr 2, 2026
1a4e02f
feat: add controller parameter to stream() and stream_async()
cpsievert Apr 2, 2026
1ed21fb
feat: create internal StreamController for chat() and chat_async()
cpsievert Apr 2, 2026
6290ce4
style: auto-format with ruff
cpsievert Apr 2, 2026
b37be74
docs: document controller parameter on stream() and stream_async()
cpsievert Apr 2, 2026
0fef5fc
fix: address review feedback on stream cancellation PR
cpsievert Apr 2, 2026
736c6bc
docs: add changelog entries for stream cancellation and partial turns
cpsievert Apr 2, 2026
9767a94
feat: extract TurnAccumulator class for streaming turn lifecycle
cpsievert Apr 2, 2026
2db6447
fix: address code review feedback on TurnAccumulator
cpsievert Apr 2, 2026
31696b0
refactor: rewrite _submit_turns streaming branches to use TurnAccumul…
cpsievert Apr 2, 2026
383eae1
style: auto-format with ruff
cpsievert Apr 2, 2026
a2e145a
refactor: extract resolve_assistant_turn to deduplicate turn finaliza…
cpsievert Apr 2, 2026
1fb7b2c
Merge branch 'main' into feat/stream-cancellation
cpsievert Apr 2, 2026
1fd01a3
fix: address code review — auto-reset stale controllers, fix partial …
cpsievert Apr 2, 2026
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0


* The `.stream()` and `.stream_async()` methods now yield `ContentThinking` objects (instead of plain strings) for thinking/reasoning content when `content="all"`. This allows downstream packages like shinychat to provide specific UI for thinking content. (#276)
* New `StreamController` class for cooperative stream cancellation. Pass a controller to `.stream()` or `.stream_async()` and call `controller.cancel()` to stop the stream cleanly (e.g., from a Shiny "stop generating" button). The partial response is preserved in conversation history. (#279)
* When a stream is interrupted (closed early, cancelled, or errors), the accumulated content is now saved as a partial `AssistantTurn` so conversation state isn't lost. Partial turns display `[interrupted]` (or the cancellation reason) in the `Chat` repr and are excluded from token/cost accounting. (#279)
* Built-in tools (`tool_web_search()`, `tool_web_fetch()`) now include `description` and `annotations` properties, making their metadata consistent with user-defined tools created by `Tool()`. (#278)

### Bug fixes
Expand Down
2 changes: 2 additions & 0 deletions chatlas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from ._provider_perplexity import ChatPerplexity
from ._provider_portkey import ChatPortkey
from ._provider_snowflake import ChatSnowflake
from ._stream_controller import StreamController
from ._tokens import token_usage
from ._tools import Tool, ToolBuiltIn, ToolRejectError
from ._tools_builtin import tool_web_fetch, tool_web_search
Expand Down Expand Up @@ -83,6 +84,7 @@
"interpolate",
"interpolate_file",
"Provider",
"StreamController",
"token_usage",
"Tool",
"ToolBuiltIn",
Expand Down
Loading
Loading