diff --git a/bot/chatgpt/chat_gpt_bot.py b/bot/chatgpt/chat_gpt_bot.py index 3ade252..e2d05c8 100644 --- a/bot/chatgpt/chat_gpt_bot.py +++ b/bot/chatgpt/chat_gpt_bot.py @@ -86,6 +86,7 @@ class ChatGPTBot(Bot,OpenAIImage): "top_p":1, "frequency_penalty":conf().get('frequency_penalty', 0.0), # [-2,2]之间,该值越大则更倾向于产生不同的内容 "presence_penalty":conf().get('presence_penalty', 0.0), # [-2,2]之间,该值越大则更倾向于产生不同的内容 + "request_timeout": conf().get('request_timeout', 30), # 请求超时时间 } def reply_text(self, session:ChatGPTSession, session_id, retry_count=0) -> dict: diff --git a/channel/chat_channel.py b/channel/chat_channel.py index 78b2775..2582b63 100644 --- a/channel/chat_channel.py +++ b/channel/chat_channel.py @@ -245,7 +245,7 @@ class ChatChannel(Channel): session_id = context['session_id'] with self.lock: if session_id not in self.sessions: - self.sessions[session_id] = (queue.Queue(), threading.BoundedSemaphore(1)) + self.sessions[session_id] = (queue.Queue(), threading.BoundedSemaphore(conf().get("concurrency_in_session", 1))) self.sessions[session_id][0].put(context) # 消费者函数,单独线程,用于从消息队列中取出消息并处理 diff --git a/config.py b/config.py index d455f45..1cdd6f1 100644 --- a/config.py +++ b/config.py @@ -27,6 +27,7 @@ available_setting = { "group_chat_in_one_session": ["ChatGPT测试群"], # 支持会话上下文共享的群名称 "trigger_by_self": False, # 是否允许机器人触发 "image_create_prefix": ["画", "看", "找"], # 开启图片回复的前缀 + "concurrency_in_session": 1, # 同一会话最多有多少条消息在处理中,大于1可能乱序 # chatgpt会话参数 "expires_in_seconds": 3600, # 无操作会话的过期时间 @@ -43,6 +44,7 @@ available_setting = { "top_p": 1, "frequency_penalty": 0, "presence_penalty": 0, + "request_timeout": 30, # chatgpt请求超时时间 # 语音设置 "speech_recognition": False, # 是否开启语音识别