feat: 更改到process.py处理长消息

This commit is contained in:
Rock Chin
2023-03-15 20:33:44 +08:00
parent 651d765ab0
commit 179a372bfe
3 changed files with 4 additions and 2 deletions
+1 -1
View File
@@ -66,7 +66,7 @@ def check_text(text: str) -> list:
"""检查文本是否为长消息,并转换成该使用的消息链组件""" """检查文本是否为长消息,并转换成该使用的消息链组件"""
if not hasattr(config, 'blob_message_threshold'): if not hasattr(config, 'blob_message_threshold'):
return [text] return [text]
if len(text) > config.blob_message_threshold: if len(text) > config.blob_message_threshold:
if not hasattr(config, 'blob_message_strategy'): if not hasattr(config, 'blob_message_strategy'):
raise AttributeError('未定义长消息处理策略') raise AttributeError('未定义长消息处理策略')
+1 -1
View File
@@ -63,7 +63,7 @@ def process_normal_message(text_message: str, mgr, config, launcher_type: str,
reply = event.get_return_value("reply") reply = event.get_return_value("reply")
if not event.is_prevented_default(): if not event.is_prevented_default():
reply = blob.check_text(prefix + text) reply = prefix + text
except openai.error.APIConnectionError as e: except openai.error.APIConnectionError as e:
err_msg = str(e) err_msg = str(e)
if err_msg.__contains__('Error communicating with OpenAI'): if err_msg.__contains__('Error communicating with OpenAI'):
+2
View File
@@ -26,6 +26,7 @@ import pkg.plugin.host as plugin_host
import pkg.plugin.models as plugin_models import pkg.plugin.models as plugin_models
import pkg.qqbot.ignore as ignore import pkg.qqbot.ignore as ignore
import pkg.qqbot.banlist as banlist import pkg.qqbot.banlist as banlist
import pkg.qqbot.blob as blob
processing = [] processing = []
@@ -157,6 +158,7 @@ def process_message(launcher_type: str, launcher_id: int, text_message: str, mes
reply[0][:min(100, len(reply[0]))] + ( reply[0][:min(100, len(reply[0]))] + (
"..." if len(reply[0]) > 100 else ""))) "..." if len(reply[0]) > 100 else "")))
reply = [mgr.reply_filter.process(reply[0])] reply = [mgr.reply_filter.process(reply[0])]
reply = blob.check_text(reply[0])
else: else:
logging.info("回复[{}]消息".format(session_name)) logging.info("回复[{}]消息".format(session_name))