Serve Module

This guide will show you how to import, extend and implement necessary methods of Tru AI Serve Module, so you will be able to load your custom model and do prediction through Tru AI Model API.

Configuration

To start using the Serve module you need to first import the packages

  from gjirafatech.truai.serve import TruServe, TruRequestModel

After importing the packages you have to initialize an object of the TruServe class and create a class that extends TruRequestModel whose properties will be used in predict function.

  from gjirafatech.truai.serve import TruServe, TruRequestModel

class CustomModel(TruServe):
    def __init__(self):
        super(CustomModel,  self).__init__();

class RequestBody(TruRequestModel):
       pass

The custom model class that you create must have the implementation of two methods:

  1. load

  2. predict

  def load(self):
   pass

def predict(self, request: RequestBody):
   pass

To deploy this model that you created you can refer to this article.

With by the Tru AI team © GjirafaTech 2022