Skip to content

Commit 8759efe

Browse files
authored
Merge pull request #100 from LlmKira/dev
🔧 refactor(generate_image): remove quality modifier attribute
2 parents 904bf85 + 27adc28 commit 8759efe

File tree

6 files changed

+27
-41
lines changed

6 files changed

+27
-41
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ async def main():
6464
sampler=Sampler.K_EULER_ANCESTRAL,
6565
ucPreset=UCPreset.TYPE0,
6666
# Recommended, using preset negative_prompt depends on selected model
67-
qualitySuffix=True,
6867
qualityToggle=True,
6968
decrisp_mode=False,
7069
variety_boost=True,

playground/generate_voice.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from pydantic import SecretStr
77

88
from novelai_python import VoiceGenerate, VoiceResponse, JwtCredential, APIError
9-
from novelai_python.sdk.ai.generate_voice import VoiceSpeakerV2, VoiceSpeakerV1
9+
from novelai_python.sdk.ai.generate_voice import VoiceSpeakerV2
1010
from novelai_python.utils.useful import enum_to_list
1111

1212
load_dotenv()

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "novelai-python"
3-
version = "0.7.3"
3+
version = "0.7.4"
44
description = "NovelAI Python Binding With Pydantic"
55
authors = [
66
{ name = "sudoskys", email = "[email protected]" },

src/novelai_python/sdk/ai/generate_image/__init__.py

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -344,10 +344,18 @@ def add_image_to_black_background(
344344

345345
class GenerateImageInfer(ApiBaseModel):
346346
_endpoint: str = PrivateAttr("https://image.novelai.net")
347+
"""Endpoint"""
348+
349+
@property
350+
def endpoint(self):
351+
return self._endpoint
352+
353+
@endpoint.setter
354+
def endpoint(self, value):
355+
self._endpoint = value
356+
347357
_mutual_exclusion: bool = PrivateAttr(False)
348358
"""Positive words and negative words are mutually exclusive, and conflicting negative words are deleted first."""
349-
_quality_modifier: bool = PrivateAttr(True)
350-
"""Add Quality Modifier To Input"""
351359

352360
def set_mutual_exclusion(self, value: bool):
353361
"""
@@ -361,27 +369,6 @@ def set_mutual_exclusion(self, value: bool):
361369
self._mutual_exclusion = bool(value)
362370
return self
363371

364-
def set_quality_modifier(self, value: bool):
365-
"""
366-
**Enable This will modify the input prompt.**
367-
Default is True.
368-
369-
Add Quality Modifier To Input.
370-
Whether to add the quality vocabulary used by the web application.
371-
:param value:
372-
:return:
373-
"""
374-
self._quality_modifier = bool(value)
375-
return self
376-
377-
@property
378-
def endpoint(self):
379-
return self._endpoint
380-
381-
@endpoint.setter
382-
def endpoint(self, value):
383-
self._endpoint = value
384-
385372
action: Union[str, Action] = Field(Action.GENERATE, description="Mode for img generate")
386373
input: str = "1girl, best quality, amazing quality, very aesthetic, absurdres"
387374
model: ModelTypeAlias = "nai-diffusion-3"
@@ -467,8 +454,8 @@ def enhance_message(_prompt):
467454
)
468455
return _prompt
469456

470-
if self._quality_modifier:
471-
logger.trace("Enhancing input with quality modifier, will modify input prompt.")
457+
if self.parameters.qualityToggle:
458+
logger.trace("Enhancing input with qualityToggle, will modify input prompt.")
472459
self.input = enhance_message(self.input)
473460

474461
if self._mutual_exclusion:

src/novelai_python/sdk/ai/generate_voice/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def build(cls,
107107
return cls(
108108
text=text,
109109
seed=speaker.seed,
110-
voice=speaker.voice,
110+
voice=speaker.sid,
111111
opus=opus,
112112
version=speaker.version
113113
)

src/novelai_python/sdk/ai/generate_voice/_enum.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,30 @@ class Speaker(BaseModel):
77
"""
88
Speaker for /ai/generated_voice
99
"""
10-
voice: int = -1
10+
sid: int = -1
1111
seed: str = "kurumuz12"
1212
name: str
1313
category: str
1414

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

1919

2020
class VoiceSpeakerV1(Enum):
2121
"""
2222
Speaker for /ai/generated_voice
2323
"""
24-
Cyllene = Speaker(voice=17, name="Cyllene", category="female")
25-
Leucosia = Speaker(voice=95, name="Leucosia", category="female")
26-
Crina = Speaker(voice=44, name="Crina", category="female")
27-
Hespe = Speaker(voice=80, name="Hespe", category="female")
28-
Ida = Speaker(voice=106, name="Ida", category="female")
29-
Alseid = Speaker(voice=6, name="Alseid", category="male")
30-
Daphnis = Speaker(voice=10, name="Daphnis", category="male")
31-
Echo = Speaker(voice=16, name="Echo", category="male")
32-
Thel = Speaker(voice=41, name="Thel", category="male")
33-
Nomios = Speaker(voice=77, name="Nomios", category="male")
24+
Cyllene = Speaker(sid=17, name="Cyllene", category="female")
25+
Leucosia = Speaker(sid=95, name="Leucosia", category="female")
26+
Crina = Speaker(sid=44, name="Crina", category="female")
27+
Hespe = Speaker(sid=80, name="Hespe", category="female")
28+
Ida = Speaker(sid=106, name="Ida", category="female")
29+
Alseid = Speaker(sid=6, name="Alseid", category="male")
30+
Daphnis = Speaker(sid=10, name="Daphnis", category="male")
31+
Echo = Speaker(sid=16, name="Echo", category="male")
32+
Thel = Speaker(sid=41, name="Thel", category="male")
33+
Nomios = Speaker(sid=77, name="Nomios", category="male")
3434
# SeedInput = Speaker(sid=-1, name="Seed Input", category="custom")
3535

3636

0 commit comments

Comments
 (0)