mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-11-20 15:06:36 +00:00
fix(channel): 模型限制用映射后模型检查 + 平台开关保留配置不删除
- OpenAI 网关三处 IsModelRestricted 改用 channelMapping.MappedModel - 前端平台勾选改为 enabled 开关,取消勾选不清空配置数据 - formToAPI/校验只处理 enabled 的平台
This commit is contained in:
1 parent
a65a8bcd93
commit
946180ef0d
4 files changed
+27
-36
No files matched your search
@@ -191,10 +191,9 @@ func (h *OpenAIGatewayHandler) Responses(c *gin.Context) {
|
||||
channelMapping = h.gatewayService.ResolveChannelMapping(c.Request.Context(), *apiKey.GroupID, reqModel)
|
||||
}
|
||||
|
||||
// 渠道模型限制检查
|
||||
// 渠道模型限制检查:先映射再判断
|
||||
if apiKey.GroupID != nil {
|
||||
if h.gatewayService.IsModelRestricted(c.Request.Context(), *apiKey.GroupID, reqModel) {
|
||||
h.errorResponse(c, http.StatusServiceUnavailable, "api_error", "No available accounts")
|
||||
if h.gatewayService.IsModelRestricted(c.Request.Context(), *apiKey.GroupID, channelMapping.MappedModel) {
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -583,10 +582,9 @@ func (h *OpenAIGatewayHandler) Messages(c *gin.Context) {
|
||||
channelMappingMsg = h.gatewayService.ResolveChannelMapping(c.Request.Context(), *apiKey.GroupID, reqModel)
|
||||
}
|
||||
|
||||
// 渠道模型限制检查
|
||||
// 渠道模型限制检查:先映射再判断
|
||||
if apiKey.GroupID != nil {
|
||||
if h.gatewayService.IsModelRestricted(c.Request.Context(), *apiKey.GroupID, reqModel) {
|
||||
h.anthropicErrorResponse(c, http.StatusServiceUnavailable, "api_error", "No available accounts")
|
||||
if h.gatewayService.IsModelRestricted(c.Request.Context(), *apiKey.GroupID, channelMappingMsg.MappedModel) {
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -1164,9 +1162,9 @@ func (h *OpenAIGatewayHandler) ResponsesWebSocket(c *gin.Context) {
|
||||
channelMappingWS = h.gatewayService.ResolveChannelMapping(ctx, *apiKey.GroupID, reqModel)
|
||||
}
|
||||
|
||||
// 渠道模型限制检查
|
||||
// 渠道模型限制检查:先映射再判断
|
||||
if apiKey.GroupID != nil {
|
||||
if h.gatewayService.IsModelRestricted(ctx, *apiKey.GroupID, reqModel) {
|
||||
if h.gatewayService.IsModelRestricted(ctx, *apiKey.GroupID, channelMappingWS.MappedModel) {
|
||||
closeOpenAIClientWS(wsConn, coderws.StatusPolicyViolation, "model not allowed")
|
||||
return
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user