在config.py配置主人/机器人名字

This commit is contained in:
hissin
2022-12-20 23:30:54 +08:00
parent af76364619
commit c886f912ed
3 changed files with 16 additions and 6 deletions

3
.gitignore vendored
View File

@@ -2,4 +2,5 @@ config.py
.idea/
__pycache__/
database.db
qchatgpt.log
qchatgpt.log
config.py

View File

@@ -30,9 +30,13 @@ openai_config = {
},
}
# 管理员QQ号用于接收报错等通知为0时不发送通知
admin_qq = 0
# [可选] 机器人的配置
#user_name: 管理员(主人)的名字
#bot_name: 机器人的名字
user_name = 'You'
bot_name = 'Bot'
# [可选] 情景预设(机器人人格)
# 每个会话的预设信息,影响所有会话,无视指令重置
# 可以通过这个字段指定某些情况的回复,可直接用自然语言描述指令
# 例如: 如果我之后想获取帮助,请你说“输入!help获取帮助”
@@ -40,6 +44,9 @@ admin_qq = 0
# 可参考 https://github.com/PlexPt/awesome-chatgpt-prompts-zh
default_prompt = "如果我之后想获取帮助,请你说“输入!help获取帮助”"
# 管理员QQ号用于接收报错等通知为0时不发送通知
admin_qq = 0
# 群内响应规则
# 符合此消息的群内消息即使不包含at机器人也会响应
# 支持消息前缀匹配及正则表达式匹配

View File

@@ -53,7 +53,9 @@ def dump_session(session_name: str):
# 从配置文件获取会话预设信息
def get_default_prompt():
return "You:{}\nBot:好的\n".format(config.default_prompt) if hasattr(config, 'default_prompt') and \
user_name = config.user_name if hasattr(config, 'user_name') and config.user_name != '' else 'You'
bot_name = config.bot_name if hasattr(config, 'bot_name') and config.bot_name != '' else 'Bot'
return user_name+":{}\n"+bot_name+":好的\n".format(config.default_prompt) if hasattr(config, 'default_prompt') and \
config.default_prompt != "" else ''
@@ -81,8 +83,8 @@ class Session:
prompt = get_default_prompt()
user_name = 'You'
bot_name = 'Bot'
user_name = config.user_name if hasattr(config, 'user_name') and config.user_name != '' else 'You'
bot_name = config.bot_name if hasattr(config, 'bot_name') and config.bot_name != '' else 'Bot'
create_timestamp = 0