Skip to main content

Novelai Python Binding With Pydantic

Project description

novelai-python

PyPI version Downloads

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 🙏

BackEnd

novelai-api

NovelAI-API

Project details


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.1.9.tar.gz (31.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

novelai_python-0.1.9-py3-none-any.whl (40.0 kB view details)

Uploaded Python 3

File details

Details for the file novelai_python-0.1.9.tar.gz.

File metadata

  • Download URL: novelai_python-0.1.9.tar.gz
  • Upload date:
  • Size: 31.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.12.3 CPython/3.10.12

File hashes

Hashes for novelai_python-0.1.9.tar.gz
Algorithm Hash digest
SHA256 6cdd7d4c3143988e1ceb5d144f1d25f51495d1a9c0deb8aee311f65be492312a
MD5 aeb7f7ef2fa4872f997bdcc2b59269db
BLAKE2b-256 827b3a073e4f6b2e9712e2491ee483e61e3ebc132ede981fc91cd236b73172ac

See more details on using hashes here.

File details

Details for the file novelai_python-0.1.9-py3-none-any.whl.

File metadata

  • Download URL: novelai_python-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 40.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.12.3 CPython/3.10.12

File hashes

Hashes for novelai_python-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 ef97ea8e726297705c8967bbd2bd4362efc4b4c7a9ef1456f0bbd145daca3a04
MD5 23811b68e97fd1ae6182d28e1465c630
BLAKE2b-256 e3b0b1b6fab5961cfd47091d24f1931f67cd67c30ebe30ea14b6619559ebff70

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page