promptPreprocessor.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.promptPreprocessor = promptPreprocessor;
const SYSTEM_RULES = `\
[System: Image Generation Plugin]
You have tools to generate images via Hugging Face.
== TOOL ROUTING ==
⢠User asks to generate/draw/create/paint/visualize something ā generate_image
⢠User asks what models are available ā list_models
== GENERATION TIPS ==
- Descriptive prompts produce better results. Include: subject, style, lighting, mood, quality terms.
Good: "a futuristic city at night, neon lights, rain reflections, cinematic, 4k, detailed"
Bad: "city"
- Use negative_prompt to exclude unwanted elements: "blurry, low quality, text, watermark, distorted"
- FLUX.1-schnell: fastest free option. SDXL: larger, more detailed. SD 1.5: fast, huge community.
- First call to an inactive model may take 20-60s on HF free tier ā this is normal.
- If you get a 403 on FLUX.1, tell the user to accept the model license at huggingface.co first.
== AFTER GENERATION ==
Always report the full file path where the image was saved and the model used.`;
async function promptPreprocessor(ctl, userMessage) {
const history = await ctl.pullHistory();
const isFirstTurn = history.length === 0;
if (isFirstTurn) {
history.append("system", SYSTEM_RULES);
}
history.append(userMessage);
return userMessage;
}