refactor(responses): remove compact model suffix handling (#6770)
This commit is contained in:
@@ -1,12 +1,6 @@
|
||||
package codex
|
||||
|
||||
import (
|
||||
"slices"
|
||||
|
||||
"github.com/QuantumNous/new-api/setting/ratio_setting"
|
||||
)
|
||||
|
||||
var baseModelList = []string{
|
||||
var ModelList = []string{
|
||||
"gpt-5.6-sol",
|
||||
"gpt-5.6-terra",
|
||||
"gpt-5.6-luna",
|
||||
@@ -17,11 +11,4 @@ var baseModelList = []string{
|
||||
"codex-auto-review",
|
||||
}
|
||||
|
||||
var ModelList = slices.DeleteFunc(
|
||||
ratio_setting.WithCompactModelVariants(baseModelList),
|
||||
func(modelName string) bool {
|
||||
return modelName == ratio_setting.WithCompactModelSuffix("codex-auto-review")
|
||||
},
|
||||
)
|
||||
|
||||
const ChannelName = "codex"
|
||||
|
||||
@@ -4,12 +4,9 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/QuantumNous/new-api/relay/common"
|
||||
relayconstant "github.com/QuantumNous/new-api/relay/constant"
|
||||
"github.com/QuantumNous/new-api/relaykit/dto"
|
||||
"github.com/QuantumNous/new-api/setting/ratio_setting"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
@@ -18,13 +15,6 @@ func ModelMappedHelper(c *gin.Context, info *common.RelayInfo, request dto.Reque
|
||||
info.ChannelMeta = &common.ChannelMeta{}
|
||||
}
|
||||
|
||||
isResponsesCompact := info.RelayMode == relayconstant.RelayModeResponsesCompact
|
||||
originModelName := info.OriginModelName
|
||||
mappingModelName := originModelName
|
||||
if isResponsesCompact && strings.HasSuffix(originModelName, ratio_setting.CompactModelSuffix) {
|
||||
mappingModelName = strings.TrimSuffix(originModelName, ratio_setting.CompactModelSuffix)
|
||||
}
|
||||
|
||||
// map model name
|
||||
modelMapping := c.GetString("model_mapping")
|
||||
if modelMapping != "" && modelMapping != "{}" {
|
||||
@@ -35,7 +25,7 @@ func ModelMappedHelper(c *gin.Context, info *common.RelayInfo, request dto.Reque
|
||||
}
|
||||
|
||||
// 支持链式模型重定向,最终使用链尾的模型
|
||||
currentModel := mappingModelName
|
||||
currentModel := info.OriginModelName
|
||||
visitedModels := map[string]bool{
|
||||
currentModel: true,
|
||||
}
|
||||
@@ -66,14 +56,6 @@ func ModelMappedHelper(c *gin.Context, info *common.RelayInfo, request dto.Reque
|
||||
}
|
||||
}
|
||||
|
||||
if isResponsesCompact {
|
||||
finalUpstreamModelName := mappingModelName
|
||||
if info.IsModelMapped && info.UpstreamModelName != "" {
|
||||
finalUpstreamModelName = info.UpstreamModelName
|
||||
}
|
||||
info.UpstreamModelName = finalUpstreamModelName
|
||||
info.OriginModelName = ratio_setting.WithCompactModelSuffix(finalUpstreamModelName)
|
||||
}
|
||||
if request != nil {
|
||||
request.SetModelName(info.UpstreamModelName)
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
func ResponsesHelper(c *gin.Context, info *relaycommon.RelayInfo) (newAPIError *types.NewAPIError) {
|
||||
info.InitChannelMeta(c)
|
||||
if info.RelayMode == relayconstant.RelayModeResponsesCompact &&
|
||||
!common.IsResponsesCompactAPIType(info.ApiType) {
|
||||
!common.SupportsResponsesCompact(info.ChannelType, info.ApiType) {
|
||||
return types.NewErrorWithStatusCode(
|
||||
fmt.Errorf("unsupported endpoint %q for api type %d", "/v1/responses/compact", info.ApiType),
|
||||
types.ErrorCodeInvalidRequest,
|
||||
|
||||
Reference in New Issue
Block a user