Procházet zdrojové kódy

fix: chat_time_module compatible logic

zhayujie před 3 roky
rodič
revize
ae06cf844d
2 změnil soubory, kde provedl 6 přidání a 10 odebrání
  1. 3 4
      common/time_check.py
  2. 3 6
      config-template.json

+ 3 - 4
common/time_check.py

@@ -5,11 +5,10 @@ from common.log import logger
 def time_checker(f):
     def _time_checker(self, *args, **kwargs):
         _config = config.conf()
-        chat_time_module = _config["chat_time_module"]
-        chat_start_time = _config["chat_start_time"]
-        chat_stopt_time = _config["chat_stop_time"]
-
+        chat_time_module = _config.get("chat_time_module", False)
         if chat_time_module:
+            chat_start_time = _config.get("chat_start_time", "00:00")
+            chat_stopt_time = _config.get("chat_stop_time", "24:00")
             time_regex = re.compile(r'^([01]?[0-9]|2[0-4])(:)([0-5][0-9])$')  #时间匹配,包含24:00
 
             starttime_format_check = time_regex.match(chat_start_time)  # 检查停止时间格式

+ 3 - 6
config-template.json

@@ -1,4 +1,4 @@
- {
+{
    "open_ai_api_key": "YOUR API KEY",
    "model": "gpt-3.5-turbo",
    "proxy": "",
@@ -11,9 +11,6 @@
    "voice_reply_voice": false,
    "conversation_max_tokens": 1000,
    "expires_in_seconds": 3600,
-   "character_desc": "你是ChatGPT, 一个由OpenAI训练的大型语言模型, 你旨在回答并解决人们的任何问题,并且可以使用多种语言与人交流。",
-   "chat_time_module": false,
-   "chat_start_time": "00:00",
-   "chat_stop_time": "24:00"   
- }
+   "character_desc": "你是ChatGPT, 一个由OpenAI训练的大型语言模型, 你旨在回答并解决人们的任何问题,并且可以使用多种语言与人交流。"
+}