From 3a11ab716be9d12da10b4c2e5b437d783ad7dfbe Mon Sep 17 00:00:00 2001 From: Daniel Peng Date: Mon, 21 Apr 2025 17:19:41 -0700 Subject: [PATCH 1/2] Add Prediction field to ChatCompletionRequest --- chat.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/chat.go b/chat.go index 995860c40..8219dbfde 100644 --- a/chat.go +++ b/chat.go @@ -263,6 +263,8 @@ type ChatCompletionRequest struct { ReasoningEffort string `json:"reasoning_effort,omitempty"` // Metadata to store with the completion. Metadata map[string]string `json:"metadata,omitempty"` + // Configuration for a predicted output. + Prediction *Prediction `json:"prediction,omitempty"` } type StreamOptions struct { @@ -330,6 +332,11 @@ type LogProbs struct { Content []LogProb `json:"content"` } +type Prediction struct { + Content string `json:"content"` + Type string `json:"type"` +} + type FinishReason string const ( From 644bfdf6f758dffd4963c729931c573b8b0afd14 Mon Sep 17 00:00:00 2001 From: Daniel Peng Date: Mon, 21 Apr 2025 18:15:25 -0700 Subject: [PATCH 2/2] Include prediction tokens in response --- common.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/common.go b/common.go index 8cc7289c0..d1936d656 100644 --- a/common.go +++ b/common.go @@ -13,8 +13,10 @@ type Usage struct { // CompletionTokensDetails Breakdown of tokens used in a completion. type CompletionTokensDetails struct { - AudioTokens int `json:"audio_tokens"` - ReasoningTokens int `json:"reasoning_tokens"` + AudioTokens int `json:"audio_tokens"` + ReasoningTokens int `json:"reasoning_tokens"` + AcceptedPredictionTokens int `json:"accepted_prediction_tokens"` + RejectedPredictionTokens int `json:"rejected_prediction_tokens"` } // PromptTokensDetails Breakdown of tokens used in the prompt.