Skip to content

Commit

Permalink
endpoints option
Browse files Browse the repository at this point in the history
  • Loading branch information
rgstephens committed Sep 26, 2023
1 parent 51b226f commit 72700c2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions rasa_sdk/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def main_from_args(args):
args.ssl_keyfile,
args.ssl_password,
args.auto_reload,
args.endpoints,
tracer_provider,
)

Expand Down
5 changes: 5 additions & 0 deletions rasa_sdk/cli/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,8 @@ def add_endpoint_arguments(parser):
help="Enable auto-reloading of modules containing Action subclasses.",
action="store_true",
)
parser.add_argument(
"--endpoints",
default=None,
help="Provide endpoints file.",
)
8 changes: 6 additions & 2 deletions rasa_sdk/endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def create_app(
action_package_name: Union[Text, types.ModuleType],
cors_origins: Union[Text, List[Text], None] = "*",
auto_reload: bool = False,
endpoints: Optional[Text] = None,
tracer_provider: Optional[TracerProvider] = None,
) -> Sanic:
"""Create a Sanic application and return it.
Expand Down Expand Up @@ -107,8 +108,9 @@ async def webhook(request: Request) -> HTTPResponse:
action_call = json.loads(decompressed_data)
else:
action_call = request.json
action_call["domain"]["tracer"] = tracer
action_call["domain"]["context"] = context
if "domain" in action_call:
action_call["domain"]["tracer"] = tracer
action_call["domain"]["context"] = context
if action_call is None:
body = {"error": "Invalid body request"}
return response.json(body, status=400)
Expand Down Expand Up @@ -161,6 +163,7 @@ def run(
ssl_keyfile: Optional[Text] = None,
ssl_password: Optional[Text] = None,
auto_reload: bool = False,
endpoints: Optional[Text] = None,
tracer_provider: Optional[TracerProvider] = None,
) -> None:
"""Starts the action endpoint server with given config values."""
Expand All @@ -169,6 +172,7 @@ def run(
action_package_name,
cors_origins=cors_origins,
auto_reload=auto_reload,
endpoints=endpoints,
tracer_provider=tracer_provider,
)
## Attach additional sanic extensions: listeners, middleware and routing
Expand Down
2 changes: 2 additions & 0 deletions rasa_sdk/tracing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def get_tracer_provider(
tracer_provider = None
endpoints_file = ""
if "endpoints" in cmdline_arguments:
logger.debug(f"Processing cmdline endpoints file: {cmdline_arguments.endpoints}")
logger.debug(f"cmdline_arguments: {cmdline_arguments}")
endpoints_file = cmdline_arguments.endpoints

if endpoints_file is not None:
Expand Down

0 comments on commit 72700c2

Please sign in to comment.