Beispiel #1
0
def test_remote_client(http_app, default_agent, tmpdir):
    model_path = tmpdir.join("persisted_model").strpath

    default_agent.persist(model_path)

    remote_agent = RemoteAgent.load(model_path, EndpointConfig(http_app))

    message = UserMessage("""/greet{"name":"Rasa"}""",
                          output_channel=CollectingOutputChannel())

    remote_agent.process_message(message)

    tracker = remote_agent.core_client.tracker_json("default")

    assert len(tracker.get("events")) == 6

    # listen
    assert tracker["events"][0]["name"] == "action_listen"
    # this should be the utterance
    assert tracker["events"][1]["text"] == """/greet{"name":"Rasa"}"""
    # set slot event
    assert tracker["events"][2]["value"] == "Rasa"
    # utter action
    assert tracker["events"][3]["name"] == "utter_greet"
    # this should be the bot utterance
    assert tracker["events"][4]["text"] == "hey there Rasa!"
    # listen
    assert tracker["events"][5]["name"] == "action_listen"
Beispiel #2
0
def run_remote():
    from rasa_core.remote import RemoteAgent
    from rasa_core.utils import EndpointConfig

    logging.basicConfig(level="DEBUG")

    from rasa_core.channels.rasa_chat import RasaChatInput
    from rasa_addons.webchat import WebChatInput, SocketInputChannel

    # definte the input channels for the platform and the chat widget
    rasa_in = RasaChatInput(config.platform_api)
    widget_in = WebChatInput(static_assets_path=os.path.join(
                os.path.dirname(os.path.realpath(__file__)), 'static'))
    input_channel = SocketInputChannel(config.self_port, "/",
                                       rasa_in, widget_in)

    # define the core endpoint
    core_endpoint_config = EndpointConfig(
        url=config.remote_core_endpoint,
        token=config.rasa_core_token
    )

    # define the nlg endpoint
    nlg_endpoint_config = EndpointConfig(
        url=config.rasa_nlg_endpoint,
        token=config.rasa_platform_token
    )

    # start the remote agent
    agent = RemoteAgent.load(config.core_model_dir,
                             core_endpoint=core_endpoint_config,
                             nlg_endpoint=nlg_endpoint_config
                             )

    agent.handle_channel(input_channel)
Beispiel #3
0
def run_remote():
    from rasa_core.remote import RemoteAgent
    from rasa_core.utils import EndpointConfig

    logging.basicConfig(level="DEBUG")

    from rasa_core.channels.rasa_chat import RasaChatInput
    from rasa_addons.webchat import WebChatInput, SocketInputChannel

    # definte the input channels for the platform and the chat widget
    rasa_in = RasaChatInput(config.platform_api)
    widget_in = WebChatInput(static_assets_path=os.path.join(
        os.path.dirname(os.path.realpath(__file__)), 'static'))
    input_channel = SocketInputChannel(config.self_port, "/", rasa_in,
                                       widget_in)

    # define the core endpoint
    core_endpoint_config = EndpointConfig(url=config.remote_core_endpoint,
                                          token=config.rasa_core_token)

    # define the nlg endpoint
    nlg_endpoint_config = EndpointConfig(url=config.rasa_nlg_endpoint,
                                         token=config.rasa_platform_token)

    # start the remote agent
    agent = RemoteAgent.load(config.core_model_dir,
                             core_endpoint=core_endpoint_config,
                             nlg_endpoint=nlg_endpoint_config)

    agent.handle_channel(input_channel)
Beispiel #4
0
def run_remote():
    from rasa_core.remote import RemoteAgent

    logging.basicConfig(level="DEBUG")

    from rasa_extensions.core.channels.rasa_chat import RasaChatInput
    from rasa_addons.webchat import WebChatInput, SocketInputChannel

    rasa_in = RasaChatInput(config.platform_api)
    widget_in = WebChatInput(static_assets_path=os.path.join(
        os.path.dirname(os.path.realpath(__file__)), 'static'))
    input_channel = SocketInputChannel(config.self_port, "/", rasa_in,
                                       widget_in)

    agent = RemoteAgent.load(config.core_model_dir,
                             config.remote_core_endpoint,
                             config.rasa_core_token)

    agent.handle_channel(input_channel)
Beispiel #5
0
import logging
import os

from rasa_core.channels.rest import HttpInputChannel
from rasa_core.remote import RemoteAgent

if __name__ == "__main__":
    logging.basicConfig(level="DEBUG")

    # instantiate the input channel you want to connect to
    from rasa_extensions.core.channels.rasa_chat import RasaChatInput

    input_channel = HttpInputChannel(
        5001, "/", RasaChatInput(os.environ.get("RASA_API_ENDPOINT_URL")))

    agent = RemoteAgent.load('models/dialogue',
                             os.environ.get("RASA_REMOTE_CORE_ENDPOINT_URL"),
                             os.environ.get("RASA_CORE_TOKEN"))

    agent.handle_channel(input_channel)