Skip to content

Commit

Permalink
renamed package
Browse files Browse the repository at this point in the history
  • Loading branch information
tmbo committed May 13, 2019
1 parent e06c4c7 commit f554687
Show file tree
Hide file tree
Showing 22 changed files with 132 additions and 93 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!-- THIS INFORMATION IS MANDATORY - YOUR ISSUE WILL BE CLOSED IF IT IS MISSING. If you don't know your Rasa Core SDK version, use `pip list | grep rasa_core_sdk`. Removing the below information is allowed for FEATURE REQUESTS. -->
<!-- THIS INFORMATION IS MANDATORY - YOUR ISSUE WILL BE CLOSED IF IT IS MISSING. If you don't know your Rasa SDK version, use `pip list | grep rasa_sdk`. Removing the below information is allowed for FEATURE REQUESTS. -->

**Rasa Core SDK version**:
**Rasa SDK version**:

**Python version**:

Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ install:
- pip install coveralls==1.3.0
- pip list
script:
- travis_wait py.test tests --cov rasa_core_sdk -v
- travis_wait py.test tests --cov rasa_sdk -v
after_success:
- coveralls
jobs:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ help:
@echo " test"
@echo " Run py.test"
@echo " init"
@echo " Install Rasa Core"
@echo " Install Rasa SDK dependencies"

init:
pip install -r requirements.txt
Expand Down
29 changes: 18 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,46 @@
# Rasa Python-SDK
[![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)
[![Build Status](https://travis-ci.com/RasaHQ/rasa_core_sdk.svg?branch=master)](https://travis-ci.com/RasaHQ/rasa_core_sdk)
[![PyPI version](https://img.shields.io/pypi/v/rasa_core_sdk.svg)](https://pypi.python.org/pypi/rasa-core-sdk)
[![Build Status](https://travis-ci.com/RasaHQ/rasa-sdk.svg?branch=master)](https://travis-ci.com/RasaHQ/rasa-sdk)
[![PyPI version](https://img.shields.io/pypi/v/rasa-sdk.svg)](https://pypi.python.org/pypi/rasa-sdk)
[![Documentation Status](https://img.shields.io/badge/docs-stable-brightgreen.svg)](https://rasa.com/docs)

Python SDK for the development of custom actions for Rasa Core.
Python SDK for the development of custom actions for Rasa.

## Installation

To install the SDK run

```bash
pip install rasa_core_sdk
pip install rasa-sdk
```

## Compatibility

`rasa-sdk` package:

| SDK version | compatible Rasa version |
|----------------|-----------------------------------|
| `1.0.x` | `>=1.0.x` |

old `rasa_core_sdk` package:

| SDK version | compatible Rasa Core version |
|----------------|----------------------------------------|
| `1.0.x` | `>=1.0.x` |
| `0.12.x` | `>=0.12.x` |
| `0.11.x` | `0.11.x` |
| not compatible | `<=0.10.x` |

## Usage

Detailed instructions can be found in the Rasa Core Documentation about
[Custom Actions](https://rasa.com/docs/core/customactions).
Detailed instructions can be found in the Rasa Documentation about
[Custom Actions](https://rasa.com/docs/customactions).

## Docker

### Usage

In order to start an action server using implemented custom actions,
you can use the available Docker image `rasa/rasa_core_sdk:latest`.
you can use the available Docker image `rasa/rasa-sdk:latest`.

Before starting the action server ensure that the folder containing
your actions is handled as Python module and therefore has to contain
Expand All @@ -43,7 +50,7 @@ Then start the action server using:

```bash
docker run -p 5055:5055 --mount type=bind,source=<ABSOLUTE_PATH_TO_YOUR_ACTIONS>,target=/app/actions \
rasa/rasa_core_sdk:latest
rasa/rasa-sdk:latest
```

The action server is then available at `http://localhost:5055/webhook`.
Expand All @@ -53,7 +60,7 @@ The action server is then available at `http://localhost:5055/webhook`.
To add custom dependencies you enhance the given Docker image, e.g.:

```
FROM rasa/rasa_core_sdk:latest
FROM rasa/rasa-sdk:latest
# To install system dependencies
RUN apt-get update -qq && \
Expand Down Expand Up @@ -86,4 +93,4 @@ Technologies GmbH. [Copy of the license](LICENSE.txt).

A list of the Licenses of the dependencies of the project can be found at
the bottom of the
[Libraries Summary](https://libraries.io/github/RasaHQ/rasa_core_sdk).
[Libraries Summary](https://libraries.io/github/RasaHQ/rasa-sdk).
8 changes: 4 additions & 4 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ set -Eeuo pipefail

function print_help {
echo "Available options:"
echo " start commands (Rasa Core cmdline arguments) - Start Rasa Core Action Server"
echo " help - Print this help"
echo " run - Run an arbitrary command inside the container"
echo " start - Start Rasa Action Server"
echo " help - Print this help"
echo " run - Run an arbitrary command inside the container"
}

case ${1} in
start)
exec python -m rasa_core_sdk.endpoint "${@:2}"
exec python -m rasa_sdk "${@:2}"
;;
run)
exec "${@:2}"
Expand Down
20 changes: 20 additions & 0 deletions rasa_sdk/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import logging

import rasa_sdk.version

logger = logging.getLogger(__name__)

__version__ = rasa_sdk.version.__version__

import rasa_sdk.cli
from rasa_sdk.interfaces import Tracker, Action, ActionExecutionRejection


if __name__ == "__main__":
import rasa_sdk.__main__
rasa_sdk.__main__.main()
26 changes: 26 additions & 0 deletions rasa_sdk/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import logging

from rasa_sdk import utils
from rasa_sdk.endpoint import create_argument_parser, run


def main():
# Running as standalone python application
arg_parser = create_argument_parser()
cmdline_args = arg_parser.parse_args()

logging.basicConfig(level=logging.DEBUG)
logging.getLogger("matplotlib").setLevel(logging.WARN)

utils.configure_colored_logging(cmdline_args.loglevel)

run(cmdline_args.actions, cmdline_args.port, cmdline_args.cors)


if __name__ == '__main__':
main()
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import argparse

from rasa_core_sdk.constants import DEFAULT_SERVER_PORT
from rasa_sdk.constants import DEFAULT_SERVER_PORT


def action_arg(action):
Expand Down
File renamed without changes.
68 changes: 28 additions & 40 deletions rasa_core_sdk/endpoint.py → rasa_sdk/endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
from flask_cors import CORS, cross_origin
from gevent.pywsgi import WSGIServer

from rasa_core_sdk.cli.arguments import add_endpoint_arguments
from rasa_core_sdk.constants import DEFAULT_SERVER_PORT
from rasa_core_sdk.executor import ActionExecutor
from rasa_core_sdk import ActionExecutionRejection
import rasa_core_sdk
from rasa_sdk.cli.arguments import add_endpoint_arguments
from rasa_sdk.constants import DEFAULT_SERVER_PORT
from rasa_sdk.executor import ActionExecutor
from rasa_sdk.interfaces import ActionExecutionRejection
import rasa_sdk

from rasa_core_sdk import utils
from rasa_sdk import utils

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -69,48 +69,48 @@ def webhook():
return app


def check_version_compatibility(core_version):
"""Check if the version of rasa_core and rasa_core_sdk are compatible.
def check_version_compatibility(rasa_version):
"""Check if the version of rasa and rasa_sdk are compatible.
The version check relies on the version string being formatted as
'x.y.z' and compares whether the numbers x and y are the same for both
rasa_core and rasa_core_sdk.
rasa and rasa_sdk.
Args:
core_version - A string containing the version of rasa_core that
rasa_version - A string containing the version of rasa that
is making the call to the action server.
Raises:
Warning - The version of rasa_core version unkown or not compatible with
this version of rasa_core_sdk.
Warning - The version of rasa version unknown or not compatible with
this version of rasa_sdk.
"""
# Check for versions of core that are too old to report their version number
if core_version is None:
# Check for versions of Rasa that are too old to report their version number
if rasa_version is None:
logger.warning(
"You are using an old version of rasa_core which might "
"not be compatible with this version of rasa_core_sdk "
"You are using an old version of rasa which might "
"not be compatible with this version of rasa_sdk "
"({}).\n"
"To ensure compatibility use the same version "
"for both, modulo the last number, i.e. using version "
"A.B.x the numbers A and B should be identical for "
"both rasa_core and rasa_core_sdk."
"".format(rasa_core_sdk.__version__)
"both rasa and rasa_sdk."
"".format(rasa_sdk.__version__)
)
return

core = core_version.split(".")[:-1]
sdk = rasa_core_sdk.__version__.split(".")[:-1]
rasa = rasa_version.split(".")[:-1]
sdk = rasa_sdk.__version__.split(".")[:-1]

if core != sdk:
if rasa != sdk:
logger.warning(
"Your versions of rasa_core and "
"rasa_core_sdk might not be compatible. You "
"are currently running rasa_core version {} "
"and rasa_core_sdk version {}.\n"
"rasa_sdk might not be compatible. You "
"are currently running rasa version {} "
"and rasa_sdk version {}.\n"
"To ensure compatibility use the same "
"version for both, modulo the last number, "
"i.e. using version A.B.x the numbers A and "
"B should be identical for "
"both rasa_core and rasa_core_sdk."
"".format(core_version, rasa_core_sdk.__version__)
"both rasa and rasa_sdk."
"".format(rasa_version, rasa_sdk.__version__)
)


Expand All @@ -126,18 +126,6 @@ def run(actions, port=DEFAULT_SERVER_PORT, cors="*"):
http_server.serve_forever()


def main(args):
logging.basicConfig(level=logging.DEBUG)
logging.getLogger("matplotlib").setLevel(logging.WARN)

utils.configure_colored_logging(args.loglevel)

run(args.actions, args.port, args.cors)


if __name__ == "__main__":
# Running as standalone python application
arg_parser = create_argument_parser()
cmdline_args = arg_parser.parse_args()

main(cmdline_args)
import rasa_sdk.__main__
rasa_sdk.__main__.main()
File renamed without changes.
7 changes: 5 additions & 2 deletions rasa_core_sdk/executor.py → rasa_sdk/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
import six
from typing import Text, List, Dict, Any

from rasa_core_sdk import utils, Action, Tracker
from rasa_sdk import utils
from rasa_sdk.interfaces import Action, Tracker

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -122,7 +123,7 @@ def __init__(self):

def register_action(self, action):
if inspect.isclass(action):
if action.__module__.startswith("rasa_core."):
if action.__module__.startswith("rasa."):
logger.warning("Skipping built in Action {}.".format(action))
return
else:
Expand Down Expand Up @@ -182,6 +183,8 @@ def register_package(self, package):
abstract = getattr(meta, "abstract", False)
if (
not action.__module__.startswith("rasa_core.")
and not action.__module__.startswith("rasa.")
and not action.__module__.startswith("rasa_sdk.")
and not action.__module__.startswith("rasa_core_sdk.")
and not abstract
):
Expand Down
8 changes: 4 additions & 4 deletions rasa_core_sdk/forms.py → rasa_sdk/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
import typing
from typing import Dict, Text, Any, List, Union, Optional, Tuple

from rasa_core_sdk import Action, ActionExecutionRejection
from rasa_core_sdk.events import SlotSet, Form
from rasa_sdk.interfaces import Action, ActionExecutionRejection
from rasa_sdk.events import SlotSet, Form

logger = logging.getLogger(__name__)

if typing.TYPE_CHECKING:
from rasa_core_sdk import Tracker
from rasa_core_sdk.executor import CollectingDispatcher
from rasa_sdk import Tracker
from rasa_sdk.executor import CollectingDispatcher

# this slot is used to store information needed
# to do the form handling
Expand Down
19 changes: 7 additions & 12 deletions rasa_core_sdk/__init__.py → rasa_sdk/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,14 @@

import copy
import logging

import typing
from typing import Dict, Text, Any, Optional, Iterator, List
from typing import Any, Dict, Iterator, List, Optional, Text

import rasa_core_sdk.version
import rasa_core_sdk.cli
if typing.TYPE_CHECKING:
from rasa_sdk.executor import CollectingDispatcher

logger = logging.getLogger(__name__)

__version__ = rasa_core_sdk.version.__version__

if typing.TYPE_CHECKING:
from rasa_core_sdk.executor import CollectingDispatcher


class Tracker(object):
"""Maintains the state of a conversation."""
Expand Down Expand Up @@ -125,6 +119,7 @@ def get_latest_input_channel(self):
for e in reversed(self.events):
if e.get("event") == "user":
return e.get("input_channel")
return None

def is_paused(self):
# type: () -> bool
Expand Down Expand Up @@ -192,17 +187,17 @@ def run(
dispatcher (CollectingDispatcher): the dispatcher which is used to
send messages back to the user. Use
``dipatcher.utter_message()`` or any other
``rasa_core_sdk.executor.CollectingDispatcher``
``rasa_sdk.executor.CollectingDispatcher``
method.
tracker (Tracker): the state tracker for the current
user. You can access slot values using
``tracker.get_slot(slot_name)``, the most recent user message
is ``tracker.latest_message.text`` and any other
``rasa_core_sdk.Tracker`` property.
``rasa_sdk.Tracker`` property.
domain (Dict[Text, Any]): the bot's domain
Returns:
List[Dict[Text, Any]]: A dictionary of
``rasa_core_sdk.events.Event`` instances that is
``rasa_sdk.events.Event`` instances that is
returned through the endpoint
"""

Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit f554687

Please sign in to comment.