A Streamlit-based AI Agent built using LangGraph that transforms Python scripts into structured, human-readable blog posts. The agent uses LLMs to understand code, structure content, and iteratively draft each section, all with human-in-the-loop feedback.
Link to medium blog
- 🔍 Understands uploaded Python code files
- 🧾 Generates a blog outline structure
- ✍️ Drafts each section individually using LLMs
- 🔁 Accepts human feedback on blog structure and drafts
- 📄 Outputs a final blog once all sections are approved
This project uses LangGraph to model a multistep agent with interruptible nodes and memory:
Python Code → Code Summary → Blog Structure → Feedback Loop → Draft Sections → Feedback Loop → Final Blog
code_understanding
: Summarizes uploaded Python codeblog_structuring
: Proposes an outlinehuman_blog_feedback
: Requests approval or revision of outlinesection_drafting
: Generates individual section draftssection_drafting_feedback
: Requests feedback on each sectionset_next_section
: Tracks and selects the next section to draft
main.py
: Streamlit app interfaceblog_graph.py
: LangGraph pipeline setupnodes.py
: Core logic for summarization, structuring, drafting, and feedback handlingblog_state.py
: Typed state for LangGraphfunctions.py
: Utilities (e.g., for loading code)requirements.txt
: All required Python packages
- Clone the Repository
git clone https://github.com/nagi1995/blog-drafting-ai-agent.git
cd blog-drafting-ai-agent
-
Download and Install Miniconda
Install Miniconda from the link.
-
Create a Conda Environment
conda create --name blog_drafting_ai_agent python=3.12.9 -y
conda activate blog_drafting_ai_agent
- Install Dependencies
pip install -r requirements.txt
- Create a .env file with necessary credentials
GROQ_API_KEY=your_groq_api_key
Launch the web interface with:
streamlit run main.py
Features:
- Upload .py files directly
- Review blog structure and draft sections
- Provide feedback via text input
- Automatically compiles final blog draft
Run the agent in a terminal:
python blog_graph.py