use multi-line to avoid yaml parsing error

This commit is contained in:
zachary62 2025-04-23 11:13:55 -04:00
parent 26fd2d2cfc
commit 2b45e97514
1 changed files with 6 additions and 8 deletions

View File

@ -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