Преглед изворни кода

feat: add support for o3-mini models in model ratio and request handling

1808837298@qq.com пре 1 година
родитељ
комит
69102d141f
3 измењених фајлова са 6 додато и 3 уклоњено
  1. 3 1
      common/model-ratio.go
  2. 2 2
      relay/channel/openai/adaptor.go
  3. 1 0
      relay/channel/openai/constant.go

+ 3 - 1
common/model-ratio.go

@@ -56,6 +56,8 @@ var defaultModelRatio = map[string]float64{
 	"o1-preview-2024-09-12":  7.5,
 	"o1-mini":                1.5,
 	"o1-mini-2024-09-12":     1.5,
+	"o3-mini":                0.55,
+	"o3-mini-2025-01-31":     0.55,
 	"gpt-4o-mini":            0.075,
 	"gpt-4o-mini-2024-07-18": 0.075,
 	"gpt-4-turbo":            5, // $0.01 / 1K tokens
@@ -366,7 +368,7 @@ func GetCompletionRatio(name string) float64 {
 		}
 		return 2
 	}
-	if strings.HasPrefix(name, "o1") {
+	if strings.HasPrefix(name, "o1") || strings.HasPrefix(name, "o3") {
 		return 4
 	}
 	if name == "chatgpt-4o-latest" {

+ 2 - 2
relay/channel/openai/adaptor.go

@@ -109,13 +109,13 @@ func (a *Adaptor) ConvertRequest(c *gin.Context, info *relaycommon.RelayInfo, re
 	if info.ChannelType != common.ChannelTypeOpenAI && info.ChannelType != common.ChannelTypeAzure {
 		request.StreamOptions = nil
 	}
-	if strings.HasPrefix(request.Model, "o1") {
+	if strings.HasPrefix(request.Model, "o1") || strings.HasPrefix(request.Model, "o3") {
 		if request.MaxCompletionTokens == 0 && request.MaxTokens != 0 {
 			request.MaxCompletionTokens = request.MaxTokens
 			request.MaxTokens = 0
 		}
 	}
-	if request.Model == "o1" || request.Model == "o1-2024-12-17" {
+	if request.Model == "o1" || request.Model == "o1-2024-12-17" || strings.HasPrefix(request.Model, "o3") {
 		//修改第一个Message的内容,将system改为developer
 		if len(request.Messages) > 0 && request.Messages[0].Role == "system" {
 			request.Messages[0].Role = "developer"

+ 1 - 0
relay/channel/openai/constant.go

@@ -13,6 +13,7 @@ var ModelList = []string{
 	"gpt-4o-mini", "gpt-4o-mini-2024-07-18",
 	"o1-preview", "o1-preview-2024-09-12",
 	"o1-mini", "o1-mini-2024-09-12",
+	"o3-mini", "o3-mini-2025-01-31",
 	"o1", "o1-2024-12-17",
 	"gpt-4o-audio-preview", "gpt-4o-audio-preview-2024-10-01",
 	"gpt-4o-realtime-preview", "gpt-4o-realtime-preview-2024-10-01", "gpt-4o-realtime-preview-2024-12-17",