{"record":{"id":"7b50044af9d1129c","repo":"mudler/LocalAI","slug":"note-found-zu-loras-in-negative-prompt-may-not","errorCode":null,"errorMessage":"Note: Found %zu LoRAs in negative prompt (may not be supported)\\n","messagePattern":"Note: Found %zu LoRAs in negative prompt \\(may not be supported\\)\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"info","filePath":"backend/go/stablediffusion-ggml/cpp/gosd.cpp","lineNumber":764,"sourceCode":"    lora_vec.clear();\n    lora_strings.clear();\n\n    // Parse LoRAs from prompt\n    std::string prompt_str = prompt ? prompt : \"\";\n    std::string negative_prompt_str = negative_prompt ? negative_prompt : \"\";\n\n    // Get lora_dir from ctx_params if available, otherwise use stored path\n    const char* lora_dir_to_use = lora_dir_path.empty() ? nullptr : lora_dir_path.c_str();\n\n    auto [loras, cleaned_prompt] = parse_loras_from_prompt(prompt_str, lora_dir_to_use);\n    lora_vec = loras;\n    cleaned_prompt_storage = cleaned_prompt;\n\n    // Also check negative prompt for LoRAs (though this is less common)\n    auto [neg_loras, cleaned_negative] = parse_loras_from_prompt(negative_prompt_str, lora_dir_to_use);\n    // Merge negative prompt LoRAs (though typically not used)\n    if (!neg_loras.empty()) {\n        fprintf(stderr, \"Note: Found %zu LoRAs in negative prompt (may not be supported)\\n\", neg_loras.size());\n    }\n    cleaned_negative_prompt_storage = cleaned_negative;\n\n    // Set the cleaned prompts\n    params->prompt = cleaned_prompt_storage.c_str();\n    params->negative_prompt = cleaned_negative_prompt_storage.c_str();\n\n    // Set LoRAs in params\n    params->loras = lora_vec.empty() ? nullptr : lora_vec.data();\n    params->lora_count = static_cast<uint32_t>(lora_vec.size());\n\n    fprintf(stderr, \"Set prompts with %zu LoRAs. Original prompt: %s\\n\", lora_vec.size(), prompt ? prompt : \"(null)\");\n    fprintf(stderr, \"Cleaned prompt: %s\\n\", cleaned_prompt_storage.c_str());\n\n    // Debug: Verify LoRAs are set correctly\n    if (params->loras && params->lora_count > 0) {\n        fprintf(stderr, \"DEBUG: LoRAs set in params structure:\\n\");\n        for (uint32_t i = 0; i < params->lora_count; i++) {","sourceCodeStart":746,"sourceCodeEnd":782,"githubUrl":"https://github.com/mudler/LocalAI/blob/44413a9d06bf5bc52ce088ba8ca74e5a2e8bee26/backend/go/stablediffusion-ggml/cpp/gosd.cpp#L746-L782","documentation":"Informational note from the prompt setter: the negative prompt contained <lora:...> tags that were parsed and stripped. The parsed negative-prompt LoRAs are only logged, not merged into params->loras (only the positive prompt's LoRAs are applied), matching upstream behavior where LoRAs in negative prompts are typically ignored.","triggerScenarios":"Sending a request whose negative prompt includes LoRA tags, e.g. negative_prompt='blurry <lora:bad_hands:0.5>'; parse_loras_from_prompt runs on both prompts, and any hits in the negative side produce this note.","commonSituations":"Prompts imported from UIs that allow LoRAs in negative prompts; users expecting negative-prompt LoRAs to counteract styles, which this backend does not apply.","solutions":["Move needed LoRA tags into the positive prompt — negative-prompt LoRAs are not applied","Or remove them from the negative prompt to silence the note and keep prompts clean","If counteracting a style, lower the LoRA multiplier in the positive prompt instead"],"exampleFix":"// before\nprompt: \"a cat\"\nnegative_prompt: \"bad hands <lora:sketchy:0.6>\"  // logged, not applied\n\n// after\nprompt: \"a cat\"\nnegative_prompt: \"bad hands\"","handlingStrategy":"validation","validationCode":"// Go caller: reject LoRA tags in negative prompts explicitly\nif loraTag.MatchString(req.NegativePrompt) {\n    return fmt.Errorf(\"negative prompt cannot contain <lora:...> tags; they are not applied\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Strip or reject LoRA tags in negative prompts at the API edge so users are not surprised they have no effect","Document that only positive-prompt LoRAs are applied"],"tags":["stablediffusion","lora","prompt-parsing","negative-prompt"],"backgroundTag":null,"analyzedSha":"44413a9d06bf5bc52ce088ba8ca74e5a2e8bee26","analyzedAt":"2026-08-15T10:13:50.291Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}