ref(openai): Only handle streamed results when applicable#5553
ref(openai): Only handle streamed results when applicable#5553alexander-alderman-webb wants to merge 8 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 📊✅ 31 passed | Total: 31 | Pass Rate: 100% | Execution Time: 12.13s 📊 Comparison with Base Branch
All tests are passing successfully. ❌ Patch coverage is 0.00%. Project has 14420 uncovered lines. Files with missing lines (181)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 26.45% 27.50% +1.05%
==========================================
Files 189 189 —
Lines 19830 19891 +61
Branches 6428 6462 +34
==========================================
+ Hits 5246 5471 +225
- Misses 14584 14420 -164
- Partials 457 488 +31Generated by Codecov Action |
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.
ericapisani
left a comment
There was a problem hiding this comment.
Small cleanups but approving so as not to block
|
|
||
| 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.
|
|
||
| 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.
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:)