2.0.0
Deprecations and Removals
-
#246: Using the
Form
event is
deprecated. Please use the newActiveLoop
event instead.
Using theactive_form
property of theTracker
object is now deprecated. Please
use theactive_loop
property instead.The usage of the
FormAction
is deprecated. Please see the migration guide
for Rasa Open Source 2.0 for instructions how to migrate yourFormAction
s. -
#250: Removed support for the
rasa_core_sdk
python module: useimport rasa_sdk
syntax instead. -
#6463: The
FormValidation
event
was renamed toLoopInterrupted
as part of Rasa Open Source 2.0. Using the
FormValidation
is now deprecated and will be removed in the future.
Please useLoopInterrupted
instead.
Features
-
#238: Added the method
slots_to_validate
toTracker
. This method is helpful
when using a custom action to validate slots which were extracted by a
form as shown by the following example.from typing import Text, Dict, List, Any from rasa_sdk import Action, Tracker from rasa_sdk.events import EventType, SlotSet from rasa_sdk.types import DomainDict from rasa_sdk.executor import CollectingDispatcher class ValidateSlots(Action): def name(self) -> Text: return "validate_your_form" def run( self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: DomainDict ) -> List[EventType]: extracted_slots: Dict[Text, Any] = tracker.slots_to_validate() validation_events = [] for slot_name, slot_value in extracted_slots.items(): # Check if slot is valid. if self.is_valid(slot_value): validation_events.append(SlotSet(slot_name, slot_value)) else: # Return a `SlotSet` event with value `None` to indicate that this # slot still needs to be filled. validation_events.append(SlotSet(slot_name, None)) return validation_events def is_valid(self, slot_value: Any) -> bool: # Implementation of the validate function. return True
Please note that
tracker.form_slots_to_validate
only works with Rasa Open Source 2.
Improvements
-
#239: Validate user input during
form activation even if there is an action in between. -
#246: Rasa Open Source 2.0 renamed
theForm
event toActiveLoop
. TheActiveLoop
event was added to the SDK and support for theactive_loop
field in JSON payloads
was added. -
#267: The
actions
package
in a Rasa project may contain multiple files containing custom
action code. The Rasa SDK Docker container now loads the entireactions
package. -
#288: Add the
FormValidationAction
abstract class that can be used to validate slots which were extracted by a Form.Example:
from typing import Text, Any, Dict from rasa_sdk import FormValidationAction, Tracker from rasa_sdk.types import DomainDict from rasa_sdk.executor import CollectingDispatcher class MyFormValidationAction(FormValidationAction): def name(self) -> Text: return "some_form" def validate_slot1( self, slot_value: Any, dispatcher: "CollectingDispatcher", tracker: "Tracker", domain: "DomainDict", ) -> Dict[Text, Any]: if slot_value == "correct_value": return { "slot1": "validated_value", } return { "slot1": None, }
-
#6463: Added support for the
LoopInterrupted
event.
Bugfixes
- #280:
tracker.applied_events
now correctly deals with restart, undo, and rewind events