def respond(self, ctx: Context):
        forms = {}  # todo: extract our own forms with regexes
        if ctx.yandex:
            forms = extract_yandex_forms(ctx.yandex)
        intents = {intent_name: 1 for intent_name in forms}
        if tgalice.nlu.basic_nlu.like_help(ctx.message_text):
            intents['help'] = 1

        print(f"Intents: {intents}")
        print(f"Forms: {forms}")
        turn = RzdTurn(ctx=ctx,
                       text=fast_normalize(ctx.message_text),
                       intents=intents,
                       forms=forms)
        handler_name = self.cascade(turn)
        print(f"Handler name: {handler_name}")
        self.cascade.postprocess(turn)
        print()
        return turn.make_response()
Пример #2
0
 def respond(self, ctx: Context):
     t0 = time.time()
     text, forms, intents = self.nlu(ctx)
     turn = RzdTurn(
         ctx=ctx,
         text=text,
         intents=intents,
         forms=forms,
         user_object=ctx.user_object,
         rasp_api=self.rasp_api,
         world=self.world,
     )
     logger.debug(f'current stage is: {turn.stage}')
     handler_name = self.cascade(turn)
     print(f"Handler name: {handler_name}")
     self.cascade.postprocess(turn)
     resp = turn.make_response()
     logger.debug(f'FULL RESPONSE TIME: {time.time() - t0}')
     return resp