feat: update according to openai doc

This commit is contained in:
Yiyang Kang 2025-02-02 15:28:16 +09:00
parent 2ff8372439
commit 4ab359053a
4 changed files with 30 additions and 18 deletions

View file

@ -6,28 +6,40 @@ type ChatRole string
const (
ChatRoleSystem ChatRole = "system"
ChatRoleDeveloper ChatRole = "developer" // replaces `system` role for o1 and newer models
ChatRoleTool ChatRole = "tool"
ChatRoleAssistant ChatRole = "assistant"
ChatRoleUser ChatRole = "user"
)
type ReasoningEffort string
const (
ReasoningEffortLow ReasoningEffort = "low"
ReasoningEffortMedium ReasoningEffort = "medium"
ReasoningEffortHigh ReasoningEffort = "high"
)
type ChatMessage struct {
Role ChatRole `json:"role"`
Content string `json:"content"`
}
type ChatRequest struct {
Model string `json:"model"`
Messages []ChatMessage `json:"messages"`
Temperature *float64 `json:"temperature,omitempty"` // What sampling temperature to use, between 0 and 2.
TopP *float64 `json:"top_p,omitempty"` // Nucleus sampling. Specify this or temperature but not both.
N int `json:"n,omitempty"` // How many chat completion choices to generate for each input message.
Stream bool `json:"stream,omitempty"` // If set, partial message deltas will be sent as data-only server-sent events as they become available.
Stop []string `json:"stop,omitempty"` // Up to 4 sequences where the API will stop generating further tokens.
MaxTokens int `json:"max_tokens,omitempty"`
PresencePenalty *float64 `json:"presence_penalty,omitempty"` // Number between -2.0 and 2.0.
FrequencyPenalty *float64 `json:"frequency_penalty,omitempty"` // Number between -2.0 and 2.0.
LogitBias map[string]float64 `json:"logit_bias,omitempty"` // Modify the likelihood of specified tokens appearing in the completion.
User string `json:"user,omitempty"` // A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse.
Model string `json:"model"`
Messages []ChatMessage `json:"messages"`
Temperature *float64 `json:"temperature,omitempty"` // What sampling temperature to use, between 0 and 2.
TopP *float64 `json:"top_p,omitempty"` // Nucleus sampling. Specify this or temperature but not both.
N int `json:"n,omitempty"` // How many chat completion choices to generate for each input message.
Stream bool `json:"stream,omitempty"` // If set, partial message deltas will be sent as data-only server-sent events as they become available.
Stop []string `json:"stop,omitempty"` // Up to 4 sequences where the API will stop generating further tokens.
MaxTokens int `json:"max_tokens,omitempty"` // Deprecated: in favor of `max_completion_tokens`
MaxCompletionTokens int `json:"max_completion_tokens,omitempty"` // Including visible output tokens and reasoning tokens.
PresencePenalty *float64 `json:"presence_penalty,omitempty"` // Number between -2.0 and 2.0.
FrequencyPenalty *float64 `json:"frequency_penalty,omitempty"` // Number between -2.0 and 2.0.
LogitBias map[string]float64 `json:"logit_bias,omitempty"` // Modify the likelihood of specified tokens appearing in the completion.
User string `json:"user,omitempty"` // A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse.
ReasoningEffort ReasoningEffort `json:"reasoning_effort,omitempty"` // Constrains effort on reasoning for reasoning models.
}
type ChatResponseChoice struct {