Exemplo n.º 1
0
def handler(stt: str, user_id: str):
    stt = stt.lower()
    try:
        if stt.lower() == 'spiel beenden':
            with CircuitBreakerSession() as session:
                session.delete(
                    'https://n3i39w6xtc.execute-api.eu-west-1.amazonaws.com/prod/delsession?id='
                    + user_id)
            return tell("Auf Wiedersehen. bis bald")
        logger = logging.getLogger(__name__)
        logger.info("**** CVI Context = " + str(context))
        with CircuitBreakerSession() as session:
            logger.info("**** user_hash = " + str(user_id))
            response = session.get(
                'https://hi4m6llff6.execute-api.eu-west-1.amazonaws.com/prod/a?id='
                + user_id + '&stt=' + stt)
        return ask_freetext(response.text)
    except Exception as e:
        logger.info("**** Exception = " + str(e))
        return ask_freetext("Es ist ein Fehler aufgetreten!")
Exemplo n.º 2
0
def handle_user_answer(stt: Text) -> Response:
    """
    Send user response to Rasa server and speak out the output

    :param stt:     STT response
    :param zipcode: Device ZIP code
    :return:
    """
    LOGGER.debug('STT text: %s, intent: %s, session: %s', stt,
                 context.intent_name, context.session.session_id)

    server_url = config.get('rasa', 'server_url', fallback=DEFAULT_SERVER_URL)
    response = send_message_receive_block(server_url,
                                          context.session.session_id, stt)
    LOGGER.debug('Response from Rasa: %s', repr(response))

    text, card = format_bot_output(response)
    LOGGER.debug('Formatted output: %s, with card: %s', repr(text), repr(card))

    return ask_freetext(text, card=card)
Exemplo n.º 3
0
def virtual_teacher_handler(answer: str):
    logger = logging.getLogger(__name__)
    logger.info("**** Start Context = " + str(context))
    return ask_freetext(
        "Hallo! Was möchtest du heute machen? Ich kann dir Algebra oder Geometrie Aufgaben anbieten oder einige Fitness Übungen zeigen."
    )
Exemplo n.º 4
0
 def test_ask_freetext(self):
     """ Check is responses.ask returns Response(type_=RESPONSE_TYPE_ASK_FREETEXT)
     """
     r = ask_freetext('Question')
     self.assertIsInstance(r, Response)
     self.assertEqual(r.type_, RESPONSE_TYPE_ASK_FREETEXT)