ソースを参照

19维度图书解析流程调整-提示词替换调整

yingge 3 ヶ月 前
コミット
a618b8563e
1 ファイル変更4 行追加2 行削除
  1. 4 2
      src/datasets/parser/nodes/prompt_retrieval_node.py

+ 4 - 2
src/datasets/parser/nodes/prompt_retrieval_node.py

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