add concurrency_in_session,request_timeout options

This commit is contained in:
lanvent
2023-04-04 13:33:01 +08:00
parent 5a221848e9
commit 371e38cfa6
3 changed files with 4 additions and 1 deletions

View File

@@ -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:

View File

@@ -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)
# 消费者函数,单独线程,用于从消息队列中取出消息并处理

View File

@@ -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, # 是否开启语音识别