Skip to content

Conversation

@danielpeng2
Copy link
Contributor

Describe the change

Adding the prediction field which allows for using Predicted Outputs.

Provide OpenAI documentation link
https://platform.openai.com/docs/api-reference/chat/create#chat-create-prediction

Describe your solution
Adds the optional parameter and modifies the response to include how many prediction tokens it used

Tests
Briefly describe how you have tested these changes. If possible — please add integration tests.
Tested locally and verified that I received predicted tokens accepted in the response
image

Issue: #954

@danielpeng2 danielpeng2 changed the title Daniel/add prediction field Add Prediction Field Apr 23, 2025
@danielpeng2 danielpeng2 changed the title Add Prediction Field Add Prediction field Apr 23, 2025
@sashabaranov sashabaranov requested a review from Copilot April 23, 2025 22:03
Copy link
Contributor

Copilot AI left a comment

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 adds support for predicted outputs by introducing a new prediction field in the chat completion request and updating usage metrics to track predicted token counts.

  • Adds AcceptedPredictionTokens and RejectedPredictionTokens to the Usage metrics in common.go.
  • Introduces a Prediction configuration and corresponding struct in chat.go for predicted outputs.

Reviewed Changes

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

File Description
common.go Adds new fields to track accepted and rejected predicted tokens.
chat.go Introduces Prediction field in ChatCompletionRequest and defines Prediction struct.

Copy link
Owner

@sashabaranov sashabaranov left a comment

Choose a reason for hiding this comment

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

Thank you!

@sashabaranov sashabaranov merged commit 93a611c into sashabaranov:master Apr 29, 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.

2 participants