Skip to content

Commit

Permalink
Merge pull request #145 from Ikaros-521/owner
Browse files Browse the repository at this point in the history
新增 念用户名的功能,例:回复xxx。你好;新增用户名过滤(违禁词、链接、拼音);新增本地问答库匹配 最低相似度配置,用于微调需要的关键词匹配度,已自定义触发灵敏度。
  • Loading branch information
Ikaros-521 authored Jul 20, 2023
2 parents 5153ad1 + c573230 commit 0499dca
Show file tree
Hide file tree
Showing 9 changed files with 873 additions and 702 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,10 @@ cmd输入命令即可:`doctoc /path/to/file`
- 文案模式增加了一组文案配置,也就是说有2块文案,会进行左右切换的播放,都播放完毕后会进行新的一轮播放。
- 新增LLM后的第二重过滤(违禁词、链接、拼音)
- 违禁拼音配置内容需要是中文,需要注意,已更正
- 新增 念用户名的功能,例:回复xxx。你好
- 新增用户名过滤(违禁词、链接、拼音)
- 修复本地问答音频匹配,传入音频后缀导致的匹配错误bug
- 新增本地问答库匹配 最低相似度配置,用于微调需要的关键词匹配度,已自定义触发灵敏度。

</details>

Expand Down
577 changes: 296 additions & 281 deletions UI_main.py

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"before_prompt": "请简要回复:",
"after_prompt": "",
"commit_log_type": "回答",
"read_user_name": true,
"filter": {
"before_must_str": [],
"after_must_str": [],
Expand Down Expand Up @@ -137,7 +138,8 @@
"audio": {
"enable": true,
"file_path": "out/本地问答音频/"
}
},
"similarity": 0.5
},
"choose_song": {
"enable": true,
Expand Down
4 changes: 3 additions & 1 deletion config.json.bak
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"before_prompt": "请简要回复:",
"after_prompt": "",
"commit_log_type": "回答",
"read_user_name": true,
"filter": {
"before_must_str": [],
"after_must_str": [],
Expand Down Expand Up @@ -137,7 +138,8 @@
"audio": {
"enable": true,
"file_path": "out/本地问答音频/"
}
},
"similarity": 0.5
},
"choose_song": {
"enable": true,
Expand Down
10 changes: 10 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ def init_config(self):
self.ui.label_before_prompt.setToolTip("提示词前缀,会自带追加在弹幕前,主要用于追加一些特殊的限制")
self.ui.label_after_prompt.setToolTip("提示词后缀,会自带追加在弹幕后,主要用于追加一些特殊的限制")
self.ui.label_commit_log_type.setToolTip("弹幕日志类型,用于记录弹幕触发时记录的内容,默认只记录回答,降低当用户使用弹幕日志显示在直播间时,因为用户的不良弹幕造成直播间被封禁问题")
self.ui.label_read_user_name.setToolTip("是否启用回复用户弹幕时,念用户的昵称,例:回复xxx。你好")

self.ui.label_captions_enable.setToolTip("是否启用字幕日志记录,字幕输出内容为当前合成播放的音频的文本")
self.ui.label_captions_file_path.setToolTip("字幕日志存储路径")
Expand All @@ -266,6 +267,7 @@ def init_config(self):
self.ui.label_local_qa_text_file_path.setToolTip("本地问答文本数据存储路径")
self.ui.label_local_qa_audio_enable.setToolTip("是否启用本地问答音频匹配,部分命中音频文件名后,直接播放对应的音频文件")
self.ui.label_local_qa_audio_file_path.setToolTip("本地问答音频文件存储路径")
self.ui.label_local_qa_similarity.setToolTip("最低文本匹配相似度,就是说用户发送的内容和本地问答库中设定的内容的最低相似度。\n低了就会被当做一般弹幕处理")

self.ui.label_filter_before_must_str.setToolTip("弹幕过滤,必须携带的触发前缀字符串(任一)\n例如:配置#,那么就需要发送:#你好")
self.ui.label_filter_after_must_str.setToolTip("弹幕过滤,必须携带的触发后缀字符串(任一)\n例如:配置。那么就需要发送:你好。")
Expand Down Expand Up @@ -482,12 +484,16 @@ def init_config(self):
self.ui.lineEdit_before_prompt.setText(self.before_prompt)
self.ui.lineEdit_after_prompt.setText(self.after_prompt)

if config.get("read_user_name"):
self.ui.checkBox_read_user_name.setChecked(True)

self.ui.comboBox_commit_log_type.clear()
commit_log_types = ["问答", "问题", "回答", "不记录"]
self.ui.comboBox_commit_log_type.addItems(commit_log_types)
commit_log_type_index = commit_log_types.index(self.commit_log_type)
self.ui.comboBox_commit_log_type.setCurrentIndex(commit_log_type_index)


# 日志
if self.captions_config['enable']:
self.ui.checkBox_captions_enable.setChecked(True)
Expand All @@ -500,6 +506,7 @@ def init_config(self):
if self.local_qa_config['audio']['enable']:
self.ui.checkBox_local_qa_audio_enable.setChecked(True)
self.ui.lineEdit_local_qa_audio_file_path.setText(self.local_qa_config['audio']['file_path'])
self.ui.lineEdit_local_qa_similarity.setText(str(self.local_qa_config['similarity']))

tmp_str = ""
for tmp in self.filter_config['before_must_str']:
Expand Down Expand Up @@ -964,6 +971,8 @@ def save(self):
config_data["before_prompt"] = self.ui.lineEdit_before_prompt.text()
config_data["after_prompt"] = self.ui.lineEdit_after_prompt.text()

config_data["read_user_name"] = self.ui.checkBox_read_user_name.isChecked()

need_lang = self.ui.comboBox_need_lang.currentText()
if need_lang == "所有":
config_data["need_lang"] = "none"
Expand All @@ -985,6 +994,7 @@ def save(self):
config_data["local_qa"]["text"]["file_path"] = self.ui.lineEdit_local_qa_text_file_path.text()
config_data["local_qa"]["audio"]["enable"] = self.ui.checkBox_local_qa_audio_enable.isChecked()
config_data["local_qa"]["audio"]["file_path"] = self.ui.lineEdit_local_qa_audio_file_path.text()
config_data["local_qa"]["similarity"] = round(float(self.ui.lineEdit_local_qa_similarity.text()), 2)

# 通用多行分隔符
separators = [" ", "\n"]
Expand Down
Loading

0 comments on commit 0499dca

Please sign in to comment.