diff --git a/pyproject.toml b/pyproject.toml index a0a5d160f10b..5bccf33762ad 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,7 +18,7 @@ repository = "https://github.com/rasahq/rasa" documentation = "https://rasa.com/docs" classifiers = [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "Topic :: Software Development :: Libraries",] keywords = [ "nlp", "machine-learning", "machine-learning-library", "bot", "bots", "botkit", "rasa conversational-agents", "conversational-ai", "chatbot", "chatbot-framework", "bot-framework",] -include = [ "LICENSE.txt", "README.md", "rasa/shared/core/training_data/visualization.html", "rasa/cli/default_config.yml", "rasa/shared/importers/*", "rasa/utils/schemas/*", "rasa/keys", "rasa/core/channels/chat.html", "rasa/dialogue_understanding/classifiers/command_prompt_template.jinja2",] +include = [ "LICENSE.txt", "README.md", "rasa/shared/core/training_data/visualization.html", "rasa/cli/default_config.yml", "rasa/shared/importers/*", "rasa/utils/schemas/*", "rasa/keys", "rasa/dialogue_understanding/classifiers/command_prompt_template.jinja2",] readme = "README.md" [[tool.poetry.source]] name = "internal repository mirroring psycopg binary for macos" diff --git a/rasa/__main__.py b/rasa/__main__.py index 0c9a0c86bd41..2132e9027c99 100644 --- a/rasa/__main__.py +++ b/rasa/__main__.py @@ -13,7 +13,6 @@ import rasa.utils.tensorflow.environment as tf_env from rasa import version from rasa.cli import ( - chat, data, export, interactive, @@ -64,7 +63,6 @@ def create_argument_parser() -> argparse.ArgumentParser: scaffold.add_subparser(subparsers, parents=parent_parsers) run.add_subparser(subparsers, parents=parent_parsers) shell.add_subparser(subparsers, parents=parent_parsers) - chat.add_subparser(subparsers, parents=parent_parsers) train.add_subparser(subparsers, parents=parent_parsers) interactive.add_subparser(subparsers, parents=parent_parsers) telemetry.add_subparser(subparsers, parents=parent_parsers) diff --git a/rasa/cli/chat.py b/rasa/cli/chat.py deleted file mode 100644 index 83b2bf0cf9af..000000000000 --- a/rasa/cli/chat.py +++ /dev/null @@ -1,69 +0,0 @@ -import argparse -from asyncio import AbstractEventLoop -import logging -from typing import List, Text -import uuid -import webbrowser - -from sanic import Sanic - -from rasa.cli import SubParsersAction -from rasa.cli.arguments import shell as arguments -from rasa.core import constants - -logger = logging.getLogger(__name__) - - -def add_subparser( - subparsers: SubParsersAction, parents: List[argparse.ArgumentParser] -) -> None: - """Add all chat parsers. - - Args: - subparsers: subparser we are going to attach to - parents: Parent parsers, needed to ensure tree structure in argparse - """ - chat_parser = subparsers.add_parser( - "chat", - parents=parents, - conflict_handler="resolve", - formatter_class=argparse.ArgumentDefaultsHelpFormatter, - help=( - "Loads your trained model and lets you talk to your " - "assistant in the browser." - ), - ) - chat_parser.set_defaults(func=chat) - - chat_parser.add_argument( - "--conversation-id", - default=uuid.uuid4().hex, - required=False, - help="Set the conversation ID.", - ) - - arguments.set_shell_arguments(chat_parser) - chat_parser.set_defaults(enable_api=True) - - -async def open_chat_in_browser(server_url: Text) -> None: - """Opens the rasa chat in the default browser.""" - webbrowser.open(f"{server_url}/webhooks/socketio/chat.html") - - -def chat(args: argparse.Namespace) -> None: - """Chat to the bot using the most recent model.""" - import rasa.cli.run - - args.connector = "socketio" - - logging.getLogger("rasa.core.tracker_store").setLevel(logging.INFO) - - async def after_start_hook_open_chat(_: Sanic, __: AbstractEventLoop) -> None: - """Hook to open the browser on server start.""" - server_url = constants.DEFAULT_SERVER_FORMAT.format("http", args.port) - await open_chat_in_browser(server_url) - - args.server_listeners = [(after_start_hook_open_chat, "after_server_start")] - - rasa.cli.run.run(args) diff --git a/rasa/core/channels/chat.html b/rasa/core/channels/chat.html deleted file mode 100644 index c7f299da3405..000000000000 --- a/rasa/core/channels/chat.html +++ /dev/null @@ -1,429 +0,0 @@ - - - - - Rasa Bot Inspector - - - - - - - - - -
-

Happy chatting!

-

- You can include the chat on your own website using the following code - (rasa documentation): -

-
-<div id="rasa-chat-widget" data-websocket-url="https://example.com/"></div>
-<script src="https://unpkg.com/@rasahq/rasa-chat" type="application/javascript"></script>
-      
-
- -
-
-

Stack (top is active):

- - - - - - - - - -
IDFlowStep Id
-

Slots:

- - - - - - - - -
SlotValue
-
-

End-2-End Test:

-
-
No test yet
-
-
-
-

Tracker State:

-
-
No story yet
-
-
-
-
-

Current Flow:

-
- - -
-
-

-        
-
-
-
- -
-
-
-
- - - - - - - - - - - diff --git a/rasa/core/channels/socketio.py b/rasa/core/channels/socketio.py index 70ae1003e225..4ccb8d5329e3 100644 --- a/rasa/core/channels/socketio.py +++ b/rasa/core/channels/socketio.py @@ -13,8 +13,6 @@ logger = logging.getLogger(__name__) -CHAT_TEMPLATE_PATH = "/chat.html" - class SocketBlueprint(Blueprint): """Blueprint for socketio connections.""" @@ -147,7 +145,7 @@ def from_credentials(cls, credentials: Optional[Dict[Text, Any]]) -> InputChanne credentials.get("user_message_evt", "user_uttered"), credentials.get("bot_message_evt", "bot_uttered"), credentials.get("namespace"), - credentials.get("session_persistence", True), + credentials.get("session_persistence", False), credentials.get("socketio_path", "/socket.io"), credentials.get("jwt_key"), credentials.get("jwt_method", "HS256"), @@ -159,7 +157,7 @@ def __init__( user_message_evt: Text = "user_uttered", bot_message_evt: Text = "bot_uttered", namespace: Optional[Text] = None, - session_persistence: bool = True, + session_persistence: bool = False, socketio_path: Optional[Text] = "/socket.io", jwt_key: Optional[Text] = None, jwt_method: Optional[Text] = "HS256", @@ -190,12 +188,6 @@ def get_output_channel(self) -> Optional["OutputChannel"]: return None return SocketIOOutput(self.sio, self.bot_message_evt) - def chat_html_path(self) -> Text: - """Returns the path to the chat.html file.""" - import pkg_resources - - return pkg_resources.resource_filename(__name__, CHAT_TEMPLATE_PATH) - def blueprint( self, on_new_message: Callable[[UserMessage], Awaitable[Any]] ) -> Blueprint: @@ -214,10 +206,6 @@ def blueprint( async def health(_: Request) -> HTTPResponse: return response.json({"status": "ok"}) - @socketio_webhook.route("/chat.html", methods=["GET"]) - async def chat(_: Request) -> HTTPResponse: - return await response.file(self.chat_html_path()) - @sio.on("connect", namespace=self.namespace) async def connect(sid: Text, environ: Dict, auth: Optional[Dict]) -> bool: if self.jwt_key: diff --git a/tests/cli/test_cli.py b/tests/cli/test_cli.py index f22a89400158..028c7ba785b5 100644 --- a/tests/cli/test_cli.py +++ b/tests/cli/test_cli.py @@ -43,7 +43,7 @@ def test_data_convert_help(run: Callable[..., RunResult]): output = run("--help") help_text = f"""usage: {RASA_EXE} [-h] [--version] - {{init,run,shell,chat,train,interactive,telemetry,test,visualize,data,export,x,evaluate}} + {{init,run,shell,train,interactive,telemetry,test,visualize,data,export,x,evaluate}} ...""" lines = help_text.split("\n")