Skip to main content

Rasa Improved

Project description

License License Version Version
Github Actions Github Actions Coverage CodeCov
Supported versions Python Versions Wheel Wheel
Status Status Downloads Downloads

rasam

Rasa Improved

Usage

Installation

pip install rasam

Rasa config.yml

importers:
  - name: rasam.PlaceholderImporter
    fake_data_count: 10  # default value is 1

pipeline:
  - name: rasam.RegexEntityExtractor
  - name: rasam.URLEntityExtractor

Rasa nlu.yml

PlaceholderImporter

The PlaceholderImporter removes the need to write unnecessary information (eg. name, address, numbers, etc.) and helps focus on writing test data.

Using {} placeholder

nlu:
- intent: tell_name
  examples: |
    - My name is {name}
    - I am {name} and he is {name}

Using @ placeholder

nlu:
- intent: tell_address
  examples: |
    - I live in @address
    - I stay at @address and @address

Mixing {} and @ placeholders

It is possible to mix both {} and @ placeholders but it is recommended to use only one style for consistency.

Available placeholders

  • any (if you need just any data)
  • integer
  • decimal
  • number
  • name
  • first_name
  • last_name
  • text
  • word
  • paragraph
  • uri
  • url
  • local_uri
  • email
  • date
  • time
  • month
  • day
  • timezone
  • company
  • license_plate
  • address
  • city
  • country
  • user_agent
  • password
  • user_name
  • file_path

Rasam decorators

Rasa relies too heavily on classes to define objects like actions, forms, etc. Rasam aims to remove these Rasa boilerplates to make writing chatbots easier.

@action decorator

The @action decorator converts function into an Action class. Here is an example of how we can write custom classes in Rasa:

class ActionHelloWorld(Action):

    def name(self) -> Text:
        return "action_hello_world"

    def run(self, dispatcher: CollectingDispatcher,
            tracker: Tracker,
            domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:

        dispatcher.utter_message(text="Hello World!")

        return []

The above code can be simplified using Rasam's @action decorator.

from rasam import action


@action
def action_hello_world(
    self: Action, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict[Text, Any]
) -> List[Dict[Text, Any]]:
    dispatcher.utter_message(text="Hello World!")
    return []

Author

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rasam-0.5.2.tar.gz (8.0 kB view hashes)

Uploaded Source

Built Distribution

rasam-0.5.2-py3-none-any.whl (7.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page