novelai-python 0.9.0__tar.gz → 0.9.2__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 (132) hide show
  1. {novelai_python-0.9.0 → novelai_python-0.9.2}/PKG-INFO +6 -5
  2. {novelai_python-0.9.0 → novelai_python-0.9.2}/README.md +2 -2
  3. {novelai_python-0.9.0 → novelai_python-0.9.2}/pyproject.toml +12 -8
  4. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/credential/_base.py +6 -3
  5. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/sdk/ai/_cost.py +0 -5
  6. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/sdk/ai/generate_image/params.py +3 -2
  7. {novelai_python-0.9.0 → novelai_python-0.9.2}/tests/test_browser_identity.py +8 -4
  8. novelai_python-0.9.2/tests/test_seed.py +16 -0
  9. {novelai_python-0.9.0 → novelai_python-0.9.2}/LICENSE +0 -0
  10. {novelai_python-0.9.0 → novelai_python-0.9.2}/NOTICE.MD +0 -0
  11. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/__init__.py +0 -0
  12. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/_enum.py +0 -0
  13. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/_exceptions.py +0 -0
  14. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/_response/__init__.py +0 -0
  15. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/_response/ai/__init__.py +0 -0
  16. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/_response/ai/generate.py +0 -0
  17. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/_response/ai/generate_image.py +0 -0
  18. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/_response/ai/generate_stream.py +0 -0
  19. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/_response/ai/generate_voice.py +0 -0
  20. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/_response/ai/upscale.py +0 -0
  21. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/_response/schema.py +0 -0
  22. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/_response/user/__init__.py +0 -0
  23. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/_response/user/data.py +0 -0
  24. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/_response/user/information.py +0 -0
  25. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/_response/user/login.py +0 -0
  26. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/_response/user/priority.py +0 -0
  27. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/_response/user/subscription.py +0 -0
  28. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/_response/user/trial_status.py +0 -0
  29. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/_retry.py +0 -0
  30. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/credential/ApiToken.py +0 -0
  31. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/credential/JwtToken.py +0 -0
  32. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/credential/UserAuth.py +0 -0
  33. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/credential/__init__.py +0 -0
  34. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/metrics.py +0 -0
  35. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/sdk/__init__.py +0 -0
  36. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/sdk/ai/LICENSE +0 -0
  37. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/sdk/ai/__init__.py +0 -0
  38. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/sdk/ai/_const.py +0 -0
  39. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/sdk/ai/_enum.py +0 -0
  40. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/sdk/ai/augment_image/__init__.py +0 -0
  41. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/sdk/ai/augment_image/_enum.py +0 -0
  42. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/sdk/ai/encode_vibe.py +0 -0
  43. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/sdk/ai/generate/__init__.py +0 -0
  44. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/sdk/ai/generate/_const.py +0 -0
  45. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/sdk/ai/generate/_enum.py +0 -0
  46. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/sdk/ai/generate/_schema.py +0 -0
  47. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/sdk/ai/generate/themes.json +0 -0
  48. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/sdk/ai/generate_image/__init__.py +0 -0
  49. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/sdk/ai/generate_image/auto_text.py +0 -0
  50. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/sdk/ai/generate_image/schema.py +0 -0
  51. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/sdk/ai/generate_image/suggest_tags.py +0 -0
  52. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/sdk/ai/generate_image/tokenizer.py +0 -0
  53. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/sdk/ai/generate_stream.py +0 -0
  54. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/sdk/ai/generate_voice/__init__.py +0 -0
  55. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/sdk/ai/generate_voice/_enum.py +0 -0
  56. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/sdk/ai/openai_compat.py +0 -0
  57. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/sdk/ai/upscale.py +0 -0
  58. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/sdk/schema.py +0 -0
  59. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/sdk/user/__init__.py +0 -0
  60. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/sdk/user/data.py +0 -0
  61. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/sdk/user/information.py +0 -0
  62. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/sdk/user/login.py +0 -0
  63. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/sdk/user/persistent_token.py +0 -0
  64. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/sdk/user/priority.py +0 -0
  65. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/sdk/user/subscription.py +0 -0
  66. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/sdk/user/trial_status.py +0 -0
  67. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/server.py +0 -0
  68. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/tokenizer/__init__.py +0 -0
  69. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/tokenizer/_definition.py +0 -0
  70. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/tokenizer/clip_tokenizer.py +0 -0
  71. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/tool/__init__.py +0 -0
  72. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/tool/image_metadata/__init__.py +0 -0
  73. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/tool/image_metadata/bch.py +0 -0
  74. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/tool/image_metadata/bch_utils.py +0 -0
  75. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/tool/image_metadata/lsb_extractor.py +0 -0
  76. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/tool/image_metadata/lsb_injector.py +0 -0
  77. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/tool/paint_mask/__init__.py +0 -0
  78. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/tool/random_prompt/__init__.py +0 -0
  79. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/tool/random_prompt/data/__init__.py +0 -0
  80. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/tool/random_prompt/data/anime_v3_data.py +0 -0
  81. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/tool/random_prompt/data/anime_v4_data.py +0 -0
  82. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/tool/random_prompt/data/furry_data.py +0 -0
  83. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/tool/random_prompt/data/holiday.py +0 -0
  84. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/tool/random_prompt/data/nsfw_data.py +0 -0
  85. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/tool/random_prompt/generate_scene_composition.py +0 -0
  86. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/tool/random_prompt/generate_scene_tags.py +0 -0
  87. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/tool/random_prompt/generate_tags.py +0 -0
  88. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/tool/random_prompt/generators/__init__.py +0 -0
  89. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/tool/random_prompt/generators/anime_v3.py +0 -0
  90. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/tool/random_prompt/generators/anime_v4.py +0 -0
  91. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/tool/random_prompt/generators/furry.py +0 -0
  92. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/tool/random_prompt/generators/holiday.py +0 -0
  93. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/tool/random_prompt/logic.py +0 -0
  94. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/utils/__init__.py +0 -0
  95. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/utils/daily_limit.py +0 -0
  96. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/utils/encode.py +0 -0
  97. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/utils/pacing.py +0 -0
  98. {novelai_python-0.9.0 → novelai_python-0.9.2}/src/novelai_python/utils/useful.py +0 -0
  99. {novelai_python-0.9.0 → novelai_python-0.9.2}/tests/__init__.py +0 -0
  100. {novelai_python-0.9.0 → novelai_python-0.9.2}/tests/conftest.py +0 -0
  101. {novelai_python-0.9.0 → novelai_python-0.9.2}/tests/fixtures/bch_vectors.json +0 -0
  102. {novelai_python-0.9.0 → novelai_python-0.9.2}/tests/fixtures/dependency_golden.json +0 -0
  103. {novelai_python-0.9.0 → novelai_python-0.9.2}/tests/fixtures/mask_ori.png +0 -0
  104. {novelai_python-0.9.0 → novelai_python-0.9.2}/tests/fixtures/mask_sketch.png +0 -0
  105. {novelai_python-0.9.0 → novelai_python-0.9.2}/tests/fixtures/tokenizer_golden.json +0 -0
  106. {novelai_python-0.9.0 → novelai_python-0.9.2}/tests/fixtures/v5_signed.webp +0 -0
  107. {novelai_python-0.9.0 → novelai_python-0.9.2}/tests/test_auto_text.py +0 -0
  108. {novelai_python-0.9.0 → novelai_python-0.9.2}/tests/test_bch.py +0 -0
  109. {novelai_python-0.9.0 → novelai_python-0.9.2}/tests/test_cost.py +0 -0
  110. {novelai_python-0.9.0 → novelai_python-0.9.2}/tests/test_daily_limit.py +0 -0
  111. {novelai_python-0.9.0 → novelai_python-0.9.2}/tests/test_dependency_golden.py +0 -0
  112. {novelai_python-0.9.0 → novelai_python-0.9.2}/tests/test_from_metadata.py +0 -0
  113. {novelai_python-0.9.0 → novelai_python-0.9.2}/tests/test_generate_image_v5.py +0 -0
  114. {novelai_python-0.9.0 → novelai_python-0.9.2}/tests/test_generate_text.py +0 -0
  115. {novelai_python-0.9.0 → novelai_python-0.9.2}/tests/test_generate_voice.py +0 -0
  116. {novelai_python-0.9.0 → novelai_python-0.9.2}/tests/test_image_metadata_v5.py +0 -0
  117. {novelai_python-0.9.0 → novelai_python-0.9.2}/tests/test_login_proxy.py +0 -0
  118. {novelai_python-0.9.0 → novelai_python-0.9.2}/tests/test_metrics.py +0 -0
  119. {novelai_python-0.9.0 → novelai_python-0.9.2}/tests/test_new_endpoints.py +0 -0
  120. {novelai_python-0.9.0 → novelai_python-0.9.2}/tests/test_pacing.py +0 -0
  121. {novelai_python-0.9.0 → novelai_python-0.9.2}/tests/test_presets_and_usage.py +0 -0
  122. {novelai_python-0.9.0 → novelai_python-0.9.2}/tests/test_random_prompt.py +0 -0
  123. {novelai_python-0.9.0 → novelai_python-0.9.2}/tests/test_retry_session.py +0 -0
  124. {novelai_python-0.9.0 → novelai_python-0.9.2}/tests/test_server.py +0 -0
  125. {novelai_python-0.9.0 → novelai_python-0.9.2}/tests/test_server_roundtrip.py +0 -0
  126. {novelai_python-0.9.0 → novelai_python-0.9.2}/tests/test_server_run.py +0 -0
  127. {novelai_python-0.9.0 → novelai_python-0.9.2}/tests/test_suggest_tags.py +0 -0
  128. {novelai_python-0.9.0 → novelai_python-0.9.2}/tests/test_tokenizer.py +0 -0
  129. {novelai_python-0.9.0 → novelai_python-0.9.2}/tests/test_upscale.py +0 -0
  130. {novelai_python-0.9.0 → novelai_python-0.9.2}/tests/test_user_information.py +0 -0
  131. {novelai_python-0.9.0 → novelai_python-0.9.2}/tests/test_user_login.py +0 -0
  132. {novelai_python-0.9.0 → novelai_python-0.9.2}/tests/test_user_subscription.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: novelai-python
3
- Version: 0.9.0
3
+ Version: 0.9.2
4
4
  Summary: NovelAI Python Binding With Pydantic
5
5
  Author-Email: sudoskys <coldlando@hotmail.com>
6
6
  License: Apache License 2.0
@@ -13,7 +13,7 @@ Project-URL: Repository, https://github.com/LlmKira/novelai-python/
13
13
  Project-URL: Issues, https://github.com/LlmKira/novelai-python/issues
14
14
  Requires-Python: >=3.12
15
15
  Requires-Dist: pydantic>=2.14
16
- Requires-Dist: curl-cffi>=0.16.3
16
+ Requires-Dist: curl-cffi>=0.17.0
17
17
  Requires-Dist: msgpack>=1.2
18
18
  Requires-Dist: Pillow>=12.3
19
19
  Requires-Dist: numpy>=2.5
@@ -26,7 +26,8 @@ Provides-Extra: metrics
26
26
  Requires-Dist: prometheus-client>=0.21; extra == "metrics"
27
27
  Provides-Extra: testing
28
28
  Requires-Dist: novelai-python[metrics,server]; extra == "testing"
29
- Requires-Dist: httpx>=0.28; extra == "testing"
29
+ Requires-Dist: starlette>=1.2; extra == "testing"
30
+ Requires-Dist: httpx2>=2.16; extra == "testing"
30
31
  Requires-Dist: pytest>=9.1; extra == "testing"
31
32
  Requires-Dist: pytest-asyncio>=1.4; extra == "testing"
32
33
  Description-Content-Type: text/markdown
@@ -106,9 +107,9 @@ Some changes do not raise an error, so check these when you upgrade:
106
107
  novelai.net does. Pass `auto_text=False` to send the prompt untouched.
107
108
  - **Image and user endpoints moved to `image.novelai.net`**; `api.novelai.net` rejects third-party clients
108
109
  there.
109
- - **Browser identity**: requests carry the headers of Chrome 155 on Windows, as the web client sends them.
110
+ - **Browser identity**: requests carry the headers of Chrome 157 on Windows, as the web client sends them.
110
111
  Accept-Language is English (`en-US,en;q=0.9`) unless the credential says otherwise:
111
- `ApiCredential(..., accept_language="en-sg")` (see `ACCEPT_LANGUAGES`) or a full header value.
112
+ `ApiCredential(..., accept_language="en-sg")` or `"zh-hk"` (see `ACCEPT_LANGUAGES`) or a full header value.
112
113
  - **The image budget is off by default.** Pass `limiter=True` to `request()` / `request_stream()` for the
113
114
  process-wide budget (`NOVELAI_DAILY_IMAGE_LIMIT`, default 2500 per 24h, saved to
114
115
  `~/.novelai_python/image_limit.json`), or a `DailyImageLimiter` of your own. The budget is shared by all
@@ -73,9 +73,9 @@ Some changes do not raise an error, so check these when you upgrade:
73
73
  novelai.net does. Pass `auto_text=False` to send the prompt untouched.
74
74
  - **Image and user endpoints moved to `image.novelai.net`**; `api.novelai.net` rejects third-party clients
75
75
  there.
76
- - **Browser identity**: requests carry the headers of Chrome 155 on Windows, as the web client sends them.
76
+ - **Browser identity**: requests carry the headers of Chrome 157 on Windows, as the web client sends them.
77
77
  Accept-Language is English (`en-US,en;q=0.9`) unless the credential says otherwise:
78
- `ApiCredential(..., accept_language="en-sg")` (see `ACCEPT_LANGUAGES`) or a full header value.
78
+ `ApiCredential(..., accept_language="en-sg")` or `"zh-hk"` (see `ACCEPT_LANGUAGES`) or a full header value.
79
79
  - **The image budget is off by default.** Pass `limiter=True` to `request()` / `request_stream()` for the
80
80
  process-wide budget (`NOVELAI_DAILY_IMAGE_LIMIT`, default 2500 per 24h, saved to
81
81
  `~/.novelai_python/image_limit.json`), or a `DailyImageLimiter` of your own. The budget is shared by all
@@ -1,13 +1,13 @@
1
1
  [project]
2
2
  name = "novelai-python"
3
- version = "0.9.0"
3
+ version = "0.9.2"
4
4
  description = "NovelAI Python Binding With Pydantic"
5
5
  authors = [
6
6
  { name = "sudoskys", email = "coldlando@hotmail.com" },
7
7
  ]
8
8
  dependencies = [
9
9
  "pydantic>=2.14",
10
- "curl-cffi>=0.16.3",
10
+ "curl-cffi>=0.17.0",
11
11
  "msgpack>=1.2",
12
12
  "Pillow>=12.3",
13
13
  "numpy>=2.5",
@@ -41,16 +41,14 @@ metrics = [
41
41
  ]
42
42
  testing = [
43
43
  "novelai-python[server,metrics]",
44
- "httpx>=0.28",
44
+ "starlette>=1.2",
45
+ "httpx2>=2.16",
45
46
  "pytest>=9.1",
46
47
  "pytest-asyncio>=1.4",
47
48
  ]
48
49
 
49
- [build-system]
50
- requires = [
51
- "pdm-backend",
52
- ]
53
- build-backend = "pdm.backend"
50
+ [tool.pytest.ini_options]
51
+ asyncio_default_fixture_loop_scope = "function"
54
52
 
55
53
  [tool.pdm]
56
54
  distribution = true
@@ -100,3 +98,9 @@ include = [
100
98
  "src",
101
99
  ]
102
100
  typeCheckingMode = "standard"
101
+
102
+ [build-system]
103
+ requires = [
104
+ "pdm-backend",
105
+ ]
106
+ build-backend = "pdm.backend"
@@ -16,6 +16,7 @@ ACCEPT_LANGUAGES = {
16
16
  "en-gb": "en-GB,en;q=0.9",
17
17
  "ja": "ja-JP,ja;q=0.9,en-US;q=0.8,en;q=0.7",
18
18
  "zh": "zh-CN,zh;q=0.9,en;q=0.8",
19
+ "zh-hk": "zh-HK,zh;q=0.9,en-US;q=0.8,en;q=0.7",
19
20
  "ko": "ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7",
20
21
  "ru": "ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7",
21
22
  }
@@ -109,9 +110,11 @@ def chrome_brands(major: int) -> str:
109
110
 
110
111
 
111
112
  # The browser the headers describe: the Chrome on Windows that novelai.net users run now.
112
- # curl_cffi's newest TLS profile can lag a few versions behind; its ClientHello still matches
113
- # this Chrome except for extensions added since (Chrome's ClientHello does not depend on the OS).
114
- CHROME_MAJOR_VERSION = "155"
113
+ # curl_cffi's newest TLS profile can lag a few versions behind; scripts/refresh_browser_identity.py
114
+ # checks both. 2026-11-13: Google serves Chrome 157 to all stable users, and the chrome152 profile
115
+ # of curl_cffi 0.17.0 sends the same ClientHello as Chrome 157 (0.16.3's chrome150 lacks extension
116
+ # 0xCA34). Chrome's ClientHello does not depend on the OS.
117
+ CHROME_MAJOR_VERSION = "157"
115
118
  DEFAULT_USER_AGENT = (
116
119
  "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
117
120
  f"Chrome/{CHROME_MAJOR_VERSION}.0.0.0 Safari/537.36"
@@ -4,7 +4,6 @@ Anlas cost of image requests, as the novelai.net web client computes it
4
4
  """
5
5
 
6
6
  import math
7
- import random
8
7
 
9
8
  from pydantic import BaseModel
10
9
 
@@ -61,10 +60,6 @@ class Args(BaseModel):
61
60
  inpaint_strength: float | None = None
62
61
 
63
62
 
64
- def generate_random_seed() -> int:
65
- return random.randint(0, 2**32 - 1)
66
-
67
-
68
63
  def _resize_within(width: int, height: int, max_pixels: int) -> tuple[int, int]:
69
64
  if width * height <= max_pixels:
70
65
  return width, height
@@ -87,11 +87,12 @@ class Params(BaseModel):
87
87
  inpaintImg2ImgStrength: float | None = Field(default=None, ge=0, le=1, multiple_of=0.01)
88
88
  """For SameFeel"""
89
89
  seed: int = Field(
90
- default_factory=lambda: random.randint(0, 4294967295 - 7),
90
+ default_factory=lambda: random.randint(1, 4294967295 - 7),
91
91
  gt=0,
92
92
  le=4294967295 - 7,
93
93
  )
94
- """Seed"""
94
+ """Seed. Image i of a batch is drawn with seed + i. The API reads it as uint64, so -1 is a 400;
95
+ 0 is accepted but draws a random image and the metadata still says 0, so it is refused here."""
95
96
  characterPrompts: list[Character] = Field(default_factory=list)
96
97
  """Character Prompts"""
97
98
  straight_alpha: bool | None = None
@@ -13,6 +13,8 @@ from novelai_python.credential._base import (
13
13
  @pytest.mark.parametrize(
14
14
  ("major", "captured"),
15
15
  [
16
+ # a real Chrome 157 on novelai.net (HAR, 2026-11-13)
17
+ (157, '"Not-A.Brand";v="99", "Google Chrome";v="157", "Chromium";v="157"'),
16
18
  # a real Chrome 155 on novelai.net (HAR)
17
19
  (155, '"Google Chrome";v="155", "Chromium";v="155", "Not(A:Brand";v="24"'),
18
20
  # what curl_cffi's chrome150 profile sends
@@ -24,12 +26,12 @@ def test_brand_list_matches_captured_chrome(major, captured):
24
26
 
25
27
 
26
28
  def test_headers_match_the_captured_web_client():
27
- # request headers of /ai/generate-image from Chrome 155 on Windows (HAR), language aside
29
+ # request headers of /ai/generate-image from Chrome 157 on Windows (HAR, 2026-11-13), language aside
28
30
  captured = {
29
31
  "accept": "*/*",
30
32
  "origin": "https://novelai.net",
31
33
  "referer": "https://novelai.net/",
32
- "sec-ch-ua": '"Google Chrome";v="155", "Chromium";v="155", "Not(A:Brand";v="24"',
34
+ "sec-ch-ua": '"Not-A.Brand";v="99", "Google Chrome";v="157", "Chromium";v="157"',
33
35
  "sec-ch-ua-mobile": "?0",
34
36
  "sec-ch-ua-platform": '"Windows"',
35
37
  "sec-fetch-dest": "empty",
@@ -37,18 +39,20 @@ def test_headers_match_the_captured_web_client():
37
39
  "sec-fetch-site": "same-site",
38
40
  "user-agent": (
39
41
  "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
40
- "Chrome/155.0.0.0 Safari/537.36"
42
+ "Chrome/157.0.0.0 Safari/537.36"
41
43
  ),
42
44
  }
43
45
  headers = browser_headers()
44
46
  assert {k: headers[k] for k in captured} == captured
45
47
  assert headers["accept-language"] == "en-US,en;q=0.9"
46
- assert CHROME_MAJOR_VERSION == "155"
48
+ assert CHROME_MAJOR_VERSION == "157"
47
49
 
48
50
 
49
51
  def test_accept_language_presets():
50
52
  assert resolve_accept_language(None) == "en-US,en;q=0.9"
51
53
  assert resolve_accept_language("en-SG") == ACCEPT_LANGUAGES["en-sg"] == "en-SG,en;q=0.9"
54
+ # Chrome with Traditional Chinese (Hong Kong) first, as captured on novelai.net
55
+ assert resolve_accept_language("zh-HK") == ACCEPT_LANGUAGES["zh-hk"] == "zh-HK,zh;q=0.9,en-US;q=0.8,en;q=0.7"
52
56
  assert resolve_accept_language("de-DE,de;q=0.9") == "de-DE,de;q=0.9"
53
57
 
54
58
 
@@ -0,0 +1,16 @@
1
+ import random
2
+
3
+ from novelai_python.sdk.ai.generate_image.params import Params
4
+
5
+
6
+ def test_default_seed_lower_bound_passes_validation(monkeypatch):
7
+ monkeypatch.setattr(random, "randint", lambda low, high: low)
8
+ params = Params()
9
+ assert params.seed == 1
10
+ assert Params.model_validate(params.model_dump()).seed == 1
11
+
12
+
13
+ def test_default_seed_upper_bound_passes_validation(monkeypatch):
14
+ monkeypatch.setattr(random, "randint", lambda low, high: high)
15
+ params = Params()
16
+ assert Params.model_validate(params.model_dump()).seed == params.seed
File without changes
File without changes