|
@@ -114,7 +114,8 @@ class PromptRetrievalNode(BaseNode):
|
|
|
logger.info(f"[Prompt-{self.dimension_id}] preceding_node中没有内容")
|
|
logger.info(f"[Prompt-{self.dimension_id}] preceding_node中没有内容")
|
|
|
# 检查模板中是否有{content}占位符
|
|
# 检查模板中是否有{content}占位符
|
|
|
if "{content}" in prompt_template:
|
|
if "{content}" in prompt_template:
|
|
|
- return prompt_template.format(content="")
|
|
|
|
|
|
|
+ # 使用replace而不是format,避免其他占位符导致KeyError
|
|
|
|
|
+ return prompt_template.replace("{content}", "")
|
|
|
else:
|
|
else:
|
|
|
return prompt_template
|
|
return prompt_template
|
|
|
|
|
|
|
@@ -138,7 +139,8 @@ class PromptRetrievalNode(BaseNode):
|
|
|
|
|
|
|
|
# 检查模板中是否有{content}占位符
|
|
# 检查模板中是否有{content}占位符
|
|
|
if "{content}" in prompt_template:
|
|
if "{content}" in prompt_template:
|
|
|
- return prompt_template.format(content=compressed_content)
|
|
|
|
|
|
|
+ # 使用replace而不是format,避免其他占位符导致KeyError
|
|
|
|
|
+ return prompt_template.replace("{content}", compressed_content)
|
|
|
else:
|
|
else:
|
|
|
# 如果没有占位符,直接返回模板(可能在模板末尾添加内容)
|
|
# 如果没有占位符,直接返回模板(可能在模板末尾添加内容)
|
|
|
return prompt_template
|
|
return prompt_template
|