Skip to content

Conversation

@ddeville
Copy link
Contributor

There were a bunch of mypy issues when I applied this internally so fixing them here.

Also deal with async stream line parsing a bit more robustly (iterating over an aiohttp.StreamReader by chunks could still return multiple lines so let's keep using the regular one and deal with multiple lines separately).

Finally make sure that we correctly close the underlying session if an exception is raised while we're making the raw request.

@ddeville ddeville requested a review from athyuttamre January 12, 2023 19:21
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you prefer to change what the server sends here? iter_chunks returns exactly the chunks as received from the server

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When stress testing this I saw that iter_chunks would return multiple lines in a chunk maybe 1/3 of the time so I believe we still need to handle this edge case. We could go back to using iter_chunks rather than the regular async stream iterator though, you're right.

@ddeville ddeville merged commit 5d1a726 into main Jan 13, 2023
@ddeville ddeville deleted the damien/async-types branch January 13, 2023 01:06
cgayapr pushed a commit to cgayapr/openai-python that referenced this pull request Dec 14, 2024
stainless-app bot pushed a commit that referenced this pull request Mar 27, 2025
Update README.md to mention which website the key lives on
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.

3 participants