Skip to content

Commit

Permalink
✨ feat(generate_image): improve handling of negative prompts
Browse files Browse the repository at this point in the history
  • Loading branch information
sudoskys committed Jan 3, 2025
1 parent 7f64ed5 commit a139de3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/novelai_python/sdk/ai/generate_image/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,15 +403,18 @@ def model_post_init(self, *args) -> None:
# Add negative prompt based on ucPreset
if self.parameters.ucPreset is not None:
uc_preset = self.parameters.ucPreset

# If ucPreset is Enum, get the value
if isinstance(self.parameters.ucPreset, Enum):
uc_preset = self.parameters.ucPreset.value
default_negative_prompt = get_default_uc_preset(self.model, uc_preset)

# Lowres means we don't found any negative prompt.
# If the default negative prompt is lowres, and the user has set a negative prompt,
# then the default negative prompt is not added.
if self.parameters.negative_prompt and default_negative_prompt == "lowres":
# Lowres means we don't found any negative prompt.
# If the default negative prompt is lowres, and the user has set a negative prompt,
# then the default negative prompt is not added.
default_negative_prompt = ""

# Combine the negative prompt preset and the user's negative prompt
self.parameters.negative_prompt = ", ".join(
filter(None, [default_negative_prompt, self.parameters.negative_prompt])
Expand Down

0 comments on commit a139de3

Please sign in to comment.