diff --git a/.buildinfo b/.buildinfo index dbd1865..5d9a8c9 100644 --- a/.buildinfo +++ b/.buildinfo @@ -1,4 +1,4 @@ # Sphinx build info version 1 # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. -config: 1ab1129fb4c92fd73b246caf58d2f39d +config: bf0b851f30abe7fe6128846a3b4b310d tags: 645f666f9bcd5a90fca523b33c5a78b7 diff --git a/_modules/example/boilerplate.html b/_modules/example/boilerplate.html index a13b775..fbce110 100644 --- a/_modules/example/boilerplate.html +++ b/_modules/example/boilerplate.html @@ -5,7 +5,7 @@
-
#: Use the old behavior of prompt separation at the 75 tokens mark (can cut words in half)
legacy_v3_extend: bool
+ #: ???
+ params_version: int
_settings: Dict[str, Any]
@@ -731,7 +733,7 @@ Navigation
[docs]class NovelAIAPI:
# Constants
+ # TODO: might want to make the base endpoint configurable
#: The base address for the API
BASE_ADDRESS: str = "https://api.novelai.net"
LIB_ROOT: str = dirname(abspath(__file__))
@@ -194,7 +195,7 @@ Navigation
modules |
- NovelAI API 0.24.1 documentation »
+ NovelAI API 0.25.0 documentation »
Module code »
novelai_api.NovelAI_API
diff --git a/_modules/novelai_api/Preset.html b/_modules/novelai_api/Preset.html
index eaefbd3..01eec74 100644
--- a/_modules/novelai_api/Preset.html
+++ b/_modules/novelai_api/Preset.html
@@ -5,7 +5,7 @@
- novelai_api.Preset — NovelAI API 0.24.1 documentation
+ novelai_api.Preset — NovelAI API 0.25.0 documentation
@@ -43,7 +43,7 @@ Navigation
modules |
- NovelAI API 0.24.1 documentation »
+ NovelAI API 0.25.0 documentation »
Module code »
novelai_api.Preset
@@ -702,7 +702,7 @@ Navigation
modules |
- NovelAI API 0.24.1 documentation »
+ NovelAI API 0.25.0 documentation »
Module code »
novelai_api.Preset
diff --git a/_modules/novelai_api/SchemaValidator.html b/_modules/novelai_api/SchemaValidator.html
index e7e81fc..e0745ac 100644
--- a/_modules/novelai_api/SchemaValidator.html
+++ b/_modules/novelai_api/SchemaValidator.html
@@ -5,7 +5,7 @@
- novelai_api.SchemaValidator — NovelAI API 0.24.1 documentation
+ novelai_api.SchemaValidator — NovelAI API 0.25.0 documentation
@@ -43,7 +43,7 @@ Navigation
modules |
- NovelAI API 0.24.1 documentation »
+ NovelAI API 0.25.0 documentation »
Module code »
novelai_api.SchemaValidator
@@ -121,7 +121,7 @@ Navigation
modules |
- NovelAI API 0.24.1 documentation »
+ NovelAI API 0.25.0 documentation »
Module code »
novelai_api.SchemaValidator
diff --git a/_modules/novelai_api/StoryHandler.html b/_modules/novelai_api/StoryHandler.html
index 26938f8..3217e00 100644
--- a/_modules/novelai_api/StoryHandler.html
+++ b/_modules/novelai_api/StoryHandler.html
@@ -5,7 +5,7 @@
- novelai_api.StoryHandler — NovelAI API 0.24.1 documentation
+ novelai_api.StoryHandler — NovelAI API 0.25.0 documentation
@@ -43,7 +43,7 @@ Navigation
modules |
- NovelAI API 0.24.1 documentation »
+ NovelAI API 0.25.0 documentation »
Module code »
novelai_api.StoryHandler
@@ -551,7 +551,7 @@ Navigation
modules |
- NovelAI API 0.24.1 documentation »
+ NovelAI API 0.25.0 documentation »
Module code »
novelai_api.StoryHandler
diff --git a/_modules/novelai_api/Tokenizer.html b/_modules/novelai_api/Tokenizer.html
index 2cfbff4..5322e38 100644
--- a/_modules/novelai_api/Tokenizer.html
+++ b/_modules/novelai_api/Tokenizer.html
@@ -5,7 +5,7 @@
- novelai_api.Tokenizer — NovelAI API 0.24.1 documentation
+ novelai_api.Tokenizer — NovelAI API 0.25.0 documentation
@@ -43,7 +43,7 @@ Navigation
modules |
- NovelAI API 0.24.1 documentation »
+ NovelAI API 0.25.0 documentation »
Module code »
novelai_api.Tokenizer
@@ -298,7 +298,7 @@ Navigation
modules |
- NovelAI API 0.24.1 documentation »
+ NovelAI API 0.25.0 documentation »
Module code »
novelai_api.Tokenizer
diff --git a/_modules/novelai_api/_high_level.html b/_modules/novelai_api/_high_level.html
index 4adeca8..1e85f83 100644
--- a/_modules/novelai_api/_high_level.html
+++ b/_modules/novelai_api/_high_level.html
@@ -5,7 +5,7 @@
- novelai_api._high_level — NovelAI API 0.24.1 documentation
+ novelai_api._high_level — NovelAI API 0.25.0 documentation
@@ -43,7 +43,7 @@ Navigation
modules |
- NovelAI API 0.24.1 documentation »
+ NovelAI API 0.25.0 documentation »
Module code »
novelai_api._high_level
@@ -588,7 +588,7 @@ Navigation
modules |
- NovelAI API 0.24.1 documentation »
+ NovelAI API 0.25.0 documentation »
Module code »
novelai_api._high_level
diff --git a/_modules/novelai_api/_low_level.html b/_modules/novelai_api/_low_level.html
index 7c26db5..e1f5937 100644
--- a/_modules/novelai_api/_low_level.html
+++ b/_modules/novelai_api/_low_level.html
@@ -5,7 +5,7 @@
- novelai_api._low_level — NovelAI API 0.24.1 documentation
+ novelai_api._low_level — NovelAI API 0.25.0 documentation
@@ -43,7 +43,7 @@ Navigation
modules |
- NovelAI API 0.24.1 documentation »
+ NovelAI API 0.25.0 documentation »
Module code »
novelai_api._low_level
@@ -78,6 +78,8 @@ Source code for novelai_api._low_level
PRINT_WITH_PARAMETERS = os.environ.get("NAI_PRINT", False)
+IMAGE_API_ADDRESS = "https://image.novelai.net"
+
# === INTERNALS === #
SSE_FIELDS = ["event", "data", "id", "retry"]
@@ -95,15 +97,15 @@ Source code for novelai_api._low_level
if "parameters" in a:
a["parameters"] = {k: str(v) for k, v in a["parameters"].items()}
- for k in ["image", "mask", "controlnet_condition"]:
- if k in a["parameters"]:
- a["parameters"][k] = (
- f"{a['parameters'][k][:10]}...{a['parameters'][k][-10:]}"
- if 30 < len(a["parameters"][k])
- else a["parameters"][k]
- )
+ for k in ["image", "mask", "controlnet_condition"]:
+ if k in a["parameters"]:
+ a["parameters"][k] = (
+ f"{a['parameters'][k][:10]}...{a['parameters'][k][-10:]}"
+ if 30 < len(a["parameters"][k])
+ else a["parameters"][k]
+ )
- print(json.dumps(a, indent=4))
+ print(json.dumps(a, indent=4, sort_keys=True))
# === API === #
@@ -238,7 +240,7 @@ Source code for novelai_api._low_level
elif content_type in ("audio/mpeg", "audio/webm"):
yield await rsp.read()
- elif content_type == "application/x-zip-compressed":
+ elif content_type in ("application/x-zip-compressed", "binary/octet-stream"):
z = zipfile.ZipFile(io.BytesIO(await rsp.read()))
for name in z.namelist():
yield name, z.read(name)
@@ -252,16 +254,29 @@ Source code for novelai_api._low_level
url: str = rsp.url if isinstance(rsp.url, str) else rsp.url.human_repr()
raise NovelAIError(url, -1, f"Unsupported type: {rsp.content_type}")
-[docs] async def request(self, method: str, endpoint: str, data: Optional[Union[Dict[str, Any], str]] = None):
+[docs] async def request(
+ self,
+ method: str,
+ endpoint: str,
+ data: Optional[Union[Dict[str, Any], str]] = None,
+ custom_base_address: Union[str, None] = None,
+ ):
"""
Send request with support for data streaming
:param method: Method of the request (get, post, delete)
:param endpoint: Endpoint of the request
:param data: Data to pass to the method if needed
+ :param custom_base_address: Custom address to use for the request
"""
- url = f"{self._parent.BASE_ADDRESS}{endpoint}"
+ if PRINT_WITH_PARAMETERS:
+ print_with_parameters(data)
+
+ if custom_base_address is None:
+ custom_base_address = self._parent.BASE_ADDRESS
+
+ url = f"{custom_base_address}{endpoint}"
is_sync = self._parent.session is None
session = ClientSession() if is_sync else self._parent.session
@@ -704,9 +719,6 @@ Source code for novelai_api._low_level
endpoint = "/ai/generate-stream" if stream else "/ai/generate"
- if PRINT_WITH_PARAMETERS:
- print_with_parameters(data)
-
async for rsp, content in self.request("post", endpoint, data):
self._treat_response_object(rsp, content, 201)
@@ -737,7 +749,7 @@ Source code for novelai_api._low_level
"parameters": parameters,
}
- async for rsp, content in self.request("post", "/ai/generate-image", data):
+ async for rsp, content in self.request("post", "/ai/generate-image", data, IMAGE_API_ADDRESS):
self._treat_response_object(rsp, content, 200)
yield content
@@ -841,7 +853,7 @@ Source code for novelai_api._low_level
quote_via=quote,
)
- async for rsp, content in self.request("get", f"/ai/generate-image/suggest-tags?{query}"):
+ async for rsp, content in self.request("get", f"/ai/generate-image/suggest-tags?{query}", IMAGE_API_ADDRESS):
self._treat_response_object(rsp, content, 200)
return content
@@ -1002,7 +1014,7 @@ Navigation
modules |
- NovelAI API 0.24.1 documentation »
+ NovelAI API 0.25.0 documentation »
Module code »
novelai_api._low_level
diff --git a/_modules/novelai_api/utils.html b/_modules/novelai_api/utils.html
index 58d765c..f7d2734 100644
--- a/_modules/novelai_api/utils.html
+++ b/_modules/novelai_api/utils.html
@@ -5,7 +5,7 @@
- novelai_api.utils — NovelAI API 0.24.1 documentation
+ novelai_api.utils — NovelAI API 0.25.0 documentation
@@ -43,7 +43,7 @@ Navigation
modules |
- NovelAI API 0.24.1 documentation »
+ NovelAI API 0.25.0 documentation »
Module code »
novelai_api.utils
@@ -464,7 +464,7 @@ Navigation
modules |
- NovelAI API 0.24.1 documentation »
+ NovelAI API 0.25.0 documentation »
Module code »
novelai_api.utils
diff --git a/_modules/tests/api/boilerplate.html b/_modules/tests/api/boilerplate.html
index 1168b00..637c461 100644
--- a/_modules/tests/api/boilerplate.html
+++ b/_modules/tests/api/boilerplate.html
@@ -5,7 +5,7 @@
- tests.api.boilerplate — NovelAI API 0.24.1 documentation
+ tests.api.boilerplate — NovelAI API 0.25.0 documentation
@@ -43,7 +43,7 @@ Navigation
modules |
- NovelAI API 0.24.1 documentation »
+ NovelAI API 0.25.0 documentation »
Module code »
tests.api.boilerplate
@@ -260,7 +260,7 @@ Navigation
modules |
- NovelAI API 0.24.1 documentation »
+ NovelAI API 0.25.0 documentation »
Module code »
tests.api.boilerplate
diff --git a/_modules/tests/api/test_decrypt_encrypt_integrity_check.html b/_modules/tests/api/test_decrypt_encrypt_integrity_check.html
index 555db8f..26f11e0 100644
--- a/_modules/tests/api/test_decrypt_encrypt_integrity_check.html
+++ b/_modules/tests/api/test_decrypt_encrypt_integrity_check.html
@@ -5,7 +5,7 @@
- tests.api.test_decrypt_encrypt_integrity_check — NovelAI API 0.24.1 documentation
+ tests.api.test_decrypt_encrypt_integrity_check — NovelAI API 0.25.0 documentation
@@ -43,7 +43,7 @@ Navigation
modules |
- NovelAI API 0.24.1 documentation »
+ NovelAI API 0.25.0 documentation »
Module code »
tests.api.test_decrypt_encrypt_integrity_check
@@ -307,7 +307,7 @@ Navigation
modules |
- NovelAI API 0.24.1 documentation »
+ NovelAI API 0.25.0 documentation »
Module code »
tests.api.test_decrypt_encrypt_integrity_check
diff --git a/_modules/tests/api/test_textgen_presets.html b/_modules/tests/api/test_textgen_presets.html
index 5a3fc48..6b7d1c6 100644
--- a/_modules/tests/api/test_textgen_presets.html
+++ b/_modules/tests/api/test_textgen_presets.html
@@ -5,7 +5,7 @@
- tests.api.test_textgen_presets — NovelAI API 0.24.1 documentation
+ tests.api.test_textgen_presets — NovelAI API 0.25.0 documentation
@@ -43,7 +43,7 @@ Navigation
modules |
- NovelAI API 0.24.1 documentation »
+ NovelAI API 0.25.0 documentation »
Module code »
tests.api.test_textgen_presets
@@ -163,7 +163,7 @@ Navigation
modules |
- NovelAI API 0.24.1 documentation »
+ NovelAI API 0.25.0 documentation »
Module code »
tests.api.test_textgen_presets
diff --git a/_static/documentation_options.js b/_static/documentation_options.js
index 0006db8..9f5e58d 100644
--- a/_static/documentation_options.js
+++ b/_static/documentation_options.js
@@ -1,6 +1,6 @@
var DOCUMENTATION_OPTIONS = {
URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'),
- VERSION: '0.24.1',
+ VERSION: '0.25.0',
LANGUAGE: 'en',
COLLAPSE_INDEX: false,
BUILDER: 'html',
diff --git a/example/example.boilerplate.html b/example/example.boilerplate.html
index 8133f3f..b346986 100644
--- a/example/example.boilerplate.html
+++ b/example/example.boilerplate.html
@@ -6,7 +6,7 @@
- boilerplate — NovelAI API 0.24.1 documentation
+ boilerplate — NovelAI API 0.25.0 documentation
@@ -52,7 +52,7 @@ Navigation
previous |
- NovelAI API 0.24.1 documentation »
+ NovelAI API 0.25.0 documentation »
example directory »
boilerplate
@@ -198,7 +198,7 @@ Navigation
previous |
- NovelAI API 0.24.1 documentation »
+ NovelAI API 0.25.0 documentation »
example directory »
boilerplate
diff --git a/example/example.html b/example/example.html
index 8afa747..b729fd9 100644
--- a/example/example.html
+++ b/example/example.html
@@ -6,7 +6,7 @@
- example directory — NovelAI API 0.24.1 documentation
+ example directory — NovelAI API 0.25.0 documentation
@@ -52,7 +52,7 @@ Navigation
previous |
- NovelAI API 0.24.1 documentation »
+ NovelAI API 0.25.0 documentation »
example directory
@@ -284,7 +284,7 @@ Navigation
previous |
- NovelAI API 0.24.1 documentation »
+ NovelAI API 0.25.0 documentation »
example directory
diff --git a/genindex.html b/genindex.html
index 2278bec..b5725d3 100644
--- a/genindex.html
+++ b/genindex.html
@@ -5,7 +5,7 @@
- Index — NovelAI API 0.24.1 documentation
+ Index — NovelAI API 0.25.0 documentation
@@ -43,7 +43,7 @@ Navigation
modules |
- NovelAI API 0.24.1 documentation »
+ NovelAI API 0.25.0 documentation »
Index
@@ -1103,6 +1103,8 @@ P
Palette_Swap (ControlNetModel attribute)
PAPER (LowLevel.SubscriptionTier attribute)
+
+ params_version (ImagePreset attribute)
phrase_rep_pen (Preset attribute)
@@ -1505,7 +1507,7 @@ Navigation
modules |
- NovelAI API 0.24.1 documentation »
+ NovelAI API 0.25.0 documentation »
Index
diff --git a/index.html b/index.html
index ef132ea..31c2f66 100644
--- a/index.html
+++ b/index.html
@@ -6,7 +6,7 @@
- novelai-api — NovelAI API 0.24.1 documentation
+ novelai-api — NovelAI API 0.25.0 documentation
@@ -48,7 +48,7 @@ Navigation
next |
- NovelAI API 0.24.1 documentation »
+ NovelAI API 0.25.0 documentation »
novelai-api
@@ -79,7 +79,7 @@ novelai-api
Activity
-
+
@@ -332,7 +332,7 @@ Navigation
next |
- NovelAI API 0.24.1 documentation »
+ NovelAI API 0.25.0 documentation »
novelai-api
diff --git a/novelai_api/Full_list_of_modules.html b/novelai_api/Full_list_of_modules.html
index fe204bb..333f65a 100644
--- a/novelai_api/Full_list_of_modules.html
+++ b/novelai_api/Full_list_of_modules.html
@@ -6,7 +6,7 @@
- <no title> — NovelAI API 0.24.1 documentation
+ <no title> — NovelAI API 0.25.0 documentation
@@ -44,7 +44,7 @@ Navigation
Use the old behavior of prompt separation at the 75 tokens mark (can cut words in half)
???
+ImagePreset.reference_information_extracted
ImagePreset.reference_strength
ImagePreset.legacy_v3_extend
ImagePreset.params_version
ImagePreset.last_seed
ImagePreset.from_file()
ImagePreset.to_file()
Send request with support for data streaming
method – Method of the request (get, post, delete)
endpoint – Endpoint of the request
data – Data to pass to the method if needed
custom_base_address – Custom address to use for the request