refactor: move channel model restriction from handler to scheduling phase
Move the model pricing restriction check from 8 handler entry points to the account scheduling phase (SelectAccountForModelWithExclusions / SelectAccountWithLoadAwareness), aligning restriction with billing: - requested: check original request model against pricing list - channel_mapped: check channel-mapped model against pricing list - upstream: per-account check using account-mapped model Handler layer now only resolves channel mapping (no restriction). Scheduling layer performs pre-check for requested/channel_mapped, and per-account filtering for upstream billing source.
This commit is contained in:
@@ -436,8 +436,9 @@ func (s *ChannelService) IsModelRestricted(ctx context.Context, groupID int64, m
|
||||
return checkRestricted(lk, groupID, model)
|
||||
}
|
||||
|
||||
// ResolveChannelMappingAndRestrict 解析渠道映射并检查模型限制(组合方法)。
|
||||
// 返回映射结果和是否被限制。groupID 为 nil 时跳过。
|
||||
// ResolveChannelMappingAndRestrict 解析渠道映射。
|
||||
// 返回映射结果。模型限制检查已移至调度阶段(GatewayService.checkChannelPricingRestriction),
|
||||
// restricted 始终返回 false,保留签名兼容性。
|
||||
func (s *ChannelService) ResolveChannelMappingAndRestrict(ctx context.Context, groupID *int64, model string) (ChannelMappingResult, bool) {
|
||||
if groupID == nil {
|
||||
return ChannelMappingResult{MappedModel: model}, false
|
||||
@@ -446,10 +447,7 @@ func (s *ChannelService) ResolveChannelMappingAndRestrict(ctx context.Context, g
|
||||
if lk == nil {
|
||||
return ChannelMappingResult{MappedModel: model}, false
|
||||
}
|
||||
// 先用原始模型检查定价列表限制,再做映射
|
||||
restricted := checkRestricted(lk, *groupID, model)
|
||||
mapping := resolveMapping(lk, *groupID, model)
|
||||
return mapping, restricted
|
||||
return resolveMapping(lk, *groupID, model), false
|
||||
}
|
||||
|
||||
// resolveMapping 基于已查找的渠道信息解析模型映射
|
||||
|
||||
Reference in New Issue
Block a user