novelai-python 0.2.0__tar.gz → 0.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. {novelai_python-0.2.0 → novelai_python-0.2.1}/PKG-INFO +2 -2
  2. {novelai_python-0.2.0 → novelai_python-0.2.1}/README.md +1 -1
  3. {novelai_python-0.2.0 → novelai_python-0.2.1}/pyproject.toml +1 -1
  4. {novelai_python-0.2.0 → novelai_python-0.2.1}/src/novelai_python/utils/random_prompt/__init__.py +28 -14
  5. {novelai_python-0.2.0 → novelai_python-0.2.1}/NOTICE.MD +0 -0
  6. {novelai_python-0.2.0 → novelai_python-0.2.1}/src/novelai_python/__init__.py +0 -0
  7. {novelai_python-0.2.0 → novelai_python-0.2.1}/src/novelai_python/_exceptions.py +0 -0
  8. {novelai_python-0.2.0 → novelai_python-0.2.1}/src/novelai_python/_response/__init__.py +0 -0
  9. {novelai_python-0.2.0 → novelai_python-0.2.1}/src/novelai_python/_response/ai/__init__.py +0 -0
  10. {novelai_python-0.2.0 → novelai_python-0.2.1}/src/novelai_python/_response/ai/generate_image.py +0 -0
  11. {novelai_python-0.2.0 → novelai_python-0.2.1}/src/novelai_python/_response/user/__init__.py +0 -0
  12. {novelai_python-0.2.0 → novelai_python-0.2.1}/src/novelai_python/_response/user/login.py +0 -0
  13. {novelai_python-0.2.0 → novelai_python-0.2.1}/src/novelai_python/_response/user/subscription.py +0 -0
  14. {novelai_python-0.2.0 → novelai_python-0.2.1}/src/novelai_python/credential/JwtToken.py +0 -0
  15. {novelai_python-0.2.0 → novelai_python-0.2.1}/src/novelai_python/credential/UserAuth.py +0 -0
  16. {novelai_python-0.2.0 → novelai_python-0.2.1}/src/novelai_python/credential/__init__.py +0 -0
  17. {novelai_python-0.2.0 → novelai_python-0.2.1}/src/novelai_python/credential/_base.py +0 -0
  18. {novelai_python-0.2.0 → novelai_python-0.2.1}/src/novelai_python/sdk/__init__.py +0 -0
  19. {novelai_python-0.2.0 → novelai_python-0.2.1}/src/novelai_python/sdk/ai/LICENSE +0 -0
  20. {novelai_python-0.2.0 → novelai_python-0.2.1}/src/novelai_python/sdk/ai/__init__.py +0 -0
  21. {novelai_python-0.2.0 → novelai_python-0.2.1}/src/novelai_python/sdk/ai/generate_image.py +0 -0
  22. {novelai_python-0.2.0 → novelai_python-0.2.1}/src/novelai_python/sdk/user/__init__.py +0 -0
  23. {novelai_python-0.2.0 → novelai_python-0.2.1}/src/novelai_python/sdk/user/login.py +0 -0
  24. {novelai_python-0.2.0 → novelai_python-0.2.1}/src/novelai_python/sdk/user/subscription.py +0 -0
  25. {novelai_python-0.2.0 → novelai_python-0.2.1}/src/novelai_python/server.py +0 -0
  26. {novelai_python-0.2.0 → novelai_python-0.2.1}/src/novelai_python/utils/__init__.py +0 -0
  27. {novelai_python-0.2.0 → novelai_python-0.2.1}/src/novelai_python/utils/encode.py +0 -0
  28. {novelai_python-0.2.0 → novelai_python-0.2.1}/src/novelai_python/utils/hash.py +0 -0
  29. {novelai_python-0.2.0 → novelai_python-0.2.1}/src/novelai_python/utils/random_prompt/tag.py +0 -0
  30. {novelai_python-0.2.0 → novelai_python-0.2.1}/src/novelai_python/utils/random_prompt/tag_artist.py +0 -0
  31. {novelai_python-0.2.0 → novelai_python-0.2.1}/src/novelai_python/utils/random_prompt/tag_character.py +0 -0
  32. {novelai_python-0.2.0 → novelai_python-0.2.1}/src/novelai_python/utils/random_prompt/tag_nsfw.py +0 -0
  33. {novelai_python-0.2.0 → novelai_python-0.2.1}/tests/__init__.py +0 -0
  34. {novelai_python-0.2.0 → novelai_python-0.2.1}/tests/test_random_prompt.py +0 -0
  35. {novelai_python-0.2.0 → novelai_python-0.2.1}/tests/test_server.py +0 -0
  36. {novelai_python-0.2.0 → novelai_python-0.2.1}/tests/test_server_run.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: novelai-python
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: Novelai Python Binding With Pydantic
5
5
  Author-Email: sudoskys <coldlando@hotmail.com>
6
6
  License: Apache 2.0
@@ -89,7 +89,7 @@ loop.run_until_complete(main())
89
89
  ```python
90
90
  from novelai_python.utils.random_prompt import RandomPromptGenerator
91
91
 
92
- s = RandomPromptGenerator(nsfw_enabled=False).generate()
92
+ s = RandomPromptGenerator(nsfw_enabled=False).random_prompt()
93
93
  print(s)
94
94
  ```
95
95
 
@@ -64,7 +64,7 @@ loop.run_until_complete(main())
64
64
  ```python
65
65
  from novelai_python.utils.random_prompt import RandomPromptGenerator
66
66
 
67
- s = RandomPromptGenerator(nsfw_enabled=False).generate()
67
+ s = RandomPromptGenerator(nsfw_enabled=False).random_prompt()
68
68
  print(s)
69
69
  ```
70
70
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "novelai-python"
3
- version = "0.2.0"
3
+ version = "0.2.1"
4
4
  description = "Novelai Python Binding With Pydantic"
5
5
  authors = [
6
6
  { name = "sudoskys", email = "coldlando@hotmail.com" },
@@ -30,16 +30,25 @@ class RandomPromptGenerator(object):
30
30
  :param existing_tags: a list of existing tags
31
31
  :return: a tag
32
32
  """
33
- valid_tags = [tag for tag in tags if
34
- len(tag) < 3 or not tag[2] or any(sub_tag in existing_tags for sub_tag in tag[2])]
33
+ valid_tags = [tag
34
+ for tag in tags
35
+ if len(tag) < 3 or not tag[2] or any(sub_tag in existing_tags for sub_tag in tag[2])]
35
36
  total_weight = sum(tagr[1] for tagr in valid_tags if len(tagr) > 1)
36
37
  if total_weight == 0:
37
- return random.choice(tags)
38
+ if isinstance(tags, list):
39
+ rd = random.choice(tags)
40
+ elif isinstance(tags, str):
41
+ rd = tags
42
+ else:
43
+ raise ValueError('get_weighted_choice: should not reach here')
44
+ return rd
38
45
  random_number = random.randint(1, total_weight)
39
46
  cumulative_weight = 0
40
47
  for tag in valid_tags:
41
48
  cumulative_weight += tag[1]
42
49
  if random_number <= cumulative_weight:
50
+ if isinstance(tag, str):
51
+ raise Exception("tag is string")
43
52
  return tag[0]
44
53
  raise ValueError('get_weighted_choice: should not reach here')
45
54
 
@@ -61,7 +70,7 @@ class RandomPromptGenerator(object):
61
70
  has_unique_feature = any(feature in features for feature in unique_features)
62
71
  if random.random() < 0.1 and enable_skin_color:
63
72
  features.append(self.get_weighted_choice(sinkColor, features))
64
- if random.random() < 0.3:
73
+ if random.random() < 0.8:
65
74
  features.append(self.get_weighted_choice(eyeColors, features))
66
75
  if random.random() < 0.1:
67
76
  features.append(self.get_weighted_choice(eyeCharacteristics, features))
@@ -71,12 +80,12 @@ class RandomPromptGenerator(object):
71
80
  features.append(self.get_weighted_choice(hairLength, features))
72
81
  if random.random() < 0.2:
73
82
  features.append(self.get_weighted_choice(backHairStyle, features))
74
- if random.random() < 0.2:
83
+ if random.random() < 0.1:
75
84
  features.append(self.get_weighted_choice(hairColors, features))
76
85
  if random.random() < 0.1:
77
86
  features.append(self.get_weighted_choice(hairColorExtra, features))
78
87
  features.append(self.get_weighted_choice(hairColors, features))
79
- if random.random() < 0.1:
88
+ if random.random() < 0.12:
80
89
  features.append(self.get_weighted_choice(hairFeatures, features))
81
90
  if gender.startswith('f') and random.random() < 0.8:
82
91
  features.append(self.get_weighted_choice(breastsSize, features))
@@ -136,9 +145,9 @@ class RandomPromptGenerator(object):
136
145
  # 单角色 + nsfw 为 1
137
146
  possible_actions = action
138
147
  if nsfw_enabled:
139
- if random.random() < 0.3:
148
+ if random.random() < 0.5:
140
149
  features.append(self.get_weighted_choice(nsfw["action"], features))
141
- if random.random() < 0.25:
150
+ if random.random() < 0.5:
142
151
  features.append(self.get_weighted_choice(nsfw["pussyForeplay"], features))
143
152
  possible_actions += nsfw["action"] + nsfw["analForeplay"] + nsfw["pussyForeplay"]
144
153
  if random.random() < 0.5:
@@ -190,8 +199,13 @@ class RandomPromptGenerator(object):
190
199
  enable_moods: bool = True,
191
200
  enable_character: bool = True,
192
201
  enable_identity: bool = False,
202
+ must_appear=None,
193
203
  ):
204
+ if must_appear is None:
205
+ must_appear = []
194
206
  tags = []
207
+ # 必须出现的标签
208
+ tags.extend(must_appear)
195
209
  if self.nsfw_enabled:
196
210
  tags.append('nsfw')
197
211
  if random.random() < 0.1:
@@ -199,7 +213,7 @@ class RandomPromptGenerator(object):
199
213
  tags.append('lewd')
200
214
  irs = self.get_weighted_choice([[1, 70], [2, 20], [3, 7], [0, 5]], tags)
201
215
  if self.nsfw_enabled:
202
- irs = self.get_weighted_choice([[1, 35], [2, 20], [3, 7]], tags)
216
+ irs = self.get_weighted_choice([[1, 40], [2, 20], [3, 7]], tags)
203
217
  if irs == 0:
204
218
  tags.append('no humans')
205
219
  if random.random() < 0.3:
@@ -216,11 +230,11 @@ class RandomPromptGenerator(object):
216
230
  return ', '.join(tags)
217
231
  if random.random() < 0.3:
218
232
  tags.append(self.get_weighted_choice(artStyle, tags))
219
- if random.random() < 0.5:
233
+ if random.random() < 0.6:
220
234
  tags.append("{" + self.get_weighted_choice(rankArtist, tags) + "}")
221
235
  if random.random() < 0.5:
222
236
  tags.append("[" + self.get_weighted_choice(rankArtist, tags) + "]")
223
- if random.random() < 0.5:
237
+ if random.random() < 0.4:
224
238
  tags.append("{{" + self.get_weighted_choice(rankArtist, tags) + "}}")
225
239
  c_count = 0
226
240
  d_count = 0
@@ -260,17 +274,17 @@ class RandomPromptGenerator(object):
260
274
  tags.append(nsfw["ya"])
261
275
  if d_count > 0:
262
276
  if c_count > 0:
263
- if random.random() < 0.6:
277
+ if random.random() < 0.3:
264
278
  tags.append(self.get_weighted_choice(nsfw["penis"], tags))
265
279
  else:
266
280
  if random.random() < 0.3:
267
281
  tags.append(self.get_weighted_choice(nsfw["penis"], tags))
268
282
  if d_count > 0 and g_count > 0:
269
- if random.random() < 0.5:
283
+ if random.random() < 0.7:
270
284
  tags.append(self.get_weighted_choice(nsfw["analSex"], tags))
271
285
  if g_count > 0:
272
286
  features = []
273
- if random.random() < 0.3:
287
+ if random.random() < 0.2:
274
288
  features = self.character_features(nsfw['fu'], None, True, irs)
275
289
  if random.random() < 0.6:
276
290
  tags.append(self.get_weighted_choice(nsfw["sex"], tags))
File without changes