fix(diffusers): keep negative_prompt unless negative embeds are set

The sd_embed branch dropped negative_prompt for every pipeline, which
discarded the user's negative prompt for Flux, where no negative embeds
are produced. Only drop it when negative_prompt_embeds is present, and
move the check to a helper that has unit tests.

Assisted-by: Claude Code:claude-sonnet-5-5
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
Ettore Di Giacinto committed 2026-10-13 08:08:24 +00:00
1 parent 5e53f5aed5
commit 8dd91dde66
3 files changed
+38 -5

No files matched your search

+23 -1
View File
@@ -2,7 +2,10 @@
import unittest
from backend.python.diffusers.load_options import single_file_load_kwargs
from backend.python.diffusers.load_options import (
drop_negative_prompt_if_embedded,
single_file_load_kwargs,
)
class SingleFileLoadKwargsTest(unittest.TestCase):
@@ -22,5 +25,24 @@ class SingleFileLoadKwargsTest(unittest.TestCase):
self.assertEqual(single_file_load_kwargs("", True), {})
class DropNegativePromptTest(unittest.TestCase):
def test_drops_negative_prompt_when_embeds_present(self):
kwargs = {"negative_prompt": "blurry", "negative_prompt_embeds": object()}
drop_negative_prompt_if_embedded(kwargs)
self.assertNotIn("negative_prompt", kwargs)
self.assertIn("negative_prompt_embeds", kwargs)
def test_keeps_negative_prompt_without_embeds(self):
kwargs = {"negative_prompt": "blurry", "prompt_embeds": object()}
drop_negative_prompt_if_embedded(kwargs)
self.assertEqual(kwargs["negative_prompt"], "blurry")
def test_no_negative_prompt_is_fine(self):
self.assertEqual(
drop_negative_prompt_if_embedded({"negative_prompt_embeds": 1}),
{"negative_prompt_embeds": 1},
)
if __name__ == "__main__":
unittest.main()