yym68686 commited on
Commit
b2991c2
·
1 Parent(s): a55b91d

🐛 Bug: Fix the bug of weight load balancing round-robin.

Browse files
Files changed (1) hide show
  1. main.py +7 -6
main.py CHANGED
@@ -717,13 +717,14 @@ class ModelRequestHandler:
717
  matching_providers = random.sample(matching_providers, num_matching_providers)
718
 
719
  weights = safe_get(config, 'api_keys', api_index, "weights")
720
- if weights:
721
- # 步骤 1: 提取 matching_providers 中的所有 provider 值
722
- providers = set(provider['provider'] for provider in matching_providers)
723
- weight_keys = set(weights.keys())
724
 
725
- # 步骤 3: 计算交集
726
- intersection = providers.intersection(weight_keys)
 
 
 
 
 
727
  weights = dict(filter(lambda item: item[0] in intersection, weights.items()))
728
 
729
  if scheduling_algorithm == "weighted_round_robin":
 
717
  matching_providers = random.sample(matching_providers, num_matching_providers)
718
 
719
  weights = safe_get(config, 'api_keys', api_index, "weights")
 
 
 
 
720
 
721
+ # 步骤 1: 提取 matching_providers 中的所有 provider 值
722
+ all_providers = set(provider['provider'] for provider in matching_providers)
723
+ weight_keys = set(weights.keys())
724
+ # 步骤 3: 计算交集
725
+ intersection = all_providers.intersection(weight_keys)
726
+
727
+ if weights and intersection:
728
  weights = dict(filter(lambda item: item[0] in intersection, weights.items()))
729
 
730
  if scheduling_algorithm == "weighted_round_robin":