已按要求修改

This commit is contained in:
chordfish
2023-03-09 19:53:31 +08:00
parent 3b55f706de
commit 85d46089e3
3 changed files with 31 additions and 41 deletions

View File

@@ -149,12 +149,11 @@ class Session:
if config.preset_mode == "full_scenario":
import os
logging.info("A")
##
dir = os.path.join(os.getcwd(), config.full_prompt_dir)
json_file = os.path.join(dir, use_default) + '.json'
logging.info("B")
logging.info("try to load json: {}".format(json_file))
logging.debug("try to load json: {}".format(json_file))
try:
with open(json_file, 'r', encoding ='utf-8') as f:
@@ -257,18 +256,18 @@ class Session:
del (res_ans_spt[0])
res_ans = '\n\n'.join(res_ans_spt)
#检测是否包含ai人格否定
logging.debug('bot_filter: {}'.format(self.bot_filter))
if config.filter_ai_warning and self.bot_filter:
import re
match = re.search(self.bot_filter['reg'], res_ans)
logging.debug(self.bot_filter)
logging.debug(res_ans)
if match:
logging.debug('回复:{} 检测到人格否定,替换中。。'.format(res_ans))
res_ans = self.bot_filter['replace']
logging.debug('替换为: {}'.format(res_ans))
# 检测是否包含ai人格否定
# logging.debug('bot_filter: {}'.format(self.bot_filter))
# if config.filter_ai_warning and self.bot_filter:
# import re
# match = re.search(self.bot_filter['reg'], res_ans)
# logging.debug(self.bot_filter)
# logging.debug(res_ans)
# if match:
# logging.debug('回复:{} 检测到人格否定,替换中。。'.format(res_ans))
# res_ans = self.bot_filter['replace']
# logging.debug('替换为: {}'.format(res_ans))
# 将此次对话的双方内容加入到prompt中
self.prompt.append({'role': 'user', 'content': text})
self.prompt.append({'role': 'assistant', 'content': res_ans})