Novelai Python Binding With Pydantic
Project description
novelai-python
The goal of this repository is to use Pydantic to build legitimate requests to access the Novelai API service.
Roadmap 🚧
- /ai/generate-image
- /user/subscription
- /user/login
- /ai/generate-image/suggest-tags
- /ai/annotate-image
- /ai/classify
- /ai/upscale
- /ai/generate-prompt
- /ai/generate
- /ai/generate-voice
Usage 🖥️
More examples can be found in the playground directory.
import asyncio
import os
from dotenv import load_dotenv
from pydantic import SecretStr
from novelai_python import GenerateImageInfer, ImageGenerateResp, JwtCredential, LoginCredential
load_dotenv()
enhance = "year 2023,dynamic angle, best quality, amazing quality, very aesthetic, absurdres"
async def main():
globe_s = JwtCredential(
jwt_token=SecretStr(os.getenv("NOVELAI_JWT"))
)
globe_s2 = LoginCredential(
username=os.getenv("NOVELAI_USERNAME"),
password=SecretStr(os.getenv("NOVELAI_PASSWORD"))
)
_res = await GenerateImageInfer.build(
prompt=f"1girl,{enhance}").generate(
session=globe_s)
_res: ImageGenerateResp
print(_res.meta)
file = _res.files[0]
with open(file[0], "wb") as f:
f.write(file[1])
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
Random Prompt
from novelai_python.utils.random_prompt import RandomPromptGenerator
s = RandomPromptGenerator(nsfw_enabled=False).generate()
print(s)
Run A Server
pip install novelai_python
python3 -m novelai_python.server -h '0.0.0.0' -p 7888
Acknowledgements 🙏
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
novelai_python-0.2.0.tar.gz
(38.7 kB
view hashes)
Built Distribution
Close
Hashes for novelai_python-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ded94023e361662946547fcd0d89a78d8524090867a4416c4bc9197c9912e63f |
|
MD5 | 6d94b93e94e10737d9d774458f6284df |
|
BLAKE2b-256 | d7fa874b75280f51a5de4e8fa9077152a9b079d1c3a342b1938ae3e45555417d |