
import pandas as pd

from sagemaker.pytorch.model import PyTorchPredictor
from sagemaker.deserializers import JSONDeserializer
from sagemaker.serializers import JSONSerializer
from sagemaker.predictor_async import AsyncPredictor
from sagemaker.predictor import Predictor


def get_probs(endpoint_key, sentences, question):
    
    if type(question) != str:
        raise TypeError("questions parameter must be of type str, with string values inside of that list!")
    
    data = {"sentences" : sentences,
                 "questions": [question]}
    
    predictor = Predictor(endpoint_name=endpoint_key, serializer=JSONSerializer(), deserializer=JSONDeserializer())
    async_predictor = AsyncPredictor(predictor)
    
    
    result = async_predictor.predict_async(data, "s3://ask-t5-stage/async_inference/ip")
    return result

