A static site generator that creates content via LLMs instead of humans.
The Rat News Network Generator is a Python-based pipeline that:
- Generates rat news articles using OpenAI's GPT models
- Creates accompanying images using DALL-E
- Renders content into a static website using Jinja2 templates
- Deploys the site to GitHub Pages via CI/CD
The system follows a three-stage pipeline:
┌─────────────┐ ┌──────────────┐ ┌─────────────┐ ┌─────────────┐
│ Content │ │ Site │ │ GitHub │ │ Published │
│ Generation │────▶│ Generation │────▶│ Repository │────▶│ Website │
│ (gen.py) │ │(templater.py)│ │ Deployment │ │ │
└─────────────┘ └──────────────┘ └─────────────┘ └─────────────┘
The main components are:
- deploy.py: Main entry point that orchestrates the entire pipeline
- gen.py: Content generation engine using LLMs
- templater.py: Renders content into HTML using Jinja2 templates
# GitHub Personal Access Token for automated deployment
export GITHUB_PAT="your-github-personal-access-token"
# OpenAI API Key for content and image generation
export OPENAI_API_KEY="your-openai-api-key"
# News API Key (required for parody article generation)
export NEWS_API_KEY="your-newsapi-org-key"- Clone the repository
- Install dependencies:
pip install -r requirements.txt - Set up environment variables as described above
- Run the generator (see Usage Instructions below)
articlegen/
├── deploy.py # Main entry point and deployment script
├── gen.py # Content generation engine
├── templater.py # Site generation and templating
├── text_processing.py # Text utilities
├── util.py # General utilities
├── job.py # Scheduled job functionality
├── docs/ # Documentation
├── prompts/ # LLM prompt templates
├── src/ # More source modules
├── templates/ # Jinja2 HTML templates and other static site files
└── tests/ # Unit tests
The main command to use this static site generator is:
python deploy.py [options]
--num: Number of articles to generate (default is 0)--articles: Directory to save or load articles--branch: Branch to deploy to (default is 'main')--repo: URL of the repository to deploy to (default is https://github.com/davidhaas6/rat-news-network-frontend.git)--keep-local: Keep the local repository after deployment (flag, no value needed)--auto: Automatically deploy without user input (flag, no value needed)
To generate three new articles and push them to the 'test' branch of the default repository:
python deploy.py --num 3 --branch test
To push existing articles from a specific directory to the 'test' branch:
python deploy.py --articles my/article/dir/ --branch test
To generate three articles and deploy them to a different repository:
python deploy.py --num 3 --repo https://github.com/username/my-static-frontent.git
To generate five articles, including two parody articles based on real news:
python deploy.py --num 5 --branch main
To generate articles and deploy without prompting for confirmation:
python deploy.py --num 3 --auto
- If
--numis set to 0, the script will use existing articles from the specified--articlesdirectory. - The
--keep-localflag can be added to any command to retain the local copy of the repository after deployment. - Always ensure you have the necessary permissions for the target repository before deploying.
- When generating multiple articles (>2), the system automatically includes parody articles based on real news.
gen.py is the core content generation script in the rat news generator. It provides several functions for generating different parts of an article or complete articles.
python gen.py [action] [parameters]
-
Generate Article Ideas
python gen.py idea [number_of_ideas]- Generates the specified number of article ideas.
- If number_of_ideas is not provided, it defaults to 1.
-
Generate Full Article
python gen.py full [idea]- Generates a complete article based on the provided idea.
- The idea should be a string describing the article concept.
-
Generate Article Image
python gen.py image [title] [outline]- Generates an image for an article based on its title and outline.
-
Generate Article from Topic
python gen.py topic [topic_idea]- Generates an article based on a given topic idea.
-
Generate Parody Articles
python gen.py parody [number_of_articles]- Generates parody articles based on real news stories.
- Requires NEWS_API_KEY environment variable to be set.
-
Generate 5 article ideas:
python gen.py idea 5 -
Generate a full article:
python gen.py full "The impact of cheese scarcity on rat economy" -
Generate an image for an article:
python gen.py image "Whisker Fashion Trends" "Latest styles in rat whisker grooming" -
Generate an article from a topic:
python gen.py topic "Underground tunnel expansion project in Ratopolis" -
Generate 3 parody articles based on current news:
python gen.py parody 3
- More interactivity
- Enabling the users to further interact with and customize the site
- Generating non-RNN content
- i.e. use some other system to create the prompts that gen.py uses, for topics or publications other than Rat News Network.
For more detailed technical information, refer to the following documentation:
- ARCHITECTURE.md - Detailed technical architecture
- parody.md - Parody system documentation
- subscribe.md - Subscription feature documentation