Repository navigation
Conversation
This branch had an error being deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Features
Preserve server-reported token usage from streaming chunks with an empty
choicesarray. Previously the parser skipped these chunks and fell back to alocal estimate, which can produce zero counts for an unknown model. The change
handles both SDK usage objects and dictionaries before skipping the empty
choices.
Closes #2163.
Feature Docs
The reproduction and expected behavior are in #2163.
Influence
This fixes the shared
OpenAILLMstream parser. Text assembly, existing usageon finish chunks or choices, and the missing-usage fallback retain their
behavior. The new regression module is collected by the current pytest config;
the older
test_openai.pyfilename is excluded there.Result
base
11cdf466, exactly the two usage-only cases fail and four controls pass.aaskandaask_code, including two custom aliases and 401 responses. Returned serverusage is now 4 prompt / 2 completion tokens for JSON and SSE. These tests use
a local fixture with synthetic credentials; no live model claim is made.
tracked Python files plus the new regression module.
git diff --checkpasses.test_count_tokensexpects 47 andgets 33 on both unchanged base and this patch in the same environment.
dependencies (including
llama_index,faissandaioboto3). The full localsuite has not passed. Validation used Python 3.11.13 and OpenAI 1.64.0;
upstream CI's Python 3.9 run remains pending.
Focused command, with native synthetic project config and live calls disabled:
Other
Repository issue
#2161 reports fork checkout failures in the current
pull_request_targetworkflows. This candidate’s fulltest run
also failed at
actions/checkout@v4, before Python setup or tests; the otherworkflow is waiting for approval. This PR contains the parser change and
regression tests only and preserves those CI protections.