from typing import Dict
import requests


def get_intent_probabilities(sentence: str, endpoint: str = 'http://localhost:8080/api/intent') -> Dict[str, float]:
    """
    Return the probabilities for each intent for the specified sentence.
    It raises a RuntimeError if the status code to the GET request is anything other than HTTP_OK.

    Parameters
    -----------
    - **sentence**: the sentence whose intent is to be guessed
    - **endpoint**: (*optional*) the intent route to the endpoint, default to localhost route on port 8080.

    Return
    -----------
    A dictionnary where the keys are the intent-class and the values are the probabilities.
    """
    r = requests.get(endpoint + '?sentence=' + sentence)
    if r.status_code == 200:
        result = r.json()
    else:
        raise RuntimeError("Couldn't parse sentence")
    return result