1. Learn
  2. /
  3. Courses
  4. /
  5. Deploying AI into Production with FastAPI

Connected

Exercise

Validate request and response for ML prediction

Building on your work as a data scientist at the coffee company, you now need to create a FastAPI endpoint that validates input request using CoffeeQualityInput data validation model and a QualityPrediction for response validation.

This endpoint will accept coffee data and return a quality prediction along with the confidence score.

The model is already loaded into a function called predict_quality for this exercise.

Instructions

100 XP
  • Define CoffeeQualityInput with fields aroma (float), flavor (float), and altitude (int).
  • Specify the response_model to validate the response within the POST request decorator.
  • Specify the data model to validate input request containing the coffee_data.