LLM-powered article generator built with LangChain and OpenAI.
A modular, OOP-based pipeline that takes high-level constraints and produces a fully-structured article — table of contents → outlines → sections → title → optional self-critique pass.
article_generator/
├── article/ # Article model
├── paragraph/ # Paragraph + Resource models
└── article_generator/
├── article_generator.py # Main orchestrator
└── prompts.py # LangChain PromptTemplate factories
- Generate table of contents from a title
- Generate outlines for each section (what to include / exclude)
- Generate contents for each section
- Generate the final title
- Optional self-critique pass
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
cp .env.example .env # then add your OPENAI_API_KEYfrom article_generator import ArticleGenerator
from article_generator.article import Article
from article_generator.paragraph import Paragraph
from langchain.chat_models import ChatOpenAI
llm = ChatOpenAI(model="gpt-3.5-turbo-16k", temperature=0.7, max_tokens=8000)
article = Article(title="", paragraphs=[Paragraph(index=1, header="")])
gen = ArticleGenerator(llm=llm, article=article)
print(gen.complete().to_markdown())See main.py and sample.py for full examples.
- Python 3.10+
- LangChain
- OpenAI
- ChromaDB (optional, for resource grounding)
MIT