feat: extend support for o3 models and update model ratios

This commit is contained in:
Laisky.Cai
2025-02-01 11:44:04 +00:00
parent f47c70aaa2
commit 0e19d60769
4 changed files with 70 additions and 56 deletions

View File

@@ -86,7 +86,8 @@ func (a *Adaptor) ConvertRequest(c *gin.Context, relayMode int, request *model.G
} }
// o1/o1-mini/o1-preview do not support system prompt/max_tokens/temperature // o1/o1-mini/o1-preview do not support system prompt/max_tokens/temperature
if strings.HasPrefix(request.Model, "o1") { if strings.HasPrefix(request.Model, "o1") ||
strings.HasPrefix(request.Model, "o3") {
temperature := float64(1) temperature := float64(1)
request.Temperature = &temperature // Only the default (1) value is supported request.Temperature = &temperature // Only the default (1) value is supported

View File

@@ -9,6 +9,7 @@ var ModelList = []string{
"gpt-4-turbo-preview", "gpt-4-turbo", "gpt-4-turbo-2024-04-09", "gpt-4-turbo-preview", "gpt-4-turbo", "gpt-4-turbo-2024-04-09",
"gpt-4o", "gpt-4o-2024-05-13", "gpt-4o-2024-08-06", "gpt-4o-2024-11-20", "chatgpt-4o-latest", "gpt-4o", "gpt-4o-2024-05-13", "gpt-4o-2024-08-06", "gpt-4o-2024-11-20", "chatgpt-4o-latest",
"gpt-4o-mini", "gpt-4o-mini-2024-07-18", "gpt-4o-mini", "gpt-4o-mini-2024-07-18",
"gpt-4o-mini-audio-preview", "gpt-4o-mini-audio-preview-2024-12-17",
"gpt-4o-audio-preview", "gpt-4o-audio-preview-2024-12-17", "gpt-4o-audio-preview-2024-10-01", "gpt-4o-audio-preview", "gpt-4o-audio-preview-2024-12-17", "gpt-4o-audio-preview-2024-10-01",
"gpt-4-vision-preview", "gpt-4-vision-preview",
"text-embedding-ada-002", "text-embedding-3-small", "text-embedding-3-large", "text-embedding-ada-002", "text-embedding-3-small", "text-embedding-3-large",
@@ -22,4 +23,5 @@ var ModelList = []string{
"o1", "o1-2024-12-17", "o1", "o1-2024-12-17",
"o1-preview", "o1-preview-2024-09-12", "o1-preview", "o1-preview-2024-09-12",
"o1-mini", "o1-mini-2024-09-12", "o1-mini", "o1-mini-2024-09-12",
"o3-mini", "o3-mini-2025-01-31",
} }

View File

@@ -48,6 +48,8 @@ var ModelRatio = map[string]float64{
"gpt-4o-audio-preview": 1.25, // $0.0025 / 1K tokens "gpt-4o-audio-preview": 1.25, // $0.0025 / 1K tokens
"gpt-4o-audio-preview-2024-12-17": 1.25, // $0.0025 / 1K tokens "gpt-4o-audio-preview-2024-12-17": 1.25, // $0.0025 / 1K tokens
"gpt-4o-audio-preview-2024-10-01": 1.25, // $0.0025 / 1K tokens "gpt-4o-audio-preview-2024-10-01": 1.25, // $0.0025 / 1K tokens
"gpt-4o-mini-audio-preview": 0.15 * MILLI_USD, // $0.15/1M tokens
"gpt-4o-mini-audio-preview-2024-12-17": 0.15 * MILLI_USD, // $0.15/1M tokens
"gpt-3.5-turbo": 0.25, // $0.0005 / 1K tokens "gpt-3.5-turbo": 0.25, // $0.0005 / 1K tokens
"gpt-3.5-turbo-0301": 0.75, "gpt-3.5-turbo-0301": 0.75,
"gpt-3.5-turbo-0613": 0.75, "gpt-3.5-turbo-0613": 0.75,
@@ -62,6 +64,8 @@ var ModelRatio = map[string]float64{
"o1-preview-2024-09-12": 7.5, "o1-preview-2024-09-12": 7.5,
"o1-mini": 1.5, // $3.00 / 1M input tokens "o1-mini": 1.5, // $3.00 / 1M input tokens
"o1-mini-2024-09-12": 1.5, "o1-mini-2024-09-12": 1.5,
"o3-mini": 1.1 * MILLI_USD,
"o3-mini-2025-01-31": 1.1 * MILLI_USD,
"davinci-002": 1, // $0.002 / 1K tokens "davinci-002": 1, // $0.002 / 1K tokens
"babbage-002": 0.2, // $0.0004 / 1K tokens "babbage-002": 0.2, // $0.0004 / 1K tokens
"text-ada-001": 0.2, "text-ada-001": 0.2,
@@ -348,6 +352,8 @@ var AudioRatio = map[string]float64{
"gpt-4o-audio-preview": 16, "gpt-4o-audio-preview": 16,
"gpt-4o-audio-preview-2024-12-17": 16, "gpt-4o-audio-preview-2024-12-17": 16,
"gpt-4o-audio-preview-2024-10-01": 40, "gpt-4o-audio-preview-2024-10-01": 40,
"gpt-4o-mini-audio-preview": 10 / 0.15,
"gpt-4o-mini-audio-preview-2024-12-17": 10 / 0.15,
} }
// GetAudioPromptRatio returns the audio prompt ratio for the given model. // GetAudioPromptRatio returns the audio prompt ratio for the given model.
@@ -368,6 +374,8 @@ var AudioCompletionRatio = map[string]float64{
"gpt-4o-audio-preview": 2, "gpt-4o-audio-preview": 2,
"gpt-4o-audio-preview-2024-12-17": 2, "gpt-4o-audio-preview-2024-12-17": 2,
"gpt-4o-audio-preview-2024-10-01": 2, "gpt-4o-audio-preview-2024-10-01": 2,
"gpt-4o-mini-audio-preview": 2,
"gpt-4o-mini-audio-preview-2024-12-17": 2,
} }
// GetAudioCompletionRatio returns the completion ratio for audio models. // GetAudioCompletionRatio returns the completion ratio for audio models.
@@ -392,6 +400,8 @@ var AudioPromptTokensPerSecond = map[string]float64{
"gpt-4o-audio-preview": 10, "gpt-4o-audio-preview": 10,
"gpt-4o-audio-preview-2024-12-17": 10, "gpt-4o-audio-preview-2024-12-17": 10,
"gpt-4o-audio-preview-2024-10-01": 10, "gpt-4o-audio-preview-2024-10-01": 10,
"gpt-4o-mini-audio-preview": 10,
"gpt-4o-mini-audio-preview-2024-12-17": 10,
} }
// GetAudioPromptTokensPerSecond returns the number of audio tokens per second // GetAudioPromptTokensPerSecond returns the number of audio tokens per second
@@ -549,7 +559,8 @@ func GetCompletionRatio(name string, channelType int) float64 {
return 2 return 2
} }
// including o1/o1-preview/o1-mini // including o1/o1-preview/o1-mini
if strings.HasPrefix(name, "o1") { if strings.HasPrefix(name, "o1") ||
strings.HasPrefix(name, "o3") {
return 4 return 4
} }
if name == "chatgpt-4o-latest" { if name == "chatgpt-4o-latest" {

View File

@@ -34,7 +34,7 @@ type GeneralOpenAIRequest struct {
MaxTokens int `json:"max_tokens,omitempty"` MaxTokens int `json:"max_tokens,omitempty"`
MaxCompletionTokens *int `json:"max_completion_tokens,omitempty"` MaxCompletionTokens *int `json:"max_completion_tokens,omitempty"`
N int `json:"n,omitempty"` N int `json:"n,omitempty"`
// ReasoningEffort constrains effort on reasoning for reasoning models, o1 models only. // ReasoningEffort constrains effort on reasoning for reasoning models, reasoning models only.
ReasoningEffort string `json:"reasoning_effort,omitempty" binding:"omitempty,oneof=low medium high"` ReasoningEffort string `json:"reasoning_effort,omitempty" binding:"omitempty,oneof=low medium high"`
// Modalities currently the model only programmatically allows modalities = [“text”, “audio”] // Modalities currently the model only programmatically allows modalities = [“text”, “audio”]
Modalities []string `json:"modalities,omitempty"` Modalities []string `json:"modalities,omitempty"`