Skip to content

Commit

Permalink
Merge pull request #100 from LlmKira/dev
Browse files Browse the repository at this point in the history
🔧 refactor(generate_image): remove quality modifier attribute
  • Loading branch information
sudoskys authored Jan 5, 2025
2 parents 904bf85 + 27adc28 commit 8759efe
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 41 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ async def main():
sampler=Sampler.K_EULER_ANCESTRAL,
ucPreset=UCPreset.TYPE0,
# Recommended, using preset negative_prompt depends on selected model
qualitySuffix=True,
qualityToggle=True,
decrisp_mode=False,
variety_boost=True,
Expand Down
2 changes: 1 addition & 1 deletion playground/generate_voice.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pydantic import SecretStr

from novelai_python import VoiceGenerate, VoiceResponse, JwtCredential, APIError
from novelai_python.sdk.ai.generate_voice import VoiceSpeakerV2, VoiceSpeakerV1
from novelai_python.sdk.ai.generate_voice import VoiceSpeakerV2
from novelai_python.utils.useful import enum_to_list

load_dotenv()
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "novelai-python"
version = "0.7.3"
version = "0.7.4"
description = "NovelAI Python Binding With Pydantic"
authors = [
{ name = "sudoskys", email = "[email protected]" },
Expand Down
37 changes: 12 additions & 25 deletions src/novelai_python/sdk/ai/generate_image/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,18 @@ def add_image_to_black_background(

class GenerateImageInfer(ApiBaseModel):
_endpoint: str = PrivateAttr("https://image.novelai.net")
"""Endpoint"""

@property
def endpoint(self):
return self._endpoint

@endpoint.setter
def endpoint(self, value):
self._endpoint = value

_mutual_exclusion: bool = PrivateAttr(False)
"""Positive words and negative words are mutually exclusive, and conflicting negative words are deleted first."""
_quality_modifier: bool = PrivateAttr(True)
"""Add Quality Modifier To Input"""

def set_mutual_exclusion(self, value: bool):
"""
Expand All @@ -361,27 +369,6 @@ def set_mutual_exclusion(self, value: bool):
self._mutual_exclusion = bool(value)
return self

def set_quality_modifier(self, value: bool):
"""
**Enable This will modify the input prompt.**
Default is True.
Add Quality Modifier To Input.
Whether to add the quality vocabulary used by the web application.
:param value:
:return:
"""
self._quality_modifier = bool(value)
return self

@property
def endpoint(self):
return self._endpoint

@endpoint.setter
def endpoint(self, value):
self._endpoint = value

action: Union[str, Action] = Field(Action.GENERATE, description="Mode for img generate")
input: str = "1girl, best quality, amazing quality, very aesthetic, absurdres"
model: ModelTypeAlias = "nai-diffusion-3"
Expand Down Expand Up @@ -467,8 +454,8 @@ def enhance_message(_prompt):
)
return _prompt

if self._quality_modifier:
logger.trace("Enhancing input with quality modifier, will modify input prompt.")
if self.parameters.qualityToggle:
logger.trace("Enhancing input with qualityToggle, will modify input prompt.")
self.input = enhance_message(self.input)

if self._mutual_exclusion:
Expand Down
2 changes: 1 addition & 1 deletion src/novelai_python/sdk/ai/generate_voice/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def build(cls,
return cls(
text=text,
seed=speaker.seed,
voice=speaker.voice,
voice=speaker.sid,
opus=opus,
version=speaker.version
)
Expand Down
24 changes: 12 additions & 12 deletions src/novelai_python/sdk/ai/generate_voice/_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,30 @@ class Speaker(BaseModel):
"""
Speaker for /ai/generated_voice
"""
voice: int = -1
sid: int = -1
seed: str = "kurumuz12"
name: str
category: str

@property
def version(self):
return "v2" if self.voice == -1 else "v1"
return "v2" if self.sid == -1 else "v1"


class VoiceSpeakerV1(Enum):
"""
Speaker for /ai/generated_voice
"""
Cyllene = Speaker(voice=17, name="Cyllene", category="female")
Leucosia = Speaker(voice=95, name="Leucosia", category="female")
Crina = Speaker(voice=44, name="Crina", category="female")
Hespe = Speaker(voice=80, name="Hespe", category="female")
Ida = Speaker(voice=106, name="Ida", category="female")
Alseid = Speaker(voice=6, name="Alseid", category="male")
Daphnis = Speaker(voice=10, name="Daphnis", category="male")
Echo = Speaker(voice=16, name="Echo", category="male")
Thel = Speaker(voice=41, name="Thel", category="male")
Nomios = Speaker(voice=77, name="Nomios", category="male")
Cyllene = Speaker(sid=17, name="Cyllene", category="female")
Leucosia = Speaker(sid=95, name="Leucosia", category="female")
Crina = Speaker(sid=44, name="Crina", category="female")
Hespe = Speaker(sid=80, name="Hespe", category="female")
Ida = Speaker(sid=106, name="Ida", category="female")
Alseid = Speaker(sid=6, name="Alseid", category="male")
Daphnis = Speaker(sid=10, name="Daphnis", category="male")
Echo = Speaker(sid=16, name="Echo", category="male")
Thel = Speaker(sid=41, name="Thel", category="male")
Nomios = Speaker(sid=77, name="Nomios", category="male")
# SeedInput = Speaker(sid=-1, name="Seed Input", category="custom")


Expand Down

0 comments on commit 8759efe

Please sign in to comment.