Skip to content

Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks.

Create output folder if it doesn't exits (#2573)

Jesse R Weigel4bff5408d870
diff --git a/docs/guides/flows/first-flow.mdx b/docs/guides/flows/first-flow.mdx
index ab03693b9..cb10de275 100644
--- a/docs/guides/flows/first-flow.mdx
+++ b/docs/guides/flows/first-flow.mdx
@@ -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)