def test_list_routes(default_agent): from rasa.core import server app = server.create_app(default_agent, auth_token=None) routes = utils.list_routes(app) assert set(routes.keys()) == { "hello", "version", "execute_action", "append_event", "replace_events", "list_trackers", "retrieve_tracker", "retrieve_story", "respond", "predict", "parse", "train_stack", "evaluate_intents", "log_message", "load_model", "evaluate_stories", "get_domain", "continue_training", "status", "tracker_predict", }
def configure_app( input_channels=None, cors=None, auth_token=None, enable_api=True, jwt_secret=None, jwt_method=None, route="/webhooks/", port=None, ): """Run the agent.""" from rasa.core import server if enable_api: app = server.create_app( cors_origins=cors, auth_token=auth_token, jwt_secret=jwt_secret, jwt_method=jwt_method, ) else: app = Sanic(__name__) CORS(app, resources={r"/*": { "origins": cors or "" }}, automatic_options=True) if input_channels: rasa.core.channels.channel.register(input_channels, app, route=route) else: input_channels = [] if logger.isEnabledFor(logging.DEBUG): utils.list_routes(app) # configure async loop logging async def configure_logging(): if logger.isEnabledFor(logging.DEBUG): rasa.utils.io.enable_async_loop_debugging(asyncio.get_event_loop()) app.add_task(configure_logging) if "cmdline" in {c.name() for c in input_channels}: async def run_cmdline_io(running_app: Sanic): """Small wrapper to shut down the server once cmd io is done.""" await asyncio.sleep(1) # allow server to start await console.record_messages( server_url=constants.DEFAULT_SERVER_FORMAT.format(port)) logger.info("Killing Sanic server now.") running_app.stop() # kill the sanic serverx app.add_task(run_cmdline_io) return app
def test_list_routes(default_agent): from rasa.core import server app = server.create_app(default_agent, auth_token=None) routes = utils.list_routes(app) assert set(routes.keys()) == { 'hello', 'version', 'execute_action', 'append_event', 'replace_events', 'list_trackers', 'retrieve_tracker', 'retrieve_story', 'respond', 'predict', 'parse', 'train_stack', 'evaluate_intents', 'log_message', 'load_model', 'evaluate_stories', 'get_domain', 'continue_training', 'status', 'tracker_predict' }
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
async def core_server(prepared_agent): app = server.create_app(prepared_agent) channel.register([RestInput()], app, "/webhooks/") return app