fix(ai): DeepInfra completion tokens calculation for gemini models#12214
Closed
sylviezhang37 wants to merge 3 commits intomainfrom
Closed
fix(ai): DeepInfra completion tokens calculation for gemini models#12214sylviezhang37 wants to merge 3 commits intomainfrom
sylviezhang37 wants to merge 3 commits intomainfrom
Conversation
Contributor
Author
|
Closing this and passing this issue to ai sdk team |
1 task
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.
Background
We noticed in ai-gateway logs that Deepinfra's gemini models' output tokens are negative.
Summary
Deepinfra's issue with how they convert gemini response to openai-compat, this is a raw output from them where completion tokens < reasoning tokens. For openai-compat, completion tokens should include reasoning tokens.
They use vllm, and the issue should be here where they don't treat
complete_token_details.Added a conditional logic to override their calculation issues for the models we are seeing issues for but keeping the other models unchanged.
Manual Verification
Checklist
pnpm changesetin the project root)Future Work
A PR is open on vllm related to reasoning tokens calculation, but it is making progress very slowly, I subscribed to it. If reasoning tokens are incorporated by vllm, I can revert the code changes here.