Functional
explain(request)
async
Explain route that expose a model explainer in charge of model explicability
This function is using starlette Request object instead of pydantic since we can not know what data your model is expecting. See https://fastapi.tiangolo.com/advanced/using-request-directly/ for more infos.
We also use the custom starlette JSONResponse class (PredictionResponse) instead of pydantic for the same reasons
For a cleaner way to handle requests and reponses you should use pydantic as stated in FastAPI doc : https://fastapi.tiangolo.com/tutorial/body/#create-your-data-model
You can use routes from example_api_num.routers.technical as examples of how to create requests and responses schemas thanks to pydantic or have a look at the FastAPI documentation : https://fastapi.tiangolo.com/tutorial/response-model/
If there is not explainer or the explainer does not implement explain_as_json or explain_as_html we return a 501 HTTP error : https://developer.mozilla.org/fr/docs/Web/HTTP/Status/501
Source code in template_api/routers/functional.py
predict(request)
async
Predict route that exposes your model
This function is using starlette Request object instead of pydantic since we can not know what data your model is expecting. See https://fastapi.tiangolo.com/advanced/using-request-directly/ for more infos.
We also use a custom starlette JSONResponse class (NumpyJSONResponse) instead of pydantic for the same reasons
For a cleaner way to handle requests and reponses you should use pydantic as stated in FastAPI doc : https://fastapi.tiangolo.com/tutorial/body/#create-your-data-model
You can use routes from template_api.routers.technical as examples of how to create requests and responses schemas thanks to pydantic or have a look at the FastAPI documentation : https://fastapi.tiangolo.com/tutorial/response-model/