def input_fn()

in models/model-a/src/code/inference.py [0:0]


def input_fn(serialized_input_data, content_type=_content_type_json):
    logger.info('input_fn: Deserializing the input data.')

    if content_type == _content_type_json:
        input_data = json.loads(serialized_input_data)
        if 'sentence' not in input_data:
            raise Exception('Requested input data did not contain sentence')
        
        sentence = input_data['sentence']
        return sentence
    
    raise Exception('Requested unsupported ContentType in content_type: ' + content_type)