Improve LLM client immutability and CI model defaults.
Replace mutable Ollama model export with a const fallback and initializeModel return value, resolving the model from the environment after optional API discovery. Use a for-of loop over attempt indices instead of let in the retry path. Continue PDF generation when map image generation or upscaling fails, and avoid mutating request headers in place. Document Open WebUI-style URLs in the README, pin OLLAMA_MODEL in the Gitea release workflow, and adjust integration and unit tests for the new initialization behavior.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
[](https://ci.keligrubb.com/repos/2)
|
||||
|
||||
Scrollsmith is a Node.js tool for generating Dungeons & Dragons one-page dungeon PDFs automatically. It uses an Ollama LLM server to create dungeon content, proofreads and refines it, then formats it into a structured PDF with maps, rooms, encounters, treasure, and NPCs.
|
||||
Scrollsmith is a Node.js tool for generating Dungeons & Dragons one-page dungeon PDFs automatically. It calls an LLM (Open WebUI `/api/chat/completions` or Ollama `/api/generate`, inferred from `OLLAMA_API_URL`), proofreads and refines the result, then builds a structured PDF with maps, rooms, encounters, treasure, and NPCs.
|
||||
|
||||
---
|
||||
|
||||
@@ -14,20 +14,21 @@ Scrollsmith is a Node.js tool for generating Dungeons & Dragons one-page dungeon
|
||||
3. JSON conversion: output strictly valid JSON for PDF generation
|
||||
- Automatically generates a PDF named after the dungeon title
|
||||
- PDF layout includes three columns: map & hooks, rooms, encounters & treasure & NPCs
|
||||
- Easy to integrate with a local Ollama server
|
||||
- Open WebUI or Ollama
|
||||
|
||||
---
|
||||
|
||||
## Requirements
|
||||
|
||||
- Node.js 22+
|
||||
- Ollama server running and accessible
|
||||
- LLM endpoint (see below)
|
||||
- Gitea Releases (optional) for PDF uploads
|
||||
- `.env` file with:
|
||||
|
||||
```env
|
||||
OLLAMA_API_URL=http://localhost:3000/api/chat/completions
|
||||
OLLAMA_API_URL=https://your-openwebui-host/api/chat/completions
|
||||
OLLAMA_API_KEY=your_api_key_here
|
||||
OLLAMA_MODEL=qwen3.5-122b-a10b
|
||||
COMFYUI_URL=http://192.168.1.124:8188
|
||||
```
|
||||
|
||||
@@ -56,17 +57,18 @@ OLLAMA_API_URL=http://localhost:11434/api/generate
|
||||
### Open WebUI API
|
||||
For Open WebUI API calls, set:
|
||||
```env
|
||||
OLLAMA_API_URL=http://localhost:3000/api/chat/completions
|
||||
OLLAMA_API_URL=https://your-openwebui-host/api/chat/completions
|
||||
OLLAMA_API_KEY=your_open_webui_api_key
|
||||
OLLAMA_MODEL=qwen3.5-122b-a10b
|
||||
```
|
||||
|
||||
> Note: The API type is automatically inferred from the endpoint URL. If the URL contains `/api/chat/completions`, it uses Open WebUI API. If it contains `/api/generate`, it uses direct Ollama API. No `OLLAMA_API_TYPE` environment variable is required.
|
||||
> Note: The API type is inferred from the URL (`/api/chat/completions` vs `/api/generate`); no `OLLAMA_API_TYPE` variable.
|
||||
|
||||
---
|
||||
|
||||
## Usage
|
||||
|
||||
1. Make sure your Ollama server is running and `.env` is configured.
|
||||
1. Configure `.env` and ensure the LLM endpoint is reachable.
|
||||
2. Run:
|
||||
|
||||
```bash
|
||||
@@ -81,7 +83,7 @@ Optional: update the map path in `index.js` if you have a local dungeon map.
|
||||
|
||||
## Project structure
|
||||
|
||||
- **`index.js`** – Entry point: loads env, initializes the Ollama model, runs dungeon generation, image generation, and PDF output.
|
||||
- **`index.js`** – Entry point: env, model init, dungeon + image + PDF.
|
||||
- **`src/`** – Application modules:
|
||||
- `dungeonGenerator.js` – LLM-backed dungeon content generation and validation.
|
||||
- `dungeonTemplate.js` – HTML template and layout for the PDF.
|
||||
@@ -105,7 +107,7 @@ Optional: update the map path in `index.js` if you have a local dungeon map.
|
||||
|
||||
## Notes
|
||||
|
||||
* Make sure your Ollama server is accessible and API key is valid.
|
||||
* Open WebUI needs a valid `OLLAMA_API_KEY` when the server requires it.
|
||||
* Dungeon generation can take a few minutes depending on your LLM response time.
|
||||
|
||||
---
|
||||
|
||||
Reference in New Issue
Block a user