Skip to content
This repository has been archived by the owner on Aug 22, 2019. It is now read-only.

Commit

Permalink
merged upstream cli
Browse files Browse the repository at this point in the history
  • Loading branch information
tmbo committed Mar 6, 2019
2 parents c5a389e + 4260d17 commit 6c76d35
Show file tree
Hide file tree
Showing 27 changed files with 172 additions and 133 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Added
- added ``/parse`` endpoint to query for NLU results
- File based event store
- ability to configure event store using the endpoints file
- added ability to use multiple env vars per line in yaml files

Changed
-------
Expand All @@ -34,12 +35,17 @@ Changed
- configuration key ``store_type`` of the tracker store endpoint configuration
has been renamed to ``type`` to allow usage accross endpoints
- renamed ``policy_metadata.json`` to ``metadata.json`` for persisted models
- ``scores`` array returned by the ``/conversations/{sender_id}/predict``
endpoint is now sorted according to the actions' scores.

Removed
-------
- removed ``admin_token`` from ``RasaChatInput`` since it wasn't used

Fixed
-----
- When a ``fork`` is used in interactive learning, every forked
storyline is saved (not just the last)

[0.13.2] - 2019-02-06
^^^^^^^^^^^^^^^^^^^^^
Expand Down
47 changes: 23 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,16 @@
# Rasa Core


[![Join the chat on Rasa Community Forum](https://img.shields.io/badge/forum-join%20discussions-brightgreen.svg)](https://forum.rasa.com/?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![PyPI version](https://img.shields.io/pypi/v/rasa_core.svg)](https://pypi.python.org/pypi/rasa-core)
[![Supported Python Versions](https://img.shields.io/pypi/pyversions/rasa_core.svg)](https://pypi.python.org/pypi/rasa_core)
[![Build Status](https://travis-ci.com/RasaHQ/rasa_core.svg?branch=master)](https://travis-ci.com/RasaHQ/rasa_core)
[![Coverage Status](https://coveralls.io/repos/github/RasaHQ/rasa_core/badge.svg?branch=master)](https://coveralls.io/github/RasaHQ/rasa_core?branch=master)
[![Documentation Status](https://img.shields.io/badge/docs-stable-brightgreen.svg)](https://rasa.com/docs/core)


- **What do Rasa Core & NLU do? 🤔**
[Read About the Rasa Stack](https://rasa.com/products/rasa-stack/)

- **I'd like to read the detailed docs 🤓**
[Read The Docs](https://rasa.com/docs/core)

- **I'm ready to install Rasa Core! 🚀**
[Installation](https://rasa.com/docs/core/installation.html)

- **I'm ready to start building! 🤖**
[Rasa Stack starter-pack](https://github.com/RasaHQ/starter-pack-rasa-stack)

- **I have a question ❓**
[Rasa Community Forum](https://forum.rasa.com)

- **I would like to contribute 🤗**
[How to contribute](#how-to-contribute)

## Introduction
<img align="right" height="244" src="https://www.rasa.com/assets/img/sara/sara-open-source-lg.png">

Rasa Core is a framework for building conversational software, which includes
Chat Bots on:
chatbots on:
- Facebook Messenger
- Slack
- Microsoft Bot Framework
Expand All @@ -51,6 +31,26 @@ Rasa Core lets you do that in a scalable way.
There's a lot more background information in this
[blog post](https://medium.com/rasa-blog/a-new-approach-to-conversational-software-2e64a5d05f2a).

---
- **What do Rasa Core & NLU do? 🤔**
[Read About the Rasa Stack](https://rasa.com/products/rasa-stack/)

- **I'd like to read the detailed docs 🤓**
[Read The Docs](https://rasa.com/docs/core)

- **I'm ready to install Rasa Core! 🚀**
[Installation](https://rasa.com/docs/core/installation/)

- **I'm ready to start building! 🤖**
[Rasa Stack starter-pack](https://github.com/RasaHQ/starter-pack-rasa-stack)

- **I have a question ❓**
[Rasa Community Forum](https://forum.rasa.com)

- **I would like to contribute 🤗**
[How to contribute](#how-to-contribute)

---
## Where to get help

There is extensive documentation:
Expand All @@ -65,7 +65,6 @@ Please use [Rasa Community Forum](https://forum.rasa.com) for quick answers to
questions.



### README Contents:
- [How to contribute](#how-to-contribute)
- [Development Internals](#development-internals)
Expand All @@ -74,7 +73,7 @@ questions.
### How to contribute
We are very happy to receive and merge your contributions. There is
some more information about the style of the code and docs in the
[documentation](https://nlu.rasa.com/contribute.html).
[documentation](https://rasa.com/docs/contributing/).

In general the process is rather simple:
1. create an issue describing the feature you want to work on (or
Expand Down
9 changes: 5 additions & 4 deletions docs/_static/spec/server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,11 @@ paths:
- Tracker
summary: Predict the next action
description: >-
Runs the conversations tracker through the models
policies to predict the next action. The action is
not executed, just returned. The state of the tracker
is not modified.
Runs the conversations tracker through the model's
policies to predict the scores of all actions present
in the model's domain. Actions are returned in the
'scores' array, sorted on their 'score' values.
The state of the tracker is not modified.
operationId: predictAction
parameters:
- $ref: '#/components/parameters/senderId'
Expand Down
14 changes: 14 additions & 0 deletions docs/migrations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@ Migration Guide
This page contains information about changes between major versions and
how you can migrate from one version to another.


.. _migration-to-0-14-0:

0.13.x to 0.14.0
----------------

Function Naming
~~~~~~~~~~~~~~~
- renamed ``train_dialogue_model`` to ``train``. Please use ``train`` from
now on.
- renamed ``rasa_core.evaluate`` to ``rasa_core.test``. Please use ``test``
from now on.


.. _migration-to-0-13-0:

0.12.x to 0.13.0
Expand Down
12 changes: 5 additions & 7 deletions examples/concertbot/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ def train_dialogue(domain_file='domain.yml',
stories_file='data/stories.md',
model_path='models/dialogue',
policy_config='policy_config.yml'):
return train.train(domain_file=domain_file,
stories_file=stories_file,
output_path=model_path,
policy_config=policy_config,
kwargs={'augmentation_factor': 50,
'validation_split': 0.2}
)
return train(domain_file=domain_file,
stories_file=stories_file,
output_path=model_path,
policy_config=policy_config,
kwargs={'augmentation_factor': 50, 'validation_split': 0.2})


if __name__ == '__main__':
Expand Down
9 changes: 4 additions & 5 deletions examples/concertbot/train_interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@


def train_agent():
return train.train(domain_file="domain.yml",
stories_file="data/stories.md",
output_path="models/dialogue",
policy_config='policy_config.yml'
)
return train(domain_file="domain.yml",
stories_file="data/stories.md",
output_path="models/dialogue",
policy_config='policy_config.yml')


if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion rasa_core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import rasa_core.version

from rasa_core.train import train
from rasa_core.test import test as test
from rasa_core.test import test
from rasa_core.visualize import visualize

logging.getLogger(__name__).addHandler(logging.NullHandler())
Expand Down
23 changes: 2 additions & 21 deletions rasa_core/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,7 @@ def __init__(
"FormPolicy to your policy ensemble."
)

self.interpreter = None
self.set_interpreter(interpreter)
self.interpreter = NaturalLanguageInterpreter.create(interpreter)

self.nlg = NaturalLanguageGenerator.create(generator, self.domain)
self.tracker_store = self.create_tracker_store(
Expand Down Expand Up @@ -368,7 +367,7 @@ def handle_text(
message_preprocessor: Optional[Callable[[Text], Text]] = None,
output_channel: Optional[OutputChannel] = None,
sender_id: Optional[Text] = UserMessage.DEFAULT_SENDER_ID
) -> Optional[List[Any]]:
) -> Optional[List[Dict[Text, Any]]]:
"""Handle a single message.
If a message preprocessor is passed, the message will be passed to that
Expand Down Expand Up @@ -707,21 +706,3 @@ def _form_policy_not_present(self) -> bool:
return (self.domain and self.domain.form_names and not
any(isinstance(p, FormPolicy)
for p in self.policy_ensemble.policies))

def set_interpreter(self,
interpreter: Optional[NaturalLanguageInterpreter]
) -> None:
from rasa_nlu.model import Interpreter

if not (isinstance(interpreter, NaturalLanguageInterpreter) or
isinstance(interpreter, Interpreter)):
if interpreter is not None:
logger.warning(
"Passing a value for interpreter to an agent "
"where the value is not an interpreter "
"is deprecated. Construct the interpreter, before"
"passing it to the agent, e.g. "
"`interpreter = NaturalLanguageInterpreter.create(nlu)`.")

interpreter = NaturalLanguageInterpreter.create(interpreter, None)
self.interpreter = interpreter
6 changes: 2 additions & 4 deletions rasa_core/channels/rasa_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@ def from_credentials(cls, credentials):
if not credentials:
cls.raise_missing_credentials_exception()

return cls(credentials.get("url"),
credentials.get("admin_token"))
return cls(credentials.get("url"))

def __init__(self, url, admin_token=None):
def __init__(self, url):
self.base_url = url
self.admin_token = admin_token

def _check_token(self, token):
url = "{}/users/me".format(self.base_url)
Expand Down
9 changes: 0 additions & 9 deletions rasa_core/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,3 @@
import rasa_core.cli.run
import rasa_core.cli.train
import rasa_core.cli.visualization


def stories_from_cli_args(cmdline_arguments):
from rasa_core import utils

if cmdline_arguments.url:
return utils.download_file_from_url(cmdline_arguments.url)
else:
return cmdline_arguments.stories
9 changes: 9 additions & 0 deletions rasa_core/cli/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,12 @@ def add_general_args(parser):
"file called `story_blocks_connections.html`.")

arguments.add_logging_option_arguments(parser)


def stories_from_cli_args(cmdline_arguments):
from rasa_core import utils

if cmdline_arguments.url:
return utils.download_file_from_url(cmdline_arguments.url)
else:
return cmdline_arguments.stories
2 changes: 1 addition & 1 deletion rasa_core/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

DEFAULT_SERVER_URL = DEFAULT_SERVER_FORMAT.format(DEFAULT_SERVER_PORT)

MINIMUM_COMPATIBLE_VERSION = "0.13.0a6"
MINIMUM_COMPATIBLE_VERSION = "0.14.0a1"

DOCS_BASE_URL = "https://rasa.com/docs/core"

Expand Down
4 changes: 2 additions & 2 deletions rasa_core/evaluate.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import logging

import rasa_core.test as test
from rasa_core.test import main

logger = logging.getLogger(__name__)

if __name__ == '__main__': # pragma: no cover
logger.warning("Calling `rasa_core.evaluate` is deprecated. "
"Please use `rasa_core.test` instead.")
test.main()
main()
5 changes: 4 additions & 1 deletion rasa_core/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ def parse(self, text):

@staticmethod
def create(obj, endpoint=None):
if isinstance(obj, NaturalLanguageInterpreter):
from rasa_nlu.model import Interpreter

if (isinstance(obj, NaturalLanguageInterpreter) or
isinstance(obj, Interpreter)):
return obj

if not isinstance(obj, str):
Expand Down
3 changes: 3 additions & 0 deletions rasa_core/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,9 @@ def predict(sender_id):
try:
# Fetches the appropriate bot response in a json format
responses = agent.predict_next(sender_id)
responses['scores'] = sorted(responses['scores'],
key = lambda k: (-k['score'],
k['action']))
return jsonify(responses)

except Exception as e:
Expand Down
3 changes: 2 additions & 1 deletion rasa_core/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import rasa_core.cli.arguments
from typing import List, Optional, Any, Text, Dict, Tuple

import rasa_core.cli.train
from rasa_core import training, cli
from rasa_core import utils
from rasa_core.events import ActionExecuted, UserUttered
Expand Down Expand Up @@ -615,7 +616,7 @@ def main():

_agent = Agent.load(cmdline_arguments.core, interpreter=_interpreter)

stories = cli.stories_from_cli_args(cmdline_arguments)
stories = rasa_core.cli.train.stories_from_cli_args(cmdline_arguments)

test(stories, _agent, cmdline_arguments.max_stories,
cmdline_arguments.output,
Expand Down
4 changes: 3 additions & 1 deletion rasa_core/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import tempfile
from typing import Text, Dict, Optional

import rasa_core.cli.train
from rasa_core import config, cli
from rasa_core import utils
from rasa_core.broker import PikaProducer
Expand Down Expand Up @@ -243,7 +244,8 @@ def do_interactive_learning(cmdline_args, stories, additional_arguments=None):

utils.configure_colored_logging(cmdline_arguments.loglevel)

training_stories = cli.stories_from_cli_args(cmdline_arguments)
training_stories = rasa_core.cli.train.stories_from_cli_args(
cmdline_arguments)

if cmdline_arguments.mode == 'default':
do_default_training(cmdline_arguments,
Expand Down
Loading

0 comments on commit 6c76d35

Please sign in to comment.