Merge pull request #40 from gwtt/gwtt
fix pocketflow-workflow yaml parse error
This commit is contained in:
commit
26fd2d2cfc
|
|
@ -1,3 +1,4 @@
|
||||||
|
import re
|
||||||
from pocketflow import Node, BatchNode
|
from pocketflow import Node, BatchNode
|
||||||
from utils import call_llm
|
from utils import call_llm
|
||||||
import yaml
|
import yaml
|
||||||
|
|
@ -21,6 +22,11 @@ sections:
|
||||||
```"""
|
```"""
|
||||||
response = call_llm(prompt)
|
response = call_llm(prompt)
|
||||||
yaml_str = response.split("```yaml")[1].split("```")[0].strip()
|
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)
|
structured_result = yaml.safe_load(yaml_str)
|
||||||
return structured_result
|
return structured_result
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue