From 2b45e975146d2e151d68b032c04a38674a761c1c Mon Sep 17 00:00:00 2001 From: zachary62 Date: Wed, 23 Apr 2025 11:13:55 -0400 Subject: [PATCH] use multi-line to avoid yaml parsing error --- cookbook/pocketflow-workflow/nodes.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/cookbook/pocketflow-workflow/nodes.py b/cookbook/pocketflow-workflow/nodes.py index 3597e7a..24e8f1a 100644 --- a/cookbook/pocketflow-workflow/nodes.py +++ b/cookbook/pocketflow-workflow/nodes.py @@ -16,17 +16,15 @@ Output the sections in YAML format as shown below: ```yaml sections: - - First section - - Second section - - Third section + - | + First section + - | + Second section + - | + Third section ```""" 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