You can create a custom endpoint for your REST API that handles the data massaging before calling the
model.predict function. This endpoint can take in the primary key as an input, retrieve the additional features from the database based on that key, and then pass the complete set of features to the
model.predict function.
You can use a web framework like Flask or FastAPI to create the custom endpoint. For example, you can create a function that retrieves the additional features like lead enrichment from the database and calls the model.predict
function, and then use this function as a route in your Flask or FastAPI app. The client application can then send a request to this custom endpoint with the primary key, and the endpoint will return the prediction based on the retrieved features.
You can also use mlflow's Model.call() method to invoke your custom function.
You can also use Serverless Framework or other similar tools to deploy this function and expose it through an API Gateway