Skip to content

Commit

Permalink
Merge remote-tracking branch 'aaakoako/https' into https
Browse files Browse the repository at this point in the history
  • Loading branch information
Leizhenpeng committed Mar 9, 2023
2 parents f6226ef + fb1d490 commit e78ba8d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions code/services/gpt3.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ func (gpt *ChatGPT) getApiKey() (string, error) {
}
totalWeight := 0
for _, weight := range gpt.apiKeyWeights {
if weight <= 0 {
// 如果权重为0或负数,则永久禁用该apikey
continue
}
totalWeight += weight
}
if totalWeight == 0 {
Expand All @@ -185,6 +189,10 @@ func (gpt *ChatGPT) getApiKey() (string, error) {
}
randNum := rand.Intn(totalWeight)
for i, weight := range gpt.apiKeyWeights {
if weight <= 0 {
// 如果权重为0或负数,则跳过该apikey
continue
}
if randNum < weight {
gpt.currentApiKeyIndex = i
break
Expand Down

0 comments on commit e78ba8d

Please sign in to comment.