コード例 #1
0
ファイル: conftest.py プロジェクト: prenigma/testfou
def core_server_secured(default_agent):
    app = server.create_app(default_agent,
                            auth_token="rasa",
                            jwt_secret="core")
    channel.register([RestInput()], app, default_agent.handle_message,
                     "/webhooks/")
    return app
コード例 #2
0
async def core_server_secured(prepared_agent):
    app = server.create_app(prepared_agent,
                            auth_token="rasa",
                            jwt_secret="core")
    channel.register([RestInput()],
                     app,
                     "/webhooks/")
    return app
コード例 #3
0
ファイル: conftest.py プロジェクト: prenigma/testfou
def core_server(tmpdir_factory):
    model_path = tmpdir_factory.mktemp("model").strpath

    agent = Agent("data/test_domains/default.yml",
                  policies=[AugmentedMemoizationPolicy(max_history=3)])

    training_data = agent.load_data(DEFAULT_STORIES_FILE)
    agent.train(training_data)
    agent.persist(model_path)

    loaded_agent = Agent.load(model_path, interpreter=RegexInterpreter())

    app = server.create_app(loaded_agent)
    channel.register([RestInput()], app, agent.handle_message, "/webhooks/")
    return app
コード例 #4
0
    def handle_channels(self,
                        channels,
                        http_port=constants.DEFAULT_SERVER_PORT,
                        serve_forever=True):
        # type: (List[InputChannel], int, bool) -> WSGIServer
        """Start a webserver attaching the input channels and handling msgs.
		If ``serve_forever`` is set to ``True``, this call will be blocking.
		Otherwise the webserver will be started, and the method will
		return afterwards."""
        from flask import Flask

        application = Flask(__name__)
        channel.register(channels,
                         application,
                         super(CustomAgent, self).handle_message,
                         route="/webhooks/")

        http_server = WSGIServer(('0.0.0.0', http_port), application)
        http_server.start()

        if serve_forever:
            http_server.serve_forever()
        return http_server
コード例 #5
0
async def core_server(prepared_agent):
    app = server.create_app(prepared_agent)
    channel.register([RestInput()],
                     app,
                     "/webhooks/")
    return app
コード例 #6
0
ファイル: web.py プロジェクト: ThewApp/gentle-naiad
from flask import Flask
from rasa_core.channels import channel
from rasa_core.interpreter import RasaNLUInterpreter

import app.logging
from rasa.lineagent import LineAgent
from rasa.lineconnector import LineInput
from rasa.store import scheduler_store, tracker_store

logger = logging.getLogger(__name__)

line_secret = os.getenv('LINE_CHANNEL_SECRET', None)
line_access_token = os.getenv('LINE_CHANNEL_ACCESS_TOKEN', None)

app = Flask(__name__)

agent = LineAgent.load("models/dialogue",
                       interpreter=RasaNLUInterpreter("models/current/nlu"),
                       tracker_store=tracker_store)

line_input_channel = LineInput(line_secret=line_secret,
                               line_access_token=line_access_token)

channel.register([line_input_channel],
                 app,
                 agent.handle_message,
                 route="/webhooks/")

logger.info("Web is ready.")