ref(openai): Only handle streamed results when applicable#5553
ref(openai): Only handle streamed results when applicable#5553alexander-alderman-webb wants to merge 10 commits intowebb/openai/input-parameterfrom
Conversation
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. Bug Fixes 🐛Openai
Other
Documentation 📚
Internal Changes 🔧Agents
Openai
Openai Agents
Other
🤖 This preview updates automatically when you update the PR. |
Codecov Results 📊✅ 1851 passed | ⏭️ 166 skipped | Total: 2017 | Pass Rate: 91.77% | Execution Time: 3m 16s All tests are passing successfully. ❌ Patch coverage is 0.00%. Project has 11846 uncovered lines. Files with missing lines (173)
Generated by Codecov Action |
ericapisani
left a comment
There was a problem hiding this comment.
Small cleanups but approving so as not to block
sentry_sdk/integrations/openai.py
Outdated
|
|
||
| def new_iterator() -> "Iterator[ChatCompletionChunk]": | ||
| nonlocal ttft | ||
| count_tokens_manually = True |
There was a problem hiding this comment.
This doesn't appear to be needed in this iterator function - we never set it to false, so the conditional on line 644 will always run.
sentry_sdk/integrations/openai.py
Outdated
|
|
||
| async def new_iterator_async() -> "AsyncIterator[ChatCompletionChunk]": | ||
| nonlocal ttft | ||
| count_tokens_manually = True |
There was a problem hiding this comment.
Same situation here as above - this is never set to False so the conditional further down on line 688 will always run.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Description
Remove iterator patches from shared output-handling code, and only apply them in the dedicated functions for patching streamed responses. Only keep code relevant to the Completions and Responses APIs in the respective iterator wrappers.
Add
stream=Trueto tests where a streamed response is returned fromopenaifunctions.Issues
Reminders
tox -e linters.feat:,fix:,ref:,meta:)