From 13c993d87e11e5b122602a65c214bd4c92ea2021 Mon Sep 17 00:00:00 2001 From: "1808837298@qq.com" <1808837298@qq.com> Date: Sat, 14 Sep 2024 16:11:38 +0800 Subject: [PATCH] feat: format o1 model max tokens param --- relay/channel/openai/adaptor.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/relay/channel/openai/adaptor.go b/relay/channel/openai/adaptor.go index 4388efd..8e4cf78 100644 --- a/relay/channel/openai/adaptor.go +++ b/relay/channel/openai/adaptor.go @@ -78,6 +78,12 @@ func (a *Adaptor) ConvertRequest(c *gin.Context, info *relaycommon.RelayInfo, re if info.ChannelType != common.ChannelTypeOpenAI { request.StreamOptions = nil } + if strings.HasPrefix(request.Model, "o1-") { + if request.MaxCompletionTokens == 0 && request.MaxTokens != 0 { + request.MaxCompletionTokens = request.MaxTokens + request.MaxTokens = 0 + } + } return request, nil }