Completion API: add new params (#870)
* Completion API: add 'store' param This param allows you to opt a completion request in to being stored, for use in distillations and evals. * Add cached and audio tokens to usage structs These have been added to the completions API recently: https://platform.openai.com/docs/api-reference/chat/object#chat/object-usage
This commit is contained in:
@@ -7,10 +7,18 @@ type Usage struct {
|
|||||||
PromptTokens int `json:"prompt_tokens"`
|
PromptTokens int `json:"prompt_tokens"`
|
||||||
CompletionTokens int `json:"completion_tokens"`
|
CompletionTokens int `json:"completion_tokens"`
|
||||||
TotalTokens int `json:"total_tokens"`
|
TotalTokens int `json:"total_tokens"`
|
||||||
|
PromptTokensDetails *PromptTokensDetails `json:"prompt_tokens_details"`
|
||||||
CompletionTokensDetails *CompletionTokensDetails `json:"completion_tokens_details"`
|
CompletionTokensDetails *CompletionTokensDetails `json:"completion_tokens_details"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CompletionTokensDetails Breakdown of tokens used in a completion.
|
// CompletionTokensDetails Breakdown of tokens used in a completion.
|
||||||
type CompletionTokensDetails struct {
|
type CompletionTokensDetails struct {
|
||||||
|
AudioTokens int `json:"audio_tokens"`
|
||||||
ReasoningTokens int `json:"reasoning_tokens"`
|
ReasoningTokens int `json:"reasoning_tokens"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PromptTokensDetails Breakdown of tokens used in the prompt.
|
||||||
|
type PromptTokensDetails struct {
|
||||||
|
AudioTokens int `json:"audio_tokens"`
|
||||||
|
CachedTokens int `json:"cached_tokens"`
|
||||||
|
}
|
||||||
|
|||||||
@@ -238,18 +238,21 @@ type CompletionRequest struct {
|
|||||||
// LogitBias is must be a token id string (specified by their token ID in the tokenizer), not a word string.
|
// LogitBias is must be a token id string (specified by their token ID in the tokenizer), not a word string.
|
||||||
// incorrect: `"logit_bias":{"You": 6}`, correct: `"logit_bias":{"1639": 6}`
|
// incorrect: `"logit_bias":{"You": 6}`, correct: `"logit_bias":{"1639": 6}`
|
||||||
// refs: https://platform.openai.com/docs/api-reference/completions/create#completions/create-logit_bias
|
// refs: https://platform.openai.com/docs/api-reference/completions/create#completions/create-logit_bias
|
||||||
LogitBias map[string]int `json:"logit_bias,omitempty"`
|
LogitBias map[string]int `json:"logit_bias,omitempty"`
|
||||||
LogProbs int `json:"logprobs,omitempty"`
|
// Store can be set to true to store the output of this completion request for use in distillations and evals.
|
||||||
MaxTokens int `json:"max_tokens,omitempty"`
|
// https://platform.openai.com/docs/api-reference/chat/create#chat-create-store
|
||||||
N int `json:"n,omitempty"`
|
Store bool `json:"store,omitempty"`
|
||||||
PresencePenalty float32 `json:"presence_penalty,omitempty"`
|
LogProbs int `json:"logprobs,omitempty"`
|
||||||
Seed *int `json:"seed,omitempty"`
|
MaxTokens int `json:"max_tokens,omitempty"`
|
||||||
Stop []string `json:"stop,omitempty"`
|
N int `json:"n,omitempty"`
|
||||||
Stream bool `json:"stream,omitempty"`
|
PresencePenalty float32 `json:"presence_penalty,omitempty"`
|
||||||
Suffix string `json:"suffix,omitempty"`
|
Seed *int `json:"seed,omitempty"`
|
||||||
Temperature float32 `json:"temperature,omitempty"`
|
Stop []string `json:"stop,omitempty"`
|
||||||
TopP float32 `json:"top_p,omitempty"`
|
Stream bool `json:"stream,omitempty"`
|
||||||
User string `json:"user,omitempty"`
|
Suffix string `json:"suffix,omitempty"`
|
||||||
|
Temperature float32 `json:"temperature,omitempty"`
|
||||||
|
TopP float32 `json:"top_p,omitempty"`
|
||||||
|
User string `json:"user,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CompletionChoice represents one of possible completions.
|
// CompletionChoice represents one of possible completions.
|
||||||
|
|||||||
Reference in New Issue
Block a user