mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-07-26 06:16:09 +00:00
refactor: 适配配置管理器读取方式
This commit is contained in:
+10
-7
@@ -3,6 +3,9 @@ import time
|
||||
import logging
|
||||
import threading
|
||||
|
||||
from ..utils import context
|
||||
|
||||
|
||||
__crt_minute_usage__ = {}
|
||||
"""当前分钟每个会话的对话次数"""
|
||||
|
||||
@@ -12,16 +15,16 @@ __timer_thr__: threading.Thread = None
|
||||
|
||||
def get_limitation(session_name: str) -> int:
|
||||
"""获取会话的限制次数"""
|
||||
import config
|
||||
config = context.get_config_manager().data
|
||||
|
||||
if type(config.rate_limitation) == dict:
|
||||
if type(config['rate_limitation']) == dict:
|
||||
# 如果被指定了
|
||||
if session_name in config.rate_limitation:
|
||||
return config.rate_limitation[session_name]
|
||||
if session_name in config['rate_limitation']:
|
||||
return config['rate_limitation'][session_name]
|
||||
else:
|
||||
return config.rate_limitation["default"]
|
||||
elif type(config.rate_limitation) == int:
|
||||
return config.rate_limitation
|
||||
return config['rate_limitation']["default"]
|
||||
elif type(config['rate_limitation']) == int:
|
||||
return config['rate_limitation']
|
||||
|
||||
|
||||
def add_usage(session_name: str):
|
||||
|
||||
Reference in New Issue
Block a user