Skip to content

Rasa component plugin to extend state and store functionalities

License

Notifications You must be signed in to change notification settings

AppliedSoul/rasa_ext_plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rasa extension plugin

Extends rasa core through component plugin to include:

max_event_history : limits the tracker to maximum of latest 'N ' events

ExtendedDialogueStateTracker: optimize payload to action server to exclude tracker events.

Installation

  • Install the plugin (requires python3)

    Online from pypi:

    pip install rasa-ext-plugin

    Offline:

    git clone https://github.com/AppliedSoul/rasa_ext_plugin.git
    pip install -e rasa_ext_plugin
  • In RASA endpoints.yaml , setup the plugin tracker store

    ###########################################################
    # limiter tracker for existing store types : 
    # rasa_ext_plugin.core.tracker_store.InMemoryLimiterTrackerStore
    # rasa_ext_plugin.core.tracker_store.RedisLimiterTrackerStore
    # rasa_ext_plugin.core.tracker_store.MongoLimiterTrackerStore
    # rasa_ext_plugin.core.tracker_store.SQLLimiterTrackerStore
    #
    # All limiter tracker store optionally accepts: 
    # max_event_history - limit maximum events tracked by tracker
    ############################################################
    
    #tracker_store:
    #  type: rasa_ext_plugin.core.tracker_store.InMemoryLimiterTrackerStore
    #  url: localhost
    #  max_event_history: 40
      
    tracker_store:
        type: rasa_ext_plugin.core.tracker_store.RedisLimiterTrackerStore
        url: localhost
        port: 6379
        db: 0
    #    password:
    #    record_exp:
        max_event_history: 40
        
  • Startup the rasa server.

Customizing tracker payload sent to remote action server

Refer to [tracker_store] ExtendedDialogueStateTracker , modify the return state from current_state method.

class ExtendedDialogueStateTracker(DialogueStateTracker):    
    # override 
    # Actions uses this method to collect tracker's metadata
    # before sending payload as json.
    def current_state(
        self, event_verbosity: EventVerbosity = EventVerbosity.NONE
    ) -> Dict[Text, Any]:
        # conversation state format
        #  {
        #    "sender_id": self.sender_id,
        #    "slots": self.current_slot_values(),
        #    "latest_message": self.latest_message.parse_data,
        #    "latest_event_time": latest_event_time,
        #    "followup_action": self.followup_action,
        #    "paused": self.is_paused(),
        #    "events": evts,
        #    "latest_input_channel": self.get_latest_input_channel(),
        #    "active_form": self.active_form,
        #    "latest_action_name": self.latest_action_name,
        # }
        state = super(ExtendedDialogueStateTracker,self).current_state(event_verbosity)
        
        #
        # request payload to action server contains tracker information
        # from this state 

        # removing events from state information
        # action server currently ignores event history
        # reduces size of request payload to action server
        # 
        # additional unwanted keys can be poped to reduce size
        #
        state.pop("events", None)
        
        return state

About

Rasa component plugin to extend state and store functionalities

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages