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 @@ import "dotenv/config";
|
||||
import { generateDungeon } from "./src/dungeonGenerator.js";
|
||||
import { generateDungeonImages } from "./src/imageGenerator.js";
|
||||
import { generatePDF } from "./src/generatePDF.js";
|
||||
import { OLLAMA_MODEL, initializeModel } from "./src/ollamaClient.js";
|
||||
import { initializeModel } from "./src/ollamaClient.js";
|
||||
|
||||
// Utility to create a filesystem-safe filename from the dungeon title
|
||||
function slugify(text) {
|
||||
@@ -18,18 +18,15 @@ function slugify(text) {
|
||||
throw new Error("OLLAMA_API_URL environment variable is required");
|
||||
}
|
||||
console.log("Using Ollama API URL:", process.env.OLLAMA_API_URL);
|
||||
|
||||
// Initialize model (will fetch default from API or use fallback)
|
||||
await initializeModel();
|
||||
console.log("Using Ollama model:", OLLAMA_MODEL);
|
||||
|
||||
const model = await initializeModel();
|
||||
console.log("Using Ollama model:", model);
|
||||
|
||||
// Generate the dungeon data
|
||||
const dungeonData = await generateDungeon();
|
||||
|
||||
// Generate dungeon map image (uses dungeonData.flavor)
|
||||
const mapPath = await generateDungeonImages(dungeonData);
|
||||
|
||||
dungeonData.map = mapPath;
|
||||
if (mapPath) dungeonData.map = mapPath;
|
||||
|
||||
// Generate PDF filename based on the title
|
||||
const filename = `${slugify(dungeonData.title)}.pdf`;
|
||||
|
||||
Reference in New Issue
Block a user