Dependency Detection¶
When analyzing CivitAI image generation data, the backend detects hidden dependencies that are not in the structured resources array but are embedded in the prompt text.
LoRA Tags in Prompts¶
LoRA references in positive prompts use the syntax <lora:Name:weight>. The _parse_lora_tags() function:
- Extracts all
<lora:Name:weight>patterns from the prompt - Returns a list of
{name, weight, source: "prompt"}objects - Also returns a clean prompt with all LoRA tags removed and whitespace collapsed
Example:
Produces:
- LoRAs:
[{name: "DetailTweaker", weight: 0.8}, {name: "FilmGrain", weight: 0.5}] - Clean prompt:
"a portrait of a woman, soft lighting"
Embeddings in Negative Prompts¶
Embeddings (textual inversions) are detected in the negative prompt by matching against the meta.resources array. The _parse_embeddings() function:
- Splits the negative prompt into lines
- Matches single tokens (alphanumeric with underscores/hyphens) against known resource names
- Returns detected embeddings with their hash if available
Resolution Pipeline¶
After detecting LoRAs and embeddings, the backend resolves each dependency:
- Hash lookup --
_resolve_by_hash()callshttps://civitai.com/api/v1/model-versions/by-hash/{hash}using the SHA256 hash frommeta.resources - Name search fallback --
_resolve_by_name()searcheshttps://civitai.com/api/v1/modelsby name with a 60% word overlap threshold - Catalog cross-reference -- each resolved dependency is checked against the local CivitAI map for catalog status
The enriched dependency objects include:
| Field | Description |
|---|---|
name |
Original name from prompt/negative |
source |
Where it was found: "prompt", "negative_prompt", or "meta_resources" |
hash |
SHA256 hash from meta.resources (if available) |
civitai_model_id |
Resolved CivitAI model ID |
civitai_version_id |
Resolved CivitAI version ID |
civitai_model_name |
Model name on CivitAI |
civitai_file |
Primary file name |
civitai_download_url |
Direct download URL |
catalog_status |
"present", "missing", "not_found", or "unknown" |