mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-05-03 08:12:39 +00:00
Create output folder if it doesn't exits (#2573)
When running this project, I got an error because the output folder had not been created. I added a line to check if the output folder exists and create it if needed.
This commit is contained in:
@@ -263,6 +263,7 @@ Let's create our flow in the `main.py` file:
|
|||||||
```python
|
```python
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
import json
|
import json
|
||||||
|
import os
|
||||||
from typing import List, Dict
|
from typing import List, Dict
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
from crewai import LLM
|
from crewai import LLM
|
||||||
@@ -341,6 +342,9 @@ class GuideCreatorFlow(Flow[GuideCreatorState]):
|
|||||||
outline_dict = json.loads(response)
|
outline_dict = json.loads(response)
|
||||||
self.state.guide_outline = GuideOutline(**outline_dict)
|
self.state.guide_outline = GuideOutline(**outline_dict)
|
||||||
|
|
||||||
|
# Ensure output directory exists before saving
|
||||||
|
os.makedirs("output", exist_ok=True)
|
||||||
|
|
||||||
# Save the outline to a file
|
# Save the outline to a file
|
||||||
with open("output/guide_outline.json", "w") as f:
|
with open("output/guide_outline.json", "w") as f:
|
||||||
json.dump(outline_dict, f, indent=2)
|
json.dump(outline_dict, f, indent=2)
|
||||||
|
|||||||
Reference in New Issue
Block a user