DreamWiki
A single-file, AI-generated Wikipedia clone that creates fictional encyclopedia articles on-demand using Large Language Models via the OpenRouter API.
Overview
DreamWiki is a creative web application that generates Wikipedia-style articles about anything you can imagine. When you visit a non-existent page, the application queries an LLM to generate a complete, interconnected article with links to other fictional pages, creating an ever-expanding universe of AI-generated lore.
Note: This is a creative experiment. All content is fictional and generated by AI.
Features
- <¯ Single-file Python application for easy deployment
-
AI-generated articles via OpenRouter API
- =Ý Wikipedia-style formatting with Markdown
- = Automatic internal linking between articles
- <¨ Clean, Wikipedia-inspired interface
- =¾ Persistent article storage as Markdown files
- = Search functionality to explore any topic
Prerequisites
- Python 3.13+
- UV package manager
- OpenRouter API account and key
Quick Start
-
Clone and enter the project directory:
cd /path/to/aignorance
-
Install dependencies using UV:
uv add fastapi uvicorn python-dotenv requests markdown2 jinja2
-
Set up your environment:
cp .env.example .env
Edit
.env
and add your OpenRouter credentials:OPENROUTER_API_KEY=your_actual_api_key_here OPENROUTER_MODEL=mistralai/mistral-7b-instruct
-
Run the application:
uv run uvicorn app:app --reload
-
Open your browser: Visit
http://localhost:8000
and start exploring!
Configuration
Environment Variables
OPENROUTER_API_KEY
: Your OpenRouter API key (get one at https://openrouter.ai/)OPENROUTER_MODEL
: The model to use for generation
Supported Models
Any OpenRouter-compatible model works. Popular choices:
mistralai/mistral-7b-instruct
(fast, creative)anthropic/claude-3-haiku
(high quality, more expensive)openai/gpt-3.5-turbo
(balanced performance)
How It Works
- User visits
/wiki/Some_Topic
- If the article doesn't exist, DreamWiki calls the OpenRouter API
- The LLM generates a complete Markdown article with:
- Multiple sections (History, Characteristics, etc.)
- Internal links to other fictional articles
- At least one table
- A placeholder image
- The article is saved locally and rendered as HTML
- Future visits to the same topic load the cached version
File Structure
aignorance/
app.py # Single-file application
.env # Your configuration (create from .env.example)
.env.example # Configuration template
README.md # This file
pyproject.toml # Project metadata
pages/ # Generated articles (created automatically)
topic_1.md
topic_2.md
...
Development
The application uses FastAPI with automatic reload:
uv run uvicorn app:app --reload --host 0.0.0.0 --port 8000
Generated articles are stored in the pages/
directory as Markdown files with slugified filenames.
API Endpoints
GET /
- Home page with search functionalityGET /wiki/{page_title}
- View or generate a wiki article
Technical Details
- Framework: FastAPI for the web server
- Templating: Jinja2 for HTML rendering
- Markdown: markdown2 for converting articles to HTML
- Storage: Local filesystem (Markdown files)
- Styling: Inline CSS mimicking Wikipedia's appearance
Troubleshooting
"API Key not configured" error:
- Ensure your
.env
file exists and contains validOPENROUTER_API_KEY
"Failed to generate article" error:
- Check your internet connection
- Verify your OpenRouter API key is valid
- Ensure you have sufficient credits on OpenRouter
Module not found errors:
- Run
uv add
to install all dependencies - Ensure you're using
uv run
to execute the application
License
This project is a creative experiment. Feel free to use, modify, and share!