Skip to content

fix input_tokens adaptation error#5

Merged
cuipengfei merged 1 commit into
cuipengfei:masterfrom
caozhiyuan:master
Aug 28, 2025
Merged

fix input_tokens adaptation error#5
cuipengfei merged 1 commit into
cuipengfei:masterfrom
caozhiyuan:master

Conversation

@cuipengfei

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings August 28, 2025 13:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes an input_tokens adaptation error by properly handling cached tokens in the token usage calculations for both streaming and non-streaming chat completion responses.

  • Updates the ChatCompletionResponse interface to include optional prompt_tokens_details with cached_tokens
  • Modifies input_tokens calculation to subtract cached tokens from prompt tokens
  • Adds cache_read_input_tokens field when cached tokens are present

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/services/copilot/create-chat-completions.ts Adds optional prompt_tokens_details field to support cached token tracking
src/routes/messages/stream-translation.ts Updates token calculations in streaming responses to handle cached tokens
src/routes/messages/non-stream-translation.ts Updates token calculations in non-streaming responses to handle cached tokens

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@cuipengfei cuipengfei merged commit 01a09c8 into cuipengfei:master Aug 28, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants