Skip to content

Rename .stream()/.stream_async()'s content parameter to stream #102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

cpsievert
Copy link
Collaborator

@cpsievert cpsievert commented May 29, 2025

Breaking change to align the API for streaming content objects with tidyverse/ellmer#494.

Before this change, to access tool request/result objects in a stream, it was:

chat.stream(content="all")

Now it's

chat.stream(stream="content")

UPDATE: Now that I think through this naming change a bit more, I'm not convinced it's an improvement. With stream="content", it could make one wonder what chat.stream() is doing -- is it streaming something other than content? From that perspective, I like content="all" better -- it better implies that you're gaining access to additional content, which is the main point of the parameter existing.

cc @gadenbuie

@cpsievert cpsievert requested a review from Copilot May 29, 2025 22:44
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the .stream() and .stream_async() methods to rename their content parameter to stream, align internal flags, and update related tests and documentation.

  • Rename contentstream in signatures, docstrings, and internal calls
  • Map new stream values to internal yield_content flags
  • Update tests and changelog for the breaking change

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
tests/conftest.py Updated test call from content="all" to stream="content"
chatlas/_chat.py Renamed content params to stream in .stream() methods, added yield_content mapping, and refreshed docblocks
CHANGELOG.md Added breaking change entry for renaming contentstream
Comments suppressed due to low confidence (1)

CHANGELOG.md:25

  • The changelog entry has empty parentheses at the end; please include the relevant PR or issue number (e.g., (#494)).
* The `.stream()`/`.stream_async()` method's `content` parameter was renamed to `stream`. Set `stream` to "content" to gain access to tool request/result content objects. ()

@cpsievert cpsievert marked this pull request as ready for review May 29, 2025 22:52
@cpsievert cpsievert marked this pull request as draft May 29, 2025 23:05
@gadenbuie
Copy link
Contributor

With stream="content", it could make one wonder what chat.stream() is doing -- is it streaming something other than content? From that perspective, I like content="all" better -- it better implies that you're gaining access to additional content, which is the main point of the parameter existing.

The distinction is more about the return type. stream="text" streams text and everything yielded by the generator is a string. When stream="content", everything yielded by the generator is a Content instance. The fact that stream="content" includes tool requests and results is a consequence of those items not having a text representation. (In theory, we could decide to yield a standard text representation for stream="text".)

Anyway, I agree the naming is confusing – lots of things could be content – but the contract of always yielding Content makes it worth using this term here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants