buerokratt / Buerokratt-Chatbot

1 stars 18 forks source link

Add functionalities to Training Module rules #829

Open jaX10bt opened 1 month ago

jaX10bt commented 1 month ago

AS A Chatbot Trainer I WANT TO utilize all available Rasa functionalities when creating rules SO THAT rules won't be broken after modifying them in Training Module GUI

Currently there is functionality to check the value of a slot in the condition of a rule, but there should also be functionality to check whether a specific slot has been set.

Example of a rule with functionality to check whether a specific slot has been set: Image

joonasroosalung commented 1 month ago

PR https://github.com/buerokratt/Training-Module/pull/634

joonasroosalung commented 4 weeks ago

@jaX10bt was the example rule generated through the GUI?

Saving a rule inserts the condition under steps:

  - rule: common_tervitus
    steps:
      - intent: common_tervitus
      - slot_was_set:
          common_teenus_ilm_asukoht: null
      - action: utter_common_teenus_ilm

Manually editing rules.yml according to the sample

  - rule: rule_UUS_HEA_TEEMA
    condition:
    - slot_was_set
      - rk_hääletus: 234567890dfdsfsdfsdf
    steps:
      - intent: UUS_HEA_TEEMA
      - action: utter_common_teenus_ilm

Gives a parsing error (dmapper)

dmapper         | YAMLParseError: Implicit keys need to be on a single line at line 5, column 7:
dmapper         | 
dmapper         | Response: {statusCode: 500, responseData: undefined}
dmapper         |     - slot_was_set
dmapper         |       ^
jaX10bt commented 3 weeks ago

It is possible to check whether a slot has been set, but the rule syntax is broken by double quotes: GUI: image rules.yml: image

How it should be:

- slot_was_set:
          rk_hääletus: null

Slot value should be without double quotes

It should also be possible to check multiple slots in a single slot_was_set check as it is with entities in intents: image

joonasroosalung commented 2 weeks ago

I was not able to solve the following issues:

In a slotNode, quotes are added only if the value does not contain a space or ends in a space. If the value is "one two", it's stored without quotes. The result is generated in GUI/src/services/rasa.tsx, in the function generateStoryStepsFromNodes but seems like something down the line affects the quotes (datamapper?).

In a conditionNode, the values are broken up in to slot and value to display in the GUI, but also stored as slot and value in rules.yml, incorrectly. The condition node is stored under steps, but should be stored after rule, before steps. The functions generateStoryStepsFromNodes and generateNodesFromStorySteps need to be adjusted to handle any number of slot_was_set conditions and separated to their own functions. Conditions type in ConditionNode component needs to be adjusted to accept an array of objects under slot_was_set.