mirror of
https://github.com/langbot-app/LangBot.git
synced 2025-11-26 03:44:58 +08:00
perf: 根据测试修改keymgr统计的文字量比例
This commit is contained in:
@@ -72,7 +72,11 @@ class KeysManager:
|
||||
md5 = hashlib.md5(self.using_key.encode('utf-8')).hexdigest()
|
||||
if md5 not in self.usage:
|
||||
self.usage[md5] = 0
|
||||
self.usage[md5] += int((len(new_content.encode('utf-8')) - len(new_content)) / 2 + len(new_content))
|
||||
|
||||
# 经测算得出的理论与实际的偏差比例
|
||||
salt_rate = 0.94
|
||||
|
||||
self.usage[md5] += int((len(new_content.encode('utf-8')) - len(new_content)) / 2 + len(new_content))*salt_rate
|
||||
|
||||
if self.usage[md5] >= self.api_key_usage_threshold:
|
||||
switch_result, key_name = self.auto_switch()
|
||||
|
||||
Reference in New Issue
Block a user