GenWiki is a small Flask web application that creates Wikipedia-style pages for any topic. It searches DuckDuckGo for source snippets and images, sends the collected context to a fixed Ollama model, and renders a clean article with citations, pictures, references, and internal See also links.
The model is fixed on the server side. Users cannot change it from the web UI or by adding a ?model=... parameter to the URL.
- DuckDuckGo text search for source snippets
- DuckDuckGo image search with SafeSearch and unsafe-domain filtering
- Ollama-based article generation
- Wikipedia-like article layout
- Source references and citation markers
- Internal GenWiki See also links, for example
/wiki?topic=Kubernetes - Debug and health pages for troubleshooting
- Windows, Linux, and macOS runner scripts
- Detailed logs in
logs/genwiki.log
- Python 3.10 or newer
- Ollama installed and running
- Internet access for DuckDuckGo search and image results
- An available Ollama model, for example:
ollama pull gemma4:31b-cloudStart Ollama in a separate terminal if it is not already running:
ollama serveTest Ollama quickly:
curl http://localhost:11434/api/generate -d '{"model":"gemma4:31b-cloud","prompt":"Reply only with OK.","stream":false}'Open PowerShell in the project folder and run:
powershell -ExecutionPolicy Bypass -File .\run_windows.ps1Then open:
http://127.0.0.1:5000
Open cmd.exe in the project folder and run:
run_windows.batThen open:
http://127.0.0.1:5000
Open a terminal in the project folder and run:
chmod +x run_linux.sh
./run_linux.shThen open:
http://127.0.0.1:5000
The runner scripts use these stable settings:
| Variable | Value | Purpose |
|---|---|---|
OLLAMA_HOST |
http://localhost:11434 |
Ollama server URL |
GENWIKI_MODEL |
gemma4:31b-cloud |
Fixed server-side model |
GENWIKI_REQUEST_TIMEOUT |
300 |
Ollama timeout in seconds |
GENWIKI_MAX_SOURCES |
4 |
Number of DuckDuckGo text sources |
GENWIKI_MAX_IMAGES |
4 |
Number of images shown |
GENWIKI_NUM_CTX |
262144 |
Ollama context size |
GENWIKI_NUM_PREDICT |
650 |
Maximum generated output tokens |
GENWIKI_STREAM |
1 |
Use Ollama streaming responses |
GENWIKI_SAFE_IMAGES |
1 |
Filter unsafe image results |
GENWIKI_REGION |
wt-wt |
DuckDuckGo search region |
GENWIKI_LOG_LEVEL |
DEBUG |
Detailed logs |
FLASK_DEBUG |
1 |
Flask debug mode |
PORT |
5000 |
Local web server port |
The web UI and URL parameters cannot change GENWIKI_MODEL. To change the model, edit the server-side runner script or .env file before starting the app.
Create and activate a virtual environment:
python -m venv .venvWindows PowerShell:
.\.venv\Scripts\Activate.ps1Windows Command Prompt:
.venv\Scripts\activate.batLinux/macOS:
source .venv/bin/activateInstall dependencies:
python -m pip install --upgrade pip
pip install -r requirements.txtSet the environment variables and start the app:
Windows PowerShell:
$env:OLLAMA_HOST="http://localhost:11434"
$env:GENWIKI_MODEL="gemma4:31b-cloud"
$env:GENWIKI_REQUEST_TIMEOUT="300"
$env:GENWIKI_MAX_SOURCES="4"
$env:GENWIKI_MAX_IMAGES="4"
$env:GENWIKI_NUM_CTX="262144"
$env:GENWIKI_NUM_PREDICT="650"
$env:GENWIKI_STREAM="1"
$env:GENWIKI_SAFE_IMAGES="1"
$env:GENWIKI_REGION="wt-wt"
$env:GENWIKI_LOG_LEVEL="DEBUG"
$env:FLASK_DEBUG="1"
$env:PORT="5000"
python genwiki.pyLinux/macOS:
export OLLAMA_HOST="http://localhost:11434"
export GENWIKI_MODEL="gemma4:31b-cloud"
export GENWIKI_REQUEST_TIMEOUT="300"
export GENWIKI_MAX_SOURCES="4"
export GENWIKI_MAX_IMAGES="4"
export GENWIKI_NUM_CTX="262144"
export GENWIKI_NUM_PREDICT="650"
export GENWIKI_STREAM="1"
export GENWIKI_SAFE_IMAGES="1"
export GENWIKI_REGION="wt-wt"
export GENWIKI_LOG_LEVEL="DEBUG"
export FLASK_DEBUG="1"
export PORT="5000"
python genwiki.pyYou can copy .env.example to .env and edit it:
Windows PowerShell:
Copy-Item .env.example .env
python genwiki.pyLinux/macOS:
cp .env.example .env
python genwiki.pyThe app loads .env automatically when it starts.
Main page:
http://127.0.0.1:5000
Generate a page directly:
http://127.0.0.1:5000/wiki?topic=OpenShift
Diagnostics page:
http://127.0.0.1:5000/debug
JSON health check:
http://127.0.0.1:5000/health
The app writes logs to:
logs/genwiki.log
Watch logs live on Windows PowerShell:
Get-Content .\logs\genwiki.log -WaitWatch logs live on Linux/macOS:
tail -f logs/genwiki.logCheck the debug page first:
http://127.0.0.1:5000/debug
Then check the log file:
logs/genwiki.log
Common causes:
- Ollama is not running.
- The model is not available in Ollama.
- The model takes longer than the configured timeout.
- Another old Flask process is still using port
5000. - The computer does not have enough memory for the selected model/context size.
Get-Process python | Stop-ProcessThen restart:
powershell -ExecutionPolicy Bypass -File .\run_windows.ps1pkill -f genwiki.pyThen restart:
./run_linux.shA short curl prompt may finish quickly, while GenWiki sends a longer prompt with source snippets, citations, and HTML instructions. Keep streaming enabled, keep source count small, and increase GENWIKI_REQUEST_TIMEOUT if needed.
genwiki.py Main Flask application
requirements.txt Python dependencies
README.md Project documentation
.env.example Example environment configuration
.gitignore Git ignore rules
run_windows.ps1 Windows PowerShell runner
run_windows.bat Windows Command Prompt runner
run_linux.sh Linux/macOS runner
templates/ Flask HTML templates
static/ CSS and static assets
logs/ Runtime logs, ignored by Git
- DuckDuckGo snippets are used as grounding context, but important facts should still be verified before publishing.
- Images are loaded from external search result URLs. Check image licenses before public use.
- Safe image filtering blocks obvious unsafe results, but no web image filter is perfect.
- The maintained DuckDuckGo Python package is imported as
ddgs; the code also supports the olderduckduckgo_searchimport as a fallback.
