mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-09 16:18:30 +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
|
||||
#!/usr/bin/env python
|
||||
import json
|
||||
import os
|
||||
from typing import List, Dict
|
||||
from pydantic import BaseModel, Field
|
||||
from crewai import LLM
|
||||
@@ -341,6 +342,9 @@ class GuideCreatorFlow(Flow[GuideCreatorState]):
|
||||
outline_dict = json.loads(response)
|
||||
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
|
||||
with open("output/guide_outline.json", "w") as f:
|
||||
json.dump(outline_dict, f, indent=2)
|
||||
|
||||
Reference in New Issue
Block a user