AI poetry generator — Streamlit web app that generates poems on demand using Langchain with OpenAI GPT or local LLama models.
🌐 Live Demo: https://ai-poet-moony.streamlit.app/
AI Poet is a Streamlit-based web app that generates original poems using Langchain. The app supports two LLM backends — OpenAI's GPT (via API) and Meta's LLama 2 (local inference) — and lets you switch between them seamlessly.
- ✍️ AI-Generated Poetry — Theme-driven poem generation
- 🔄 Dual LLM Backend — Switch between OpenAI GPT (cloud) and LLama 2 (local)
- 🔒 Local Inference Option — Run LLama 2 fully offline, no API key needed
- ⚡ Streaming Output — Real-time token streaming for live poem display
- 🐍 Single-File App — Minimal Streamlit codebase, easy to fork
| Layer | Technology |
|---|---|
| Web Framework | Streamlit |
| LLM Orchestration | Langchain |
| LLMs | OpenAI GPT (cloud), Meta LLama 2 (local) |
| Language | Python 3.9 |
- Python 3.9 (Download)
git clone https://github.com/moony01/ai-poet.git
cd ai-poet
pip install -r requirements.txt
# Add your OpenAI API key to .env
echo "OPENAI_API_KEY=sk-..." > .env
streamlit run main.pyOpen the URL printed in the terminal (usually http://localhost:8501).
- Download a quantized LLama 2 GGML model (e.g.
llama-2-7b-chat.ggmlv3.q2_K.bin) - Place it in the project root
- Run:
streamlit run llama.py
ai-poet/
├── main.py # OpenAI-backed Streamlit app
├── llama.py # Local LLama 2 Streamlit app
├── requirements.txt # Python dependencies
└── .devcontainer/ # VSCode dev container config
MIT License © 2024–2026 moony01
You are free to use, modify, and distribute this code. Attribution appreciated.
- 👤 Author: @moony01
- 📧 Email: mun01180@gmail.com
- 🌐 Website: moony01.com
- 💖 Sponsor: github.com/sponsors/moony01