fix: 移除了分段回复llm提示词辅助
This commit is contained in:
@@ -29,7 +29,6 @@ DEFAULT_CONFIG = {
|
||||
"enable": False,
|
||||
"only_llm_result": True,
|
||||
"interval": "1.5,3.5",
|
||||
"seg_prompt": "",
|
||||
"regex": ".*?[。?!~…]+|.+$"
|
||||
},
|
||||
"no_permission_reply": True,
|
||||
@@ -219,11 +218,6 @@ CONFIG_METADATA_2 = {
|
||||
"type": "string",
|
||||
"hint": "每一段回复的间隔时间,格式为 `最小时间,最大时间`。如 `0.75,2.5`",
|
||||
},
|
||||
"seg_prompt": {
|
||||
"description": "分段提示词辅助",
|
||||
"type": "string",
|
||||
"hint": "此项为空时表达不启用这个方法。此方法会调用一次LLM请求。让 LLM 在某一句话中插入一个可以用正则表达式分隔的标记,来实现LLM基于情感分段。如: `请基于情感对以下文本进行分段, 并在两段之间添加`<seg>`以便我用正则匹配。` 然后将下面的正则表达式更换为`.+?<seg>`。",
|
||||
},
|
||||
"regex": {
|
||||
"description": "正则表达式",
|
||||
"type": "string",
|
||||
|
||||
@@ -30,7 +30,6 @@ class ResultDecorateStage:
|
||||
# 分段回复
|
||||
self.enable_segmented_reply = ctx.astrbot_config['platform_settings']['segmented_reply']['enable']
|
||||
self.only_llm_result = ctx.astrbot_config['platform_settings']['segmented_reply']['only_llm_result']
|
||||
self.seg_prompt = ctx.astrbot_config['platform_settings']['segmented_reply']['seg_prompt']
|
||||
self.regex = ctx.astrbot_config['platform_settings']['segmented_reply']['regex']
|
||||
|
||||
async def process(self, event: AstrMessageEvent) -> Union[None, AsyncGenerator[None, None]]:
|
||||
@@ -57,19 +56,6 @@ class ResultDecorateStage:
|
||||
new_chain = []
|
||||
for comp in result.chain:
|
||||
if isinstance(comp, Plain):
|
||||
|
||||
if self.seg_prompt:
|
||||
try:
|
||||
llm_resp = await self.ctx.plugin_manager.context.get_using_provider().text_chat(
|
||||
prompt=f"{self.seg_prompt}\n{comp.text}",
|
||||
)
|
||||
comp.text = llm_resp.completion_text
|
||||
except BaseException as e:
|
||||
traceback.print_exc()
|
||||
logger.warning("使用 LLM 分段回复失败。将不分段回复。: " + str(e))
|
||||
new_chain.append(comp)
|
||||
continue
|
||||
|
||||
split_response = re.findall(self.regex, comp.text)
|
||||
if not split_response:
|
||||
new_chain.append(comp)
|
||||
|
||||
Reference in New Issue
Block a user