Skip to content

Commit

Permalink
remove /flows endpoint and add hook
Browse files Browse the repository at this point in the history
  • Loading branch information
m-vdb committed Sep 20, 2023
1 parent 5c05800 commit 4e0bfae
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
11 changes: 11 additions & 0 deletions rasa/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@
from rasa.shared.nlu.training_data.message import Message

if TYPE_CHECKING:
from sanic import Sanic

from rasa.core.brokers.broker import EventBroker
from rasa.core.tracker_store import TrackerStore
from rasa.core.utils import AvailableEndpoints
from rasa.engine.graph import SchemaNode
from rasa.shared.core.domain import Domain
from rasa.utils.endpoints import EndpointConfig
Expand Down Expand Up @@ -150,6 +153,14 @@ def get_license_hash() -> Optional[Text]:
"""Hook specification for getting the license hash."""


@hookspec # type: ignore[misc]
def configure_server(app: "Sanic", auth_token: Optional[Text], endpoints: Optional["AvailableEndpoints"]) -> None:

Check failure on line 157 in rasa/plugin.py

View workflow job for this annotation

GitHub Actions / Code Quality

E501 Line too long (114 > 88 characters)
"""Hook specification for configuring the server.
Use this hook to add extra configuration on the server.
"""


@hookspec # type: ignore[misc]
def after_server_stop() -> None:
"""Hook specification for stopping the server.
Expand Down
10 changes: 2 additions & 8 deletions rasa/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import rasa
import rasa.core.utils
from rasa.nlu.emulators.emulator import Emulator
from rasa.plugin import plugin_manager
import rasa.utils.common
import rasa.shared.utils.common
import rasa.shared.utils.io
Expand Down Expand Up @@ -1372,14 +1373,6 @@ async def unload_model(request: Request) -> HTTPResponse:
logger.debug(f"Successfully unloaded model '{model_file}'.")
return response.json(None, status=HTTPStatus.NO_CONTENT)

@app.get("/flows")
@requires_auth(app, auth_token)
async def get_flows(request: Request) -> HTTPResponse:
"""Get all the flows currently stored by the agent."""
processor = app.ctx.agent.processor
flows = processor.get_flows()
return response.json(flows.as_json())

@app.get("/domain")
@requires_auth(app, auth_token)
@ensure_loaded_agent(app)
Expand Down Expand Up @@ -1407,6 +1400,7 @@ async def get_domain(request: Request) -> HTTPResponse:
f"header.",
)

plugin_manager().hook.configure_server(app, auth_token, endpoints)
return app


Expand Down

0 comments on commit 4e0bfae

Please sign in to comment.