Merge pull request #563 from iorisa/merge/geekan/main_to_env_refactor

fixbug: single line block cause error
This commit is contained in:
geekan
2023-12-15 11:37:02 +08:00
committed by GitHub
2 changed files with 8 additions and 3 deletions
+1 -1
View File
@@ -99,7 +99,7 @@ class WriteTasks(Action):
async def _merge(self, system_design_doc, task_doc, format=CONFIG.prompt_format) -> Document:
context = NEW_REQ_TEMPLATE.format(context=system_design_doc.content, old_tasks=task_doc.content)
node = await PM_NODE.fill(context, self.llm, format)
task_doc.content = node.content
task_doc.content = node.instruct_content.json(ensure_ascii=False)
return task_doc
@staticmethod
+7 -2
View File
@@ -223,10 +223,15 @@ class CodeParser:
# 遍历所有的block
for block in blocks:
# 如果block不为空,则继续处理
if block.strip() != "":
if block.strip() == "":
continue
if "\n" not in block:
block_title = block
block_content = ""
else:
# 将block的标题和内容分开,并分别去掉前后的空白字符
block_title, block_content = block.split("\n", 1)
block_dict[block_title.strip()] = block_content.strip()
block_dict[block_title.strip()] = block_content.strip()
return block_dict