use multi-line to avoid yaml parsing error
This commit is contained in:
parent
26fd2d2cfc
commit
2b45e97514
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue