🐛 Bug: Fix the bug of weight load balancing round-robin.
Browse files
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 |
-
|
726 |
-
|
|
|
|
|
|
|
|
|
|
|
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":
|