feat(config): 新增最大并发分发数配置项
在 `ChatConfig` 中引入了 `max_concurrent_distributions` 配置,允许用户自定义最大并发处理的消息流数量。 此举旨在提供更灵活的性能调优选项,帮助用户根据服务器负载和API速率限制来控制资源消耗,防止系统过载。该配置的默认值为10。
This commit is contained in:
@@ -34,8 +34,8 @@ class StreamLoopManager:
|
|||||||
}
|
}
|
||||||
|
|
||||||
# 配置参数
|
# 配置参数
|
||||||
self.max_concurrent_streams = max_concurrent_streams or getattr(
|
self.max_concurrent_streams = (
|
||||||
global_config.chat, "max_concurrent_distributions", 10
|
max_concurrent_streams or global_config.chat.max_concurrent_distributions
|
||||||
)
|
)
|
||||||
|
|
||||||
# Chatter管理器
|
# Chatter管理器
|
||||||
|
|||||||
@@ -158,6 +158,9 @@ class ChatConfig(ValidatedConfigBase):
|
|||||||
dynamic_distribution_jitter_factor: float = Field(
|
dynamic_distribution_jitter_factor: float = Field(
|
||||||
default=0.2, ge=0.0, le=0.5, description="分发间隔随机扰动因子"
|
default=0.2, ge=0.0, le=0.5, description="分发间隔随机扰动因子"
|
||||||
)
|
)
|
||||||
|
max_concurrent_distributions: int = Field(
|
||||||
|
default=10, ge=1, le=100, description="最大并发处理的消息流数量"
|
||||||
|
)
|
||||||
|
|
||||||
def get_current_talk_frequency(self, chat_stream_id: Optional[str] = None) -> float:
|
def get_current_talk_frequency(self, chat_stream_id: Optional[str] = None) -> float:
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[inner]
|
[inner]
|
||||||
version = "7.0.2"
|
version = "7.0.3"
|
||||||
|
|
||||||
#----以下是给开发人员阅读的,如果你只是部署了MoFox-Bot,不需要阅读----
|
#----以下是给开发人员阅读的,如果你只是部署了MoFox-Bot,不需要阅读----
|
||||||
#如果你想要修改配置文件,请递增version的值
|
#如果你想要修改配置文件,请递增version的值
|
||||||
@@ -131,6 +131,7 @@ dynamic_distribution_base_interval = 5.0 # 基础分发间隔(秒)
|
|||||||
dynamic_distribution_min_interval = 1.0 # 最小分发间隔(秒)
|
dynamic_distribution_min_interval = 1.0 # 最小分发间隔(秒)
|
||||||
dynamic_distribution_max_interval = 30.0 # 最大分发间隔(秒)
|
dynamic_distribution_max_interval = 30.0 # 最大分发间隔(秒)
|
||||||
dynamic_distribution_jitter_factor = 0.2 # 分发间隔随机扰动因子
|
dynamic_distribution_jitter_factor = 0.2 # 分发间隔随机扰动因子
|
||||||
|
max_concurrent_distributions = 10 # 最大并发处理的消息流数量,可以根据API性能和服务器负载调整
|
||||||
|
|
||||||
talk_frequency_adjust = [
|
talk_frequency_adjust = [
|
||||||
["", "8:00,1", "12:00,1.2", "18:00,1.5", "01:00,0.6"],
|
["", "8:00,1", "12:00,1.2", "18:00,1.5", "01:00,0.6"],
|
||||||
|
|||||||
Reference in New Issue
Block a user