From 9b2da6c431be6c5b3f37b0b25821ed861b3467b8 Mon Sep 17 00:00:00 2001 From: lichengzhe <38408577@qq.com> Date: Sun, 19 Mar 2023 01:10:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=85=E9=99=A4=E8=AE=B0=E5=BF=86=E5=91=BD?= =?UTF-8?q?=E4=BB=A4=E5=92=8CAPI=E8=B0=83=E7=94=A8=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E6=94=B9=E4=B8=BAconfig.json=E9=85=8D=E7=BD=AE=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bot/chatgpt/chat_gpt_bot.py | 9 +++++---- config-template.json | 15 --------------- 2 files changed, 5 insertions(+), 19 deletions(-) delete mode 100644 config-template.json diff --git a/bot/chatgpt/chat_gpt_bot.py b/bot/chatgpt/chat_gpt_bot.py index be2fa67..b5c2a5b 100644 --- a/bot/chatgpt/chat_gpt_bot.py +++ b/bot/chatgpt/chat_gpt_bot.py @@ -27,7 +27,8 @@ class ChatGPTBot(Bot): if not context or not context.get('type') or context.get('type') == 'TEXT': logger.info("[OPEN_AI] query={}".format(query)) session_id = context.get('session_id') or context.get('from_user_id') - if query == '#清除记忆': + clear_memory_commands = conf().get('clear_memory_commands', ['#清除记忆']) + if query in clear_memory_commands: Session.clear_session(session_id) return '记忆已清除' elif query == '#清除所有': @@ -65,11 +66,11 @@ class ChatGPTBot(Bot): response = openai.ChatCompletion.create( model= conf().get("model") or "gpt-3.5-turbo", # 对话模型的名称 messages=session, - temperature=0.9, # 值在[0,1]之间,越大表示回复越具有不确定性 + temperature=conf().get('temperature', 0.9), # 值在[0,1]之间,越大表示回复越具有不确定性 #max_tokens=4096, # 回复最大的字符数 top_p=1, - frequency_penalty=0.0, # [-2,2]之间,该值越大则更倾向于产生不同的内容 - presence_penalty=0.0, # [-2,2]之间,该值越大则更倾向于产生不同的内容 + frequency_penalty=conf().get('frequency_penalty', 0.0), # [-2,2]之间,该值越大则更倾向于产生不同的内容 + presence_penalty=conf().get('presence_penalty', 0.0), # [-2,2]之间,该值越大则更倾向于产生不同的内容 ) # logger.info("[ChatGPT] reply={}, total_tokens={}".format(response.choices[0]['message']['content'], response["usage"]["total_tokens"])) return {"total_tokens": response["usage"]["total_tokens"], diff --git a/config-template.json b/config-template.json deleted file mode 100644 index 154cb9e..0000000 --- a/config-template.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "open_ai_api_key": "YOUR API KEY", - "model": "gpt-3.5-turbo", - "proxy": "", - "single_chat_prefix": ["bot", "@bot"], - "single_chat_reply_prefix": "[bot] ", - "group_chat_prefix": ["@bot"], - "group_name_white_list": ["ChatGPT测试群", "ChatGPT测试群2"], - "image_create_prefix": ["画", "看", "找"], - "speech_recognition": false, - "voice_reply_voice": false, - "conversation_max_tokens": 1000, - "expires_in_seconds": 3600, - "character_desc": "你是ChatGPT, 一个由OpenAI训练的大型语言模型, 你旨在回答并解决人们的任何问题,并且可以使用多种语言与人交流。" -}