|
|
@@ -166,12 +166,22 @@ func GetChannelAffinityCacheStats() ChannelAffinityCacheStats {
|
|
|
unknown++
|
|
|
continue
|
|
|
}
|
|
|
- if rule.IncludeUsingGroup {
|
|
|
+ if rule.IncludeModelName {
|
|
|
if len(parts) < 3 {
|
|
|
unknown++
|
|
|
continue
|
|
|
}
|
|
|
}
|
|
|
+ if rule.IncludeUsingGroup {
|
|
|
+ minParts := 3
|
|
|
+ if rule.IncludeModelName {
|
|
|
+ minParts = 4
|
|
|
+ }
|
|
|
+ if len(parts) < minParts {
|
|
|
+ unknown++
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ }
|
|
|
byRuleName[ruleName]++
|
|
|
}
|
|
|
|
|
|
@@ -319,11 +329,14 @@ func extractChannelAffinityValue(c *gin.Context, src operation_setting.ChannelAf
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func buildChannelAffinityCacheKeySuffix(rule operation_setting.ChannelAffinityRule, usingGroup string, affinityValue string) string {
|
|
|
- parts := make([]string, 0, 3)
|
|
|
+func buildChannelAffinityCacheKeySuffix(rule operation_setting.ChannelAffinityRule, modelName string, usingGroup string, affinityValue string) string {
|
|
|
+ parts := make([]string, 0, 4)
|
|
|
if rule.IncludeRuleName && rule.Name != "" {
|
|
|
parts = append(parts, rule.Name)
|
|
|
}
|
|
|
+ if rule.IncludeModelName && modelName != "" {
|
|
|
+ parts = append(parts, modelName)
|
|
|
+ }
|
|
|
if rule.IncludeUsingGroup && usingGroup != "" {
|
|
|
parts = append(parts, usingGroup)
|
|
|
}
|
|
|
@@ -573,7 +586,7 @@ func GetPreferredChannelByAffinity(c *gin.Context, modelName string, usingGroup
|
|
|
if ttlSeconds <= 0 {
|
|
|
ttlSeconds = setting.DefaultTTLSeconds
|
|
|
}
|
|
|
- cacheKeySuffix := buildChannelAffinityCacheKeySuffix(rule, usingGroup, affinityValue)
|
|
|
+ cacheKeySuffix := buildChannelAffinityCacheKeySuffix(rule, modelName, usingGroup, affinityValue)
|
|
|
cacheKeyFull := channelAffinityCacheNamespace + ":" + cacheKeySuffix
|
|
|
setChannelAffinityContext(c, channelAffinityMeta{
|
|
|
CacheKey: cacheKeyFull,
|