Skip to content

Commit

Permalink
Merge pull request #6052 from mcminis1/6051_jupyter_chat_action_endpoint
Browse files Browse the repository at this point in the history
adding in endpoints parameter for the jupyter.chat method
  • Loading branch information
rgstephens authored Jul 27, 2020
2 parents fb8049d + 5ec4061 commit b5f6139
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions changelog/6052.improvement.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add endpoint kwarg to rasa.jupyter.chat to enable using a custom action server while chatting with a model in a jupyter notebook.
6 changes: 3 additions & 3 deletions docs/api/jupyter-notebooks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ Chat with your assistant
~~~~~~~~~~~~~~~~~~~~~~~~

To start chatting to an assistant, call the ``chat`` function, passing
in the path to your saved model:
in the path to your saved model. If you do not have custom actions you can set `endpoints = None` or omit it:


.. runnable::

from rasa.jupyter import chat
chat(model_path)

endpoints = "endpoints.yml"
chat(model_path, endpoints)


Evaluate your model against test data
Expand Down
6 changes: 4 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
]
linkcheck_retries = 2
linkcheck_timeout = 5
sphinx_tabs_valid_builders = ['linkcheck']

# If your documentation needs a minimal Sphinx version, state it here.
# needs_sphinx = '1.0'

Expand Down Expand Up @@ -421,13 +423,13 @@


def setup(sphinx):
sphinx.add_stylesheet("css/custom.css")
sphinx.add_css_file("css/custom.css")

try:
utils_path = os.path.abspath(os.path.join(__file__, "..", "utils"))
sys.path.insert(0, utils_path)
from StoryLexer import StoryLexer

sphinx.add_lexer("story", StoryLexer())
sphinx.add_lexer("story", StoryLexer)
except ImportError:
print("No Story Lexer :( Sad times!")
4 changes: 3 additions & 1 deletion rasa/jupyter.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ def pprint(obj: Any):

def chat(
model_path: Optional[Text] = None,
endpoints: Optional[Text] = None,
agent: Optional["Agent"] = None,
interpreter: Optional[NaturalLanguageInterpreter] = None,
) -> None:
"""Chat to the bot within a Jupyter notebook.
Args:
model_path: Path to a combined Rasa model.
endpoints: Path to a yaml with the action server is custom actions are defined.
agent: Rasa Core agent (used if no Rasa model given).
interpreter: Rasa NLU interpreter (used with Rasa Core agent if no
Rasa model is given).
Expand All @@ -30,7 +32,7 @@ def chat(
if model_path:
from rasa.run import create_agent

agent = create_agent(model_path)
agent = create_agent(model_path, endpoints)

elif agent is not None and interpreter is not None:
# HACK: this skips loading the interpreter and directly
Expand Down

0 comments on commit b5f6139

Please sign in to comment.