コード例 #1
0
def _create_external_channel(channel, port, credentials_file):
    if credentials_file is None:
        _raise_missing_credentials_exception(channel)

    credentials = read_yaml_file(credentials_file)
    if channel == "facebook":
        input_blueprint = FacebookInput(credentials.get("verify"),
                                        credentials.get("secret"),
                                        credentials.get("page-access-token"))
    elif channel == "slack":
        input_blueprint = SlackInput(credentials.get("slack_token"),
                                     credentials.get("slack_channel"))
    elif channel == "telegram":
        input_blueprint = TelegramInput(credentials.get("access_token"),
                                        credentials.get("verify"),
                                        credentials.get("webhook_url"))
    elif channel == "mattermost":
        input_blueprint = MattermostInput(credentials.get("url"),
                                          credentials.get("team"),
                                          credentials.get("user"),
                                          credentials.get("pw"))
    elif channel == "twilio":
        input_blueprint = TwilioInput(credentials.get("account_sid"),
                                      credentials.get("auth_token"),
                                      credentials.get("twilio_number"))
    else:
        Exception("This script currently only supports the facebook,"
                  " telegram, mattermost and slack connectors.")

    return HttpInputChannel(port, None, input_blueprint)
コード例 #2
0
def run(serve_forever=True):
    model_u = "models/nlu/default/current"
    model_d = "models/dialogue"
    agent = Agent.load(model_d, interpreter=RasaNLUInterpreter(model_u))

    if serve_forever:
        # agent.handle_channel(ConsoleInputChannel())
        agent.handle_channel(HttpInputChannel(8080, "", SimpleWebChannel()))
    return agent
コード例 #3
0
def run_server(serve_forever=True):
    interpreter = RasaNLUInterpreter("models/nlu/default/current")
    agent = Agent.load("models/dialogue", interpreter=interpreter)

    if serve_forever:
        input_blueprint = CustomInputCollectingComponent(
            'http://localhost:8124/')
        input_channel = HttpInputChannel(3000, None, input_blueprint)
        agent.handle_channel(input_channel)
    return agent
コード例 #4
0
def run_weather_bot(serve_forever=True):
    interpreter = RasaNLUInterpreter('./models/nlu/default/akshay_model')
    agent = Agent.load('./models/dialogue', interpreter=interpreter)

    input_channel = SimpleWebBot()

    if serve_forever:
        agent.handle_channel(HttpInputChannel(5004, '/hi', input_channel))
        # agent.handle_channel(ConsoleInputChannel())

    return agent
コード例 #5
0
ファイル: run.py プロジェクト: tiagodanielff/rasa_core
def _create_facebook_channel(channel, port, credentials_file):
    if credentials_file is None:
        raise Exception("To use the facebook input channel, you need to "
                        "pass a credentials file using '--credentials'. "
                        "The argument should be a file path pointing to"
                        "a yml file containing the facebook authentication"
                        "information. Details in the docs: "
                        "https://core.rasa.ai/facebook.html")
    credentials = read_yaml_file(credentials_file)
    input_blueprint = FacebookInput(credentials.get("verify"),
                                    credentials.get("secret"),
                                    credentials.get("page-access-token"))

    return HttpInputChannel(port, None, input_blueprint)
コード例 #6
0
    def continue_predicting():
        """Continue a prediction started with parse.

        Caller should have executed the action returned from the parse
        endpoint. The events returned from that executed action are
        passed to continue which will trigger the next action prediction.

        If continue predicts action listen, the caller should wait for the
        next user message."""
        from rasa_core.run import create_input_channel
        from rasa_core.channels.custom_websocket import CustomInput
        input_component1=CustomInput(None)
        input_component2=CustomInput(None)
        from rasa_core.channels.websocket import WebSocketInputChannel
        global usr_channel
        global ha_channel
        try:
            usr_channel = WebSocketInputChannel(int(env_json["userchannelport"]),None,input_component1,http_ip='0.0.0.0')

            botf_input_channel = BotFrameworkInput(
                  app_id=env_json['teams_app_id'],
                    app_password=env_json['teams_app_password']
                  )
            teams_channel = HttpInputChannel(int(env_json['userchannelport2']),'/webhooks/botframework',botf_input_channel)

        except OSError as e:
            logger.error(str(e))
            return str(e)


        usr_channel.output_channel = input_component1.output_channel
        teams_channel.output_channel = botf_input_channel.output_channel

        op_agent = agent()
        op_agent.handle_custom_processor([usr_channel,teams_channel],usr_channel,processor)

        return "ok"
コード例 #7
0
def run(channel = 'console'):
    nlu = "http://localhost:5000"
    interpreter = None
    if (channel == 'console'):
        interpreter = RasaNLUInterpreter(model_directory = nluModelDir)
    else:
        interpreter = RasaNLUHttpInterpreter(model_name = "default") #, nlu)

    agent = Agent.load(modelPath, interpreter = interpreter)
    if (channel == 'console'):
        agent.handle_channel(ConsoleInputChannel())
    else:
        input_channel = CustomWebChannel()
        http_channel = HttpInputChannel(4000, '/', input_channel)
        agent.handle_channel(http_channel)
コード例 #8
0
ファイル: run.py プロジェクト: zh2010/rasa_core
def _create_external_channel(channel, port, credentials_file):
    if credentials_file is None:
        _raise_missing_credentials_Exception(channel)

    credentials = read_yaml_file(credentials_file)
    if channel == "facebook":
        input_blueprint = FacebookInput(credentials.get("verify"),
                                        credentials.get("secret"),
                                        credentials.get("page-access-token"))
    elif channel == "slack":
        input_blueprint = SlackInput(credentials.get("slack_token"),
                                     credentials.get("slack_channel"))
    else:
        Exception("This script currently only supports the facebook "
                  "and slack connectors.")

    return HttpInputChannel(port, None, input_blueprint)
コード例 #9
0
def run(serve_forever=True,port=5002, debug = False):
    domain = os.path.abspath("")
    interpreter = RasaNLUHttpInterpreter(server="http://rasanlu:5000",token = "",model_name = "",project = "")
    tracker_domain = TemplateDomain.load(os.path.abspath(""))
    tracker_store = InMemoryTrackerStore(tracker_domain)
    chat_endpoint = BotInput()
    if debug:
        input_channel = ConsoleInputChannel()
    else:
        input_channel = HttpInputChannel(port, "/ai", chat_endpoint)
    agent = Agent.load(domain,
                    interpreter=interpreter,
                    tracker_store=tracker_store)

    if serve_forever:
        agent.handle_channel(input_channel)
    return agent
コード例 #10
0
ファイル: run.py プロジェクト: osustarg/rasa_core
def create_input_channel(channel, port, credentials_file):
    """Instantiate the chosen input channel."""

    if channel == "facebook":
        if credentials_file is None:
            raise Exception("To use the facebook input channel, you need to "
                            "pass a credentials file using '--credentials'. "
                            "The argument should be a file path pointing to"
                            "a yml file containing the facebook authentication"
                            "information. Details in the docs: "
                            "https://core.rasa.ai/facebook.html")
        credentials = read_yaml_file(credentials_file)
        input_blueprint = FacebookInput(credentials.get("verify"),
                                        credentials.get("secret"),
                                        credentials.get("page-tokens"), True)
        return HttpInputChannel(port, None, input_blueprint)
    elif channel == "cmdline":
        return ConsoleInputChannel()
    else:
        raise Exception("Unknown input channel for running main.")
コード例 #11
0
ファイル: run_app.py プロジェクト: VenkatNagendra/TensorFlow
from rasa_core.channels.rest import HttpInputChannel
from rasa_core.agent import Agent
from rasa_core.interpreter import RasaNLUInterpreter
from rasa_slack_connector import SlackInput

nlu_interpreter = RasaNLUInterpreter('./models/nlu/default/assistantnlu')
agent = Agent.load('./models/dialogue', interpreter=nlu_interpreter)
input_channel = SlackInput(
    'xoxp-577750409252-577782185266-623450917824-9f928829e771f94acc084958e634f15a',
    'xoxb-577750409252-611978780099-2gV3498zVOYKckxFbbxtuTKP',
    'n98DSijgCdAVc4DJ2oL9VPtt', True)
agent.handle_channel(HttpInputChannel(5004, '/', input_channel))
コード例 #12
0
def _create_bot_channel(port):
    input_blueprint = BotInput()
    return HttpInputChannel(port, None, input_blueprint)
コード例 #13
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)
コード例 #14
0
from rasa_core.channels.rest import HttpInputChannel
from rasa_core.channels.console import ConsoleInputChannel
from rasa_core.channels.facebook import FacebookInput
from rasa_core.channels.custom import CustomInput
from rasa_core.agent import Agent
from rasa_core.interpreter import RasaNLUInterpreter
from botlerchannel import SimpleWebBot
# load your trained agent

agent = Agent.load("models/dialouge",
                   interpreter=RasaNLUInterpreter("models/default/current",
                                                  "nlu_model_config.json"))
input_channel = SimpleWebBot()
agent.handle_channel(HttpInputChannel(5050, "/app", input_channel))