Contributing New Models/Features

Contributing New Models/Features on Modal

How to add a new model in Modal

Above is the flow of a feature call. The class and methods outlined in red represent the interface between your local machine and Modal.

Contributing a new model only requires you to create the file that runs code on Modal and returns the user data.

  1. Create a new .py file in src/tiomagic/providers/modal. This is where your modal code goes.
    • Refer to Structure of a Modal Provider file for a breakdown of an implementation
  2. Add model to src/tiomagic/providers/modal/__init__.py
  3. Add requirements schema to proper features file under src/tiomagic/core/schemas

And that’s it!

Structure of a Modal Provider file

If you are unfamiliar with deploying code to Modal, familiarize yourself with Modal documentation.

You can refer to src/tiomagic/providers/modal/wan_2_1_14b.py and its comments for a detailed description of a Modal Provider file. The docs are a high level description of a file:

Feature class (i.e. class I2V) consists of methods that run on modal:

Modal Provider class (i.e. Wan21TextToVideo14B) prepares user data to send to Modal. This class serves as the local client that will communicate with Modal:

Class WebAPI is the API that receives the POST request from the user and directs the request to the appropriate feature.

registry.register is a CRUCIAL function that links the feature/model/provider combination. If you don’t register each feature/model/provider combination, you will not be able to access this model and will run into errors.

How to add a new feature into an existing model

  1. Read “Structure of a Modal Provider”
  2. Create a new Feature Class
  3. Create a new Modal Provider Class
  4. Add the new feature into the WebAPI
  5. Add your new feature/model/provider combination using registry.register

Contributing New Models/Features on Local

How to add a new model on local

  1. Obtain the API key of the closed-source model you want to contribute
  2. If there is a library you must pip install for the model, add it to the dependencies list under pyproject.toml
    • When testing locally, run pip install -e . again to ensure that the dependencies are updated
  3. Add a new file under src/tiomagic/providers/local. This is where your implementation goes.
    • Refer to Structure of a Local Provider file for a breakdown of an implementation
  4. Add model to src/tiomagic/providers/local/__init__.py
  5. Add requirements schema to proper features file under src/tiomagic/core/schemas

Structure of a Local Provider file

Class ModelFeature (i.e. LumaRay2I2V):

registry.register is a CRUCIAL function that links the feature/model/provider combination. If you don’t register each feature/model/provider combination, you will not be able to access this model and will run into errors.

How to add a new feature into an existing model

  1. Read “Structure of a Local Provider”
  2. Create a new ModelFeature Class
  3. Add your new feature/model/provider combination using registry.register