fix: preserve explicit zero values in native relay requests

This commit is contained in:
Seefs
2026-03-01 15:47:03 +08:00
parent 21cfc1ca38
commit 0e9198e9b5
52 changed files with 523 additions and 232 deletions

View File

@@ -14,6 +14,7 @@ import (
relaycommon "github.com/QuantumNous/new-api/relay/common"
relayconstant "github.com/QuantumNous/new-api/relay/constant"
"github.com/QuantumNous/new-api/types"
"github.com/samber/lo"
"github.com/gin-gonic/gin"
)
@@ -83,8 +84,8 @@ func (a *Adaptor) ConvertOpenAIRequest(c *gin.Context, info *relaycommon.RelayIn
if request == nil {
return nil, errors.New("request is nil")
}
if request.TopP >= 1 {
request.TopP = 0.99
if lo.FromPtrOr(request.TopP, 0) >= 1 {
request.TopP = lo.ToPtr(0.99)
}
return requestOpenAI2Zhipu(*request), nil
}