Skip to content

Commit 93a611c

Browse files
authored
Add Prediction field (#970)
* Add Prediction field to ChatCompletionRequest * Include prediction tokens in response
1 parent 6836cf6 commit 93a611c

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

chat.go

+7
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,8 @@ type ChatCompletionRequest struct {
273273
ReasoningEffort string `json:"reasoning_effort,omitempty"`
274274
// Metadata to store with the completion.
275275
Metadata map[string]string `json:"metadata,omitempty"`
276+
// Configuration for a predicted output.
277+
Prediction *Prediction `json:"prediction,omitempty"`
276278
}
277279

278280
type StreamOptions struct {
@@ -340,6 +342,11 @@ type LogProbs struct {
340342
Content []LogProb `json:"content"`
341343
}
342344

345+
type Prediction struct {
346+
Content string `json:"content"`
347+
Type string `json:"type"`
348+
}
349+
343350
type FinishReason string
344351

345352
const (

common.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ type Usage struct {
1313

1414
// CompletionTokensDetails Breakdown of tokens used in a completion.
1515
type CompletionTokensDetails struct {
16-
AudioTokens int `json:"audio_tokens"`
17-
ReasoningTokens int `json:"reasoning_tokens"`
16+
AudioTokens int `json:"audio_tokens"`
17+
ReasoningTokens int `json:"reasoning_tokens"`
18+
AcceptedPredictionTokens int `json:"accepted_prediction_tokens"`
19+
RejectedPredictionTokens int `json:"rejected_prediction_tokens"`
1820
}
1921

2022
// PromptTokensDetails Breakdown of tokens used in the prompt.

0 commit comments

Comments
 (0)