rasa/core/training/interactive.py
async def record_messages(endpoint: EndpointConfig,
                          sender_id: Text = UserMessage.DEFAULT_SENDER_ID,
                          max_message_limit: Optional[int] = None,
                          finetune: bool = False,
                          stories: Optional[Text] = None,
                          skip_visualization: bool = False
                          ):
    """Read messages from the command line and print bot responses."""

    from rasa.core import training

    try:
        _print_help(skip_visualization)

        try:
            domain = await retrieve_domain(endpoint)
        except ClientError:
            logger.exception("Failed to connect to Rasa Core server at '{}'. "
                             "Is the server running?".format(endpoint.url))
            return

        trackers = await training.load_data(stories, Domain.from_dict(domain),
                                            augmentation_factor=0,
                                            use_story_concatenation=False,
                                            )

        intents = [next(iter(i)) for i in (domain.get("intents") or [])]

        num_messages = 0
        sender_ids = [t.events for t in trackers] + [sender_id]

        if not skip_visualization:
            plot_file = "story_graph.dot"
            await _plot_trackers(sender_ids, plot_file, endpoint)
        else:
            plot_file = None

        while not utils.is_limit_reached(num_messages, max_message_limit):
            try:
                if await is_listening_for_message(sender_id, endpoint):
                    await _enter_user_message(sender_id, endpoint)
                    await _validate_nlu(intents, endpoint, sender_id)
                await _predict_till_next_listen(endpoint, sender_id,
                                                finetune, sender_ids, plot_file)

                num_messages += 1
            except RestartConversation:
                await send_event(endpoint, sender_id,
                                 Restarted().as_dict())

                await send_event(endpoint, sender_id,
                                 ActionExecuted(ACTION_LISTEN_NAME).as_dict())

                logger.info("Restarted conversation, starting a new one.")
            except UndoLastStep:
                await _undo_latest(sender_id, endpoint)
                await _print_history(sender_id, endpoint)
            except ForkTracker:
                await _print_history(sender_id, endpoint)

                evts_fork = await _request_fork_from_user(sender_id, endpoint)

                await send_event(endpoint, sender_id,
                                 Restarted().as_dict())

                if evts_fork:
                    for evt in evts_fork:
                        await send_event(endpoint, sender_id, evt)
                logger.info("Restarted conversation at fork.")

                await _print_history(sender_id, endpoint)
                await _plot_trackers(sender_ids, plot_file, endpoint)

    except Abort:
        return
    except Exception:
        logger.exception("An exception occurred while recording messages.")
        raise
Read messages from the command line and print bot responses.
Read messages from the command line and print bot responses.
Read messages from the command line and print bot responses .
async def record_messages(endpoint: EndpointConfig,
                          sender_id: Text = UserMessage.DEFAULT_SENDER_ID,
                          max_message_limit: Optional[int] = None,
                          finetune: bool = False,
                          stories: Optional[Text] = None,
                          skip_visualization: bool = False
                          ):
    from rasa.core import training
    try:
        _print_help(skip_visualization)
        try:
            domain = await retrieve_domain(endpoint)
        except ClientError:
            logger.exception("Failed to connect to Rasa Core server at '{}'. "
                             "Is the server running?".format(endpoint.url))
            return
        trackers = await training.load_data(stories, Domain.from_dict(domain),
                                            augmentation_factor=0,
                                            use_story_concatenation=False,
                                            )
        intents = [next(iter(i)) for i in (domain.get("intents") or [])]
        num_messages = 0
        sender_ids = [t.events for t in trackers] + [sender_id]
        if not skip_visualization:
            plot_file = "story_graph.dot"
            await _plot_trackers(sender_ids, plot_file, endpoint)
        else:
            plot_file = None
        while not utils.is_limit_reached(num_messages, max_message_limit):
            try:
                if await is_listening_for_message(sender_id, endpoint):
                    await _enter_user_message(sender_id, endpoint)
                    await _validate_nlu(intents, endpoint, sender_id)
                await _predict_till_next_listen(endpoint, sender_id,
                                                finetune, sender_ids, plot_file)
                num_messages += 1
            except RestartConversation:
                await send_event(endpoint, sender_id,
                                 Restarted().as_dict())
                await send_event(endpoint, sender_id,
                                 ActionExecuted(ACTION_LISTEN_NAME).as_dict())
                logger.info("Restarted conversation, starting a new one.")
            except UndoLastStep:
                await _undo_latest(sender_id, endpoint)
                await _print_history(sender_id, endpoint)
            except ForkTracker:
                await _print_history(sender_id, endpoint)
                evts_fork = await _request_fork_from_user(sender_id, endpoint)
                await send_event(endpoint, sender_id,
                                 Restarted().as_dict())
                if evts_fork:
                    for evt in evts_fork:
                        await send_event(endpoint, sender_id, evt)
                logger.info("Restarted conversation at fork.")
                await _print_history(sender_id, endpoint)
                await _plot_trackers(sender_ids, plot_file, endpoint)
    except Abort:
        return
    except Exception:
        logger.exception("An exception occurred while recording messages.")
        raise
async def record_messages ( endpoint : EndpointConfig , sender_id : Text = UserMessage . DEFAULT_SENDER_ID , max_message_limit : Optional [ int ] = None , finetune : bool = False , stories : Optional [ Text ] = None , skip_visualization : bool = False ) : from rasa . core import training try : _print_help ( skip_visualization ) try : domain = await retrieve_domain ( endpoint ) except ClientError : logger . exception ( "Failed to connect to Rasa Core server at '{}'. " "Is the server running?" . format ( endpoint . url ) ) return trackers = await training . load_data ( stories , Domain . from_dict ( domain ) , augmentation_factor = 0 , use_story_concatenation = False , ) intents = [ next ( iter ( i ) ) for i in ( domain . get ( "intents" ) or [ ] ) ] num_messages = 0 sender_ids = [ t . events for t in trackers ] + [ sender_id ] if not skip_visualization : plot_file = "story_graph.dot" await _plot_trackers ( sender_ids , plot_file , endpoint ) else : plot_file = None while not utils . is_limit_reached ( num_messages , max_message_limit ) : try : if await is_listening_for_message ( sender_id , endpoint ) : await _enter_user_message ( sender_id , endpoint ) await _validate_nlu ( intents , endpoint , sender_id ) await _predict_till_next_listen ( endpoint , sender_id , finetune , sender_ids , plot_file ) num_messages += 1 except RestartConversation : await send_event ( endpoint , sender_id , Restarted ( ) . as_dict ( ) ) await send_event ( endpoint , sender_id , ActionExecuted ( ACTION_LISTEN_NAME ) . as_dict ( ) ) logger . info ( "Restarted conversation, starting a new one." ) except UndoLastStep : await _undo_latest ( sender_id , endpoint ) await _print_history ( sender_id , endpoint ) except ForkTracker : await _print_history ( sender_id , endpoint ) evts_fork = await _request_fork_from_user ( sender_id , endpoint ) await send_event ( endpoint , sender_id , Restarted ( ) . as_dict ( ) ) if evts_fork : for evt in evts_fork : await send_event ( endpoint , sender_id , evt ) logger . info ( "Restarted conversation at fork." ) await _print_history ( sender_id , endpoint ) await _plot_trackers ( sender_ids , plot_file , endpoint ) except Abort : return except Exception : logger . exception ( "An exception occurred while recording messages." ) raise
Read messages from the command line and print bot responses.
Read messages from the command line and print bot responses .
"""Read messages from the command line and print bot responses."""
endpoint
EndpointConfig
sender_id
Text
max_message_limit
Optional[int]
finetune
bool
stories
Optional[Text]
skip_visualization
bool