Skip to content
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

refactor(stream): make MessageStream wrap Stream directly #805

Merged
merged 1 commit into from
Dec 29, 2024

Conversation

alexmojaki
Copy link

This is intended to address pydantic/logfire#672. We patch the client _request methods to replace the stream_cls argument with a wrapper class that logs streamed values. But that wrapper gets lost by MessageStream and MessageStreamManager. This PR not only fixes the issue for us but also seems cleaner and more logical within this codebase - why recreate the Stream with the same arguments? It seems like a relic from when MessageStream was a subclass of Stream and passing the same arguments to __init__ made more sense.

@alexmojaki alexmojaki requested a review from a team as a code owner December 28, 2024 12:14
@RobertCraigie RobertCraigie changed the title Make MessageStream wrap Stream more directly refactor(stream): make MessageStream wrap Stream directly Dec 29, 2024
@RobertCraigie RobertCraigie changed the base branch from main to next December 29, 2024 04:13
Copy link
Collaborator

@RobertCraigie RobertCraigie left a comment

Choose a reason for hiding this comment

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

Thanks!

This PR not only fixes the issue for us but also seems cleaner and more logical within this codebase - why recreate the Stream with the same arguments? It seems like a relic from when MessageStream was a subclass of Stream and passing the same arguments to init made more sense.

yup spot on


note that this is technically a breaking change as MessageStream.__init__ is public API but I'd be surprised if anyone is relying on it

@RobertCraigie RobertCraigie merged commit 5669399 into anthropics:next Dec 29, 2024
2 checks passed
@stainless-app stainless-app bot mentioned this pull request Dec 29, 2024
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