Skip to main content

Abstract base class and return formats for AI Generator classes within the Jeneratorverse.

Project description

Base Jenerator

Abstract base class and return formats for AI Generator classes within the Jeneratorverse, providing a unified API across different media formats.

The idea is, whether you're running Stable Diffusion 1.5 with imagejenerator, or Llama 3.2 with textjenerator, you'll always call the same methods, and get outputs returned to you in the same format.

BaseGenerator class

Contract for generator classes that run model inference.

Abstract methods that must be implmented by subclasses are:

  • load: load the model into memory, and assign the pipeline/model/engine to self.model.
  • prepare: Reset lifecycle without tearing down the model - e.g., reset torch generators, clear cache, etc.
  • generate: The public method that is called to run inference.
  • generate_impl: Subclasses must implement this to run inference. Called by .generate().
  • _quick_wrap: Helper for subclasses to wrap artifacts into the Artfact class.
  • teardown: Purge the model from memory, empty cache, run garbage collector, etc.

GeneratorOutput

Wrapper for artifacts generated. Will always return artifacts in a list in the .artifacts attribute, even for pipelines that return a single artifact (e.g., LLMs, non-batch image generation, etc.). Generation level metadata can be returned in .extras, however you should reserve this for things really cannot be captured anywhere else. The generator classes are meant to be stateless, besides the model/pipline.

They are like toasters - prompt in, artifact out.

Artifact

Represents a single artifact created by the generator. One image, text response, wav file, or whatever.

As with GeneratorOutput you can bundle metadata into .item_extras but again, I recommend leaving that responsibility to the calling app.

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

basejenerator-0.1.0.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

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

basejenerator-0.1.0-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file basejenerator-0.1.0.tar.gz.

File metadata

  • Download URL: basejenerator-0.1.0.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.12.3 Linux/6.17.0-35-generic

File hashes

Hashes for basejenerator-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ecc7bec45d4b561bff2853d3ebf8fc444bdeb8caad0678079c82638849c52410
MD5 86f9abe56200cf10929bde875227bb1f
BLAKE2b-256 2b9ab7b54df970d573ecd03aa05b2beac1035b821b39d7d64c05bd5853335554

See more details on using hashes here.

File details

Details for the file basejenerator-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: basejenerator-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.12.3 Linux/6.17.0-35-generic

File hashes

Hashes for basejenerator-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 daca52550758b3947cafe482e5d5a1c7d9b89216175497a53f1f1a3c185a3ca8
MD5 f3d4baac9155b7973a78c1796f4b228a
BLAKE2b-256 841faa86719e3ef05402500e9db3c9b904d24fc961f52146636ff4a918efd3f7

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