From b10c599f91e2a1270e4df6734938980529820a43 Mon Sep 17 00:00:00 2001 From: Aedial Date: Wed, 24 May 2023 00:59:08 +0200 Subject: [PATCH] [API] Add Clio v1 model --- novelai_api/Preset.py | 2 + novelai_api/Tokenizer.py | 1 + .../presets_clio_v1/Fresh Coffee.preset | 49 +++++++++++++++++++ .../presets/presets_clio_v1/Keelback.preset | 49 +++++++++++++++++++ .../presets/presets_clio_v1/Long Press.preset | 49 +++++++++++++++++++ .../presets/presets_clio_v1/Talker C.preset | 49 +++++++++++++++++++ .../presets/presets_clio_v1/Vingt-Un.preset | 49 +++++++++++++++++++ tests/api/boilerplate.py | 4 +- 8 files changed, 251 insertions(+), 1 deletion(-) create mode 100644 novelai_api/presets/presets_clio_v1/Fresh Coffee.preset create mode 100644 novelai_api/presets/presets_clio_v1/Keelback.preset create mode 100644 novelai_api/presets/presets_clio_v1/Long Press.preset create mode 100644 novelai_api/presets/presets_clio_v1/Talker C.preset create mode 100644 novelai_api/presets/presets_clio_v1/Vingt-Un.preset diff --git a/novelai_api/Preset.py b/novelai_api/Preset.py index ae1eacc..a80621e 100644 --- a/novelai_api/Preset.py +++ b/novelai_api/Preset.py @@ -91,6 +91,8 @@ class Model(StrEnum): Euterpe = "euterpe-v2" Krake = "krake-v2" + Clio = "clio-v1" + Genji = "genji-jp-6b-v2" Snek = "genji-python-6b" diff --git a/novelai_api/Tokenizer.py b/novelai_api/Tokenizer.py index fd3967e..153961e 100644 --- a/novelai_api/Tokenizer.py +++ b/novelai_api/Tokenizer.py @@ -70,6 +70,7 @@ class Tokenizer: Model.Genji: "gpt2-genji", Model.HypeBot: "gpt2", Model.Inline: "gpt2", + Model.Clio: "nerdstash_v1", ImageModel.Anime_Curated: "clip", ImageModel.Anime_Full: "clip", ImageModel.Furry: "clip", diff --git a/novelai_api/presets/presets_clio_v1/Fresh Coffee.preset b/novelai_api/presets/presets_clio_v1/Fresh Coffee.preset new file mode 100644 index 0000000..90d1419 --- /dev/null +++ b/novelai_api/presets/presets_clio_v1/Fresh Coffee.preset @@ -0,0 +1,49 @@ +{ + "presetVersion": 3, + "name": "Fresh Coffee", + "id": "082cc0a0-f3b9-489f-9cab-ed60e6ac673d", + "remoteId": "", + "parameters": { + "textGenerationSettingsVersion": 3, + "temperature": 1, + "max_length": 75, + "min_length": 1, + "top_k": 25, + "top_p": 1, + "top_a": 1, + "typical_p": 1, + "tail_free_sampling": 0.925, + "repetition_penalty": 1.9, + "repetition_penalty_range": 768, + "repetition_penalty_slope": 1, + "repetition_penalty_frequency": 0.0025, + "repetition_penalty_presence": 0.001, + "order": [ + { + "id": "temperature", + "enabled": true + }, + { + "id": "top_k", + "enabled": true + }, + { + "id": "top_p", + "enabled": true + }, + { + "id": "tfs", + "enabled": true + }, + { + "id": "top_a", + "enabled": false + }, + { + "id": "typical_p", + "enabled": false + } + ] + }, + "model": "clio-v1" +} diff --git a/novelai_api/presets/presets_clio_v1/Keelback.preset b/novelai_api/presets/presets_clio_v1/Keelback.preset new file mode 100644 index 0000000..9b9a498 --- /dev/null +++ b/novelai_api/presets/presets_clio_v1/Keelback.preset @@ -0,0 +1,49 @@ +{ + "presetVersion": 3, + "name": "Keelback", + "id": "60ee0af1-fd32-46bf-ab2b-54df256412cb", + "remoteId": "", + "parameters": { + "textGenerationSettingsVersion": 3, + "temperature": 1.18, + "max_length": 75, + "min_length": 1, + "top_k": 640, + "top_p": 0.125, + "top_a": 0.022, + "typical_p": 0.9, + "tail_free_sampling": 0.956, + "repetition_penalty": 1.25, + "repetition_penalty_range": 4096, + "repetition_penalty_slope": 0.9, + "repetition_penalty_frequency": 0, + "repetition_penalty_presence": 0, + "order": [ + { + "id": "top_a", + "enabled": true + }, + { + "id": "typical_p", + "enabled": true + }, + { + "id": "temperature", + "enabled": true + }, + { + "id": "tfs", + "enabled": true + }, + { + "id": "top_k", + "enabled": false + }, + { + "id": "top_p", + "enabled": false + } + ] + }, + "model": "clio-v1" +} diff --git a/novelai_api/presets/presets_clio_v1/Long Press.preset b/novelai_api/presets/presets_clio_v1/Long Press.preset new file mode 100644 index 0000000..a229d9b --- /dev/null +++ b/novelai_api/presets/presets_clio_v1/Long Press.preset @@ -0,0 +1,49 @@ +{ + "presetVersion": 3, + "name": "Long Press", + "id": "38bde058-832a-4f2e-810f-36c784e18c31", + "remoteId": "", + "parameters": { + "textGenerationSettingsVersion": 3, + "temperature": 1.155, + "max_length": 75, + "min_length": 1, + "top_k": 25, + "top_p": 1, + "top_a": 0.3, + "typical_p": 0.96, + "tail_free_sampling": 0.895, + "repetition_penalty": 1.0125, + "repetition_penalty_range": 2048, + "repetition_penalty_slope": 0, + "repetition_penalty_frequency": 0.011, + "repetition_penalty_presence": 0.005, + "order": [ + { + "id": "temperature", + "enabled": true + }, + { + "id": "top_a", + "enabled": true + }, + { + "id": "top_k", + "enabled": true + }, + { + "id": "typical_p", + "enabled": true + }, + { + "id": "tfs", + "enabled": true + }, + { + "id": "top_p", + "enabled": false + } + ] + }, + "model": "clio-v1" +} diff --git a/novelai_api/presets/presets_clio_v1/Talker C.preset b/novelai_api/presets/presets_clio_v1/Talker C.preset new file mode 100644 index 0000000..8c2e96f --- /dev/null +++ b/novelai_api/presets/presets_clio_v1/Talker C.preset @@ -0,0 +1,49 @@ +{ + "presetVersion": 3, + "name": "Talker C", + "id": "72d966fb-53c1-4c99-9295-04e4d0a3edef", + "remoteId": "", + "parameters": { + "textGenerationSettingsVersion": 3, + "temperature": 1.05, + "max_length": 75, + "min_length": 1, + "top_k": 79, + "top_p": 0.95, + "top_a": 0.075, + "typical_p": 1, + "tail_free_sampling": 0.989, + "repetition_penalty": 1.5, + "repetition_penalty_range": 8192, + "repetition_penalty_slope": 0, + "repetition_penalty_frequency": 0.03, + "repetition_penalty_presence": 0.005, + "order": [ + { + "id": "top_k", + "enabled": true + }, + { + "id": "tfs", + "enabled": true + }, + { + "id": "top_a", + "enabled": true + }, + { + "id": "temperature", + "enabled": true + }, + { + "id": "top_p", + "enabled": true + }, + { + "id": "typical_p", + "enabled": false + } + ] + }, + "model": "clio-v1" +} diff --git a/novelai_api/presets/presets_clio_v1/Vingt-Un.preset b/novelai_api/presets/presets_clio_v1/Vingt-Un.preset new file mode 100644 index 0000000..778f2b5 --- /dev/null +++ b/novelai_api/presets/presets_clio_v1/Vingt-Un.preset @@ -0,0 +1,49 @@ +{ + "presetVersion": 3, + "name": "Vingt-Un", + "id": "41f0f2d6-28af-431e-a6b8-6f9e6182dca7", + "remoteId": "", + "parameters": { + "textGenerationSettingsVersion": 3, + "temperature": 1.21, + "max_length": 75, + "min_length": 1, + "top_k": 0, + "top_p": 0.912, + "top_a": 1, + "typical_p": 0.912, + "tail_free_sampling": 0.921, + "repetition_penalty": 1.21, + "repetition_penalty_range": 321, + "repetition_penalty_slope": 2.1, + "repetition_penalty_frequency": 0.00621, + "repetition_penalty_presence": 0, + "order": [ + { + "id": "temperature", + "enabled": true + }, + { + "id": "typical_p", + "enabled": true + }, + { + "id": "tfs", + "enabled": true + }, + { + "id": "top_p", + "enabled": true + }, + { + "id": "top_k", + "enabled": true + }, + { + "id": "top_a", + "enabled": false + } + ] + }, + "model": "clio-v1" +} diff --git a/tests/api/boilerplate.py b/tests/api/boilerplate.py index b77944d..fb08fb6 100644 --- a/tests/api/boilerplate.py +++ b/tests/api/boilerplate.py @@ -73,7 +73,7 @@ def decorator(func: Callable[[Any, Any], Awaitable[Any]]): @functools.wraps(func) async def wrap(*args, **kwargs): err: Exception = RuntimeError("Error placeholder. Shouldn't happen") - for _ in range(attempts): + for attempt in range(attempts): try: res = await func(*args, **kwargs) await asyncio.sleep(wait) @@ -96,6 +96,8 @@ async def wrap(*args, **kwargs): if not retry: break + print(f"Error: {err}. Try {attempt + 1}/{attempts}") + # 10s wait between each retry await asyncio.sleep(10)