def print_bot_output( message: Dict[Text, Any], is_latest_message: bool = False, color=cli_utils.bcolors.OKBLUE, ) -> Optional[questionary.Question]: if "buttons" in message: question = print_buttons(message, is_latest_message, color) if question: return question if "text" in message: cli_utils.print_color(message.get("text"), color=color) if "image" in message: cli_utils.print_color("Image: " + message.get("image"), color=color) if "attachment" in message: cli_utils.print_color("Attachment: " + message.get("attachment"), color=color) if "elements" in message: cli_utils.print_color("Elements:", color=color) for idx, element in enumerate(message.get("elements")): cli_utils.print_color( cli_utils.element_to_string(element, idx), color=color ) if "quick_replies" in message: cli_utils.print_color("Quick Replies:", color=color) for idx, element in enumerate(message.get("quick_replies")): cli_utils.print_color(cli_utils.button_to_string(element, idx), color=color) if "custom" in message: cli_utils.print_color("Custom json:", color=color) cli_utils.print_color(json.dumps(message.get("custom"), indent=2), color=color)
def _bot_output( message: Dict[Text, Any], color=cli_utils.bcolors.OKBLUE) -> Optional[questionary.Question]: from sagas.nlu.tts_utils import say_lang # from sagas.kit.analysis_kit import AnalysisKit if ("text" in message) and not ("buttons" in message): text = message.get("text") cli_utils.print_color(text, color=color) say_lang(text, sett.lang, False) # AnalysisKit().console_vis(text, sett.lang) if "image" in message: cli_utils.print_color("Image: " + message.get("image"), color=color) if "attachment" in message: cli_utils.print_color("Attachment: " + message.get("attachment"), color=color) if "buttons" in message: choices = cli_utils.button_choices_from_message_data( message, allow_free_text_input=True) question = questionary.select( message.get("text"), choices, style=Style([("qmark", "#6d91d3"), ("", "#6d91d3"), ("answer", "#b373d6")]), ) return question if "elements" in message: cli_utils.print_color("Elements:", color=color) for idx, element in enumerate(message.get("elements")): cli_utils.print_color(cli_utils.element_to_string(element, idx), color=color) if "quick_replies" in message: cli_utils.print_color("Quick Replies:", color=color) for idx, element in enumerate(message.get("quick_replies")): cli_utils.print_color(cli_utils.button_to_string(element, idx), color=color) if "custom" in message: cli_utils.print_color("Custom json:", color=color) cli_utils.print_color(json.dumps(message.get("custom"), indent=2), color=color)
def _print_bot_output( message: Dict[Text, Any], is_latest_message: bool = False, color: Text = rasa.shared.utils.io.bcolors.OKBLUE, ) -> Optional[questionary.Question]: if "buttons" in message: question = print_buttons(message, is_latest_message, color) if question: return question if "text" in message: rasa.shared.utils.cli.print_color(message["text"], color=color) if "image" in message: rasa.shared.utils.cli.print_color("Image: " + message["image"], color=color) if "attachment" in message: rasa.shared.utils.cli.print_color("Attachment: " + message["attachment"], color=color) if "elements" in message: rasa.shared.utils.cli.print_color("Elements:", color=color) for idx, element in enumerate(message["elements"]): rasa.shared.utils.cli.print_color(cli_utils.element_to_string( element, idx), color=color) if "quick_replies" in message: rasa.shared.utils.cli.print_color("Quick Replies:", color=color) for idx, element in enumerate(message["quick_replies"]): rasa.shared.utils.cli.print_color(cli_utils.button_to_string( element, idx), color=color) if "custom" in message: rasa.shared.utils.cli.print_color("Custom json:", color=color) rasa.shared.utils.cli.print_color(json.dumps(message["custom"], indent=2), color=color) return None
def print_bot_output( message: Dict[Text, Any], color=cli_utils.bcolors.OKBLUE) -> Optional[questionary.Question]: if ("text" in message) and not ("buttons" in message): cli_utils.print_color(message.get("text"), color=color) if "image" in message: cli_utils.print_color("Image: " + message.get("image"), color=color) if "attachment" in message: cli_utils.print_color("Attachment: " + message.get("attachment"), color=color) if "buttons" in message: choices = cli_utils.button_choices_from_message_data( message, allow_free_text_input=True) question = questionary.select( message.get("text"), choices, style=Style([("qmark", "#6d91d3"), ("", "#6d91d3"), ("answer", "#b373d6")]), ) return question if "elements" in message: cli_utils.print_color("Elements:", color=color) for idx, element in enumerate(message.get("elements")): cli_utils.print_color(cli_utils.element_to_string(element, idx), color=color) if "quick_replies" in message: cli_utils.print_color("Quick Replies:", color=color) for idx, element in enumerate(message.get("quick_replies")): cli_utils.print_color(cli_utils.button_to_string(element, idx), color=color) if "custom" in message: cli_utils.print_color("Custom json:", color=color) cli_utils.print_color(json.dumps(message.get("custom"), indent=2), color=color)