From 1a64be5031dd91a7883695d5757c9f94a8b82061 Mon Sep 17 00:00:00 2001 From: guwt Date: Wed, 23 Apr 2025 16:53:35 +0800 Subject: [PATCH] fix yaml parse error Use re to handle the unexpected conversion of colons in the yaml format --- cookbook/pocketflow-workflow/nodes.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cookbook/pocketflow-workflow/nodes.py b/cookbook/pocketflow-workflow/nodes.py index 041dfd4..3597e7a 100644 --- a/cookbook/pocketflow-workflow/nodes.py +++ b/cookbook/pocketflow-workflow/nodes.py @@ -1,3 +1,4 @@ +import re from pocketflow import Node, BatchNode from utils import call_llm import yaml @@ -21,6 +22,11 @@ sections: ```""" response = call_llm(prompt) yaml_str = response.split("```yaml")[1].split("```")[0].strip() + yaml_str = re.sub( + r'(?m)^(\s*)-\s*([^"\n]+)', + r'\1- "\2"', + yaml_str + ) structured_result = yaml.safe_load(yaml_str) return structured_result