mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-06-02 00:57:41 +08:00
feat: add debug option
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -10,3 +10,4 @@ nohup.out
|
|||||||
tmp
|
tmp
|
||||||
plugins.json
|
plugins.json
|
||||||
itchat.pkl
|
itchat.pkl
|
||||||
|
*.log
|
||||||
@@ -8,6 +8,10 @@ def _get_logger():
|
|||||||
console_handle = logging.StreamHandler(sys.stdout)
|
console_handle = logging.StreamHandler(sys.stdout)
|
||||||
console_handle.setFormatter(logging.Formatter('[%(levelname)s][%(asctime)s][%(filename)s:%(lineno)d] - %(message)s',
|
console_handle.setFormatter(logging.Formatter('[%(levelname)s][%(asctime)s][%(filename)s:%(lineno)d] - %(message)s',
|
||||||
datefmt='%Y-%m-%d %H:%M:%S'))
|
datefmt='%Y-%m-%d %H:%M:%S'))
|
||||||
|
file_handle = logging.FileHandler('run.log', encoding='utf-8')
|
||||||
|
file_handle.setFormatter(logging.Formatter('[%(levelname)s][%(asctime)s][%(filename)s:%(lineno)d] - %(message)s',
|
||||||
|
datefmt='%Y-%m-%d %H:%M:%S'))
|
||||||
|
log.addHandler(file_handle)
|
||||||
log.addHandler(console_handle)
|
log.addHandler(console_handle)
|
||||||
return log
|
return log
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
# encoding:utf-8
|
# encoding:utf-8
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
from common.log import logger
|
from common.log import logger
|
||||||
|
|
||||||
@@ -38,7 +39,6 @@ available_setting = {
|
|||||||
"rate_limit_chatgpt": 20, # chatgpt的调用频率限制
|
"rate_limit_chatgpt": 20, # chatgpt的调用频率限制
|
||||||
"rate_limit_dalle": 50, # openai dalle的调用频率限制
|
"rate_limit_dalle": 50, # openai dalle的调用频率限制
|
||||||
|
|
||||||
|
|
||||||
# chatgpt api参数 参考https://platform.openai.com/docs/api-reference/chat/create
|
# chatgpt api参数 参考https://platform.openai.com/docs/api-reference/chat/create
|
||||||
"temperature": 0.9,
|
"temperature": 0.9,
|
||||||
"top_p": 1,
|
"top_p": 1,
|
||||||
@@ -82,6 +82,7 @@ available_setting = {
|
|||||||
# channel配置
|
# channel配置
|
||||||
"channel_type": "wx", # 通道类型,支持wx,wxy和terminal
|
"channel_type": "wx", # 通道类型,支持wx,wxy和terminal
|
||||||
|
|
||||||
|
"debug": False, # 是否开启debug模式,开启后会打印更多日志
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,6 +140,10 @@ def load_config():
|
|||||||
else:
|
else:
|
||||||
config[name] = value
|
config[name] = value
|
||||||
|
|
||||||
|
if config["debug"]:
|
||||||
|
logger.setLevel(logging.DEBUG)
|
||||||
|
logger.debug("[INIT] set log level to DEBUG")
|
||||||
|
|
||||||
logger.info("[INIT] load config: {}".format(config))
|
logger.info("[INIT] load config: {}".format(config))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user