iuiaoin / wechat-gptbot

A wechat robot based on ChatGPT with no risk, very stable! 🚀
MIT License
579 stars 113 forks source link

[Bug]: config加载问题 #103

Open QAbot-zh opened 8 months ago

QAbot-zh commented 8 months ago

Search for answers in existing issues

Python version

python 3.8

Issue description

不同的类的启动顺序影响config正确加载,有些用到config参数的类启动比较早,config还没有加载完成,导致其初始化使用的并不是config.json里的参数,比如下图中的情况: image

Repro steps

No response

Relevant log output

No response

ic4y commented 6 months ago

厉害,能顺便修复下这个问题吗,提个pr @QAbot-zh

QAbot-zh commented 6 months ago

厉害,能顺便修复下这个问题吗,提个pr @QAbot-zh

我有个简单粗暴的方法,就是可能不优雅,不知道有没有更好的方法:

''' app.py '''
from config import load_config, load_prompts
load_config()   # 优先所有import执行

from utils.log import logger
from utils.print import color_print
from plugins.manager import PluginManager
from channel.wechat import WeChatChannel