fix(types): include prompt text and image token counts#1902
Open
FU-max-boop wants to merge 1 commit into
Open
Conversation
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.
Summary
Fixes #1718.
CompletionUsage.PromptTokensDetailsalready exposesaudio_tokensandcached_tokens, but chat completions usage payloads for audio/image-capable models can also includetext_tokensandimage_tokens. This adds those optional fields to the shared completion usage type soresponse.usage.prompt_tokens_details.text_tokensand.image_tokenstype-check for chat completions.I also added a small type regression test that exercises the shared
OpenAI.CompletionUsagesurface.Tests
npx -y [email protected] install --frozen-lockfile --ignore-scriptsnpx -y [email protected] test tests/usage-types.test.tsnpx -y [email protected] build./node_modules/.bin/prettier --check src/resources/completions.ts tests/usage-types.test.ts./node_modules/.bin/eslint src/resources/completions.ts tests/usage-types.test.tsgit diff --checkNote: the full
npx -y [email protected] lintrun completed prettier/eslint/build, then stopped in its repo-wide type-check step because this checkout does not have optional example dependencies (@azure/identity,express,next) installed. The changed files passed targeted prettier/eslint, and the package build plus type regression test passed.Git HTTPS push repeatedly timed out to github.com:443 from this environment, so I created the fork branch via the GitHub Git Data API after local validation.