Add semantic tagging, search, favourite/NSFW filtering, and LLM job queue

Replaces old list-format tags (which duplicated prompt content) with structured
dict tags per category (origin_series, outfit_type, participants, style_type,
scene_type, etc.). Tags are now purely organizational metadata — removed from
the prompt pipeline entirely.

Adds is_favourite and is_nsfw columns to all 8 resource models. Favourite is
DB-only (user preference); NSFW is mirrored in JSON tags for rescan persistence.
All library pages get filter controls and favourites-first sorting.

Introduces a parallel LLM job queue (_enqueue_task + _llm_queue_worker) for
background tag regeneration, with the same status polling UI as ComfyUI jobs.
Fixes call_llm() to use has_request_context() fallback for background threads.

Adds global search (/search) across resources and gallery images, with navbar
search bar. Adds gallery image sidecar JSON for per-image favourite/NSFW metadata.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Aodhan Collins
2026-03-21 03:22:09 +00:00
parent 7d79e626a5
commit 32a73b02f5
72 changed files with 3163 additions and 2212 deletions

View File

@@ -10,26 +10,32 @@
<form action="{{ url_for('create_character') }}" method="post">
<div class="mb-3">
<label for="name" class="form-label">Character Name</label>
<input type="text" class="form-control" id="name" name="name" placeholder="e.g. Cyberpunk Ninja" required>
<input type="text" class="form-control" id="name" name="name" placeholder="e.g. Cyberpunk Ninja" value="{{ form_data.get('name', '') }}" required>
</div>
<div class="mb-3">
<label for="filename" class="form-label">Filename (Slug) <small class="text-muted">- optional, auto-generated if empty</small></label>
<input type="text" class="form-control" id="filename" name="filename" placeholder="e.g. cyberpunk_ninja">
<input type="text" class="form-control" id="filename" name="filename" placeholder="e.g. cyberpunk_ninja" value="{{ form_data.get('filename', '') }}">
<div class="form-text">Used for the JSON file and URL. No spaces or special characters. Auto-generated from name if left empty.</div>
</div>
<div class="mb-3 form-check form-switch">
<input class="form-check-input" type="checkbox" id="use_llm" name="use_llm" checked>
<input class="form-check-input" type="checkbox" id="use_llm" name="use_llm" {{ 'checked' if form_data.get('use_llm', True) }}>
<label class="form-check-label" for="use_llm">Use AI to generate profile from description</label>
</div>
<div class="mb-3" id="prompt-group">
<label for="prompt" class="form-label">Description / Concept</label>
<textarea class="form-control" id="prompt" name="prompt" rows="5" placeholder="Describe the character's appearance, clothing, style, and personality. The AI will generate the full profile based on this."></textarea>
<textarea class="form-control" id="prompt" name="prompt" rows="5" placeholder="Describe the character's appearance, clothing, style, and personality. The AI will generate the full profile based on this.">{{ form_data.get('prompt', '') }}</textarea>
<div class="form-text">Required when AI generation is enabled.</div>
</div>
<div class="mb-3" id="wiki-url-group">
<label for="wiki_url" class="form-label">Wiki / Reference URL <small class="text-muted">- optional</small></label>
<input type="url" class="form-control" id="wiki_url" name="wiki_url" placeholder="e.g. https://finalfantasy.fandom.com/wiki/Tifa_Lockhart" value="{{ form_data.get('wiki_url', '') }}">
<div class="form-text">Fandom wiki URL or other character page. The AI will use this as reference for accurate appearance details.</div>
</div>
<div class="alert alert-info" id="ai-info">
<i class="bi bi-info-circle"></i> The AI will generate a complete character profile based on your description.
</div>
@@ -51,19 +57,22 @@
<script>
document.getElementById('use_llm').addEventListener('change', function() {
const promptGroup = document.getElementById('prompt-group');
const wikiUrlGroup = document.getElementById('wiki-url-group');
const aiInfo = document.getElementById('ai-info');
const manualInfo = document.getElementById('manual-info');
const submitBtn = document.getElementById('submit-btn');
const promptInput = document.getElementById('prompt');
if (this.checked) {
promptGroup.classList.remove('d-none');
wikiUrlGroup.classList.remove('d-none');
aiInfo.classList.remove('d-none');
manualInfo.classList.add('d-none');
submitBtn.textContent = 'Create & Generate';
promptInput.required = true;
} else {
promptGroup.classList.add('d-none');
wikiUrlGroup.classList.add('d-none');
aiInfo.classList.add('d-none');
manualInfo.classList.remove('d-none');
submitBtn.textContent = 'Create Character';