Setting up slots in story using Rasa v3

332 views Asked by At

Using the rasa documentation, I have included a few slots and entities in my domain.yml file.

domain.yml
entities:
  - cuisine
  - bot
  - PERSON
  - GPE
  - topic
  - DATE
  - month
  - ORDINAL
  - body_part
  - motor_action
  - direction
  - botname
  - username
  - country

slots:
  DATE:
    type: text
    mappings:
      - type: from_entity
        entity: DATE

  GPE:
    type: text
    mappings:
      - type: from_entity
        entity: GPE

  PERSON:
    type: text
    mappings:
      - type: from_entity
        entity: PERSON

  bot:
    type: categorical
    values:
      - alexa
      - google assistant
      - cortana
    mappings:
      - type: from_entity
        entity: bot

  botname:
    type: categorical
    values:
      - Albert
    mappings:
      - type: from_entity
        entity: botname

  month:
    type: categorical
    values:
      - january
      - february
      - march
      - april
      - may
      - june
      - july
      - august
      - september
      - october
      - november
      - december
    mappings:
      - type: from_entity
        entity: month

  topic:
    type: text
    mappings:
      - type: from_entity
        entity: topic

  username:
    type: text
    initial_value: human
    mappings:
      - type: from_entity
        entity: username

A snippet from my story.yml file

version: "3.1"

stories:
    - story: user asks for days in month
    steps:
      - intent: ask_days_in_month
        entities:
          - month: "January"
      - slot_was_set:
          - month: "January"
      - action: action_get_daysinmonth

Upon running rasa train, i come across the following error

Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Program Files\www\bot\venv\Scripts\rasa.exe\__main__.py", line 7, in <module>
  File "c:\program files\www\bot\venv\lib\site-packages\rasa\__main__.py", line 126, in main
    cmdline_arguments.func(cmdline_arguments)
  File "c:\program files\www\bot\venv\lib\site-packages\rasa\cli\train.py", line 62, in <lambda>
    train_parser.set_defaults(func=lambda args: run_training(args, can_exit=True))
  File "c:\program files\www\bot\venv\lib\site-packages\rasa\cli\train.py", line 94, in run_training
    training_result = train_all(
  File "c:\program files\www\bot\venv\lib\site-packages\rasa\api.py", line 105, in train
    return train(
  File "c:\program files\www\bot\venv\lib\site-packages\rasa\model_training.py", line 120, in train
    stories = file_importer.get_stories()
  File "c:\program files\www\bot\venv\lib\site-packages\rasa\shared\importers\importer.py", line 492, in get_stories
    return self.importer.get_stories(exclusion_percentage)
  File "c:\program files\www\bot\venv\lib\site-packages\rasa\shared\importers\importer.py", line 418, in get_stories
    return self._importer.get_stories(exclusion_percentage)
  File "c:\program files\www\bot\venv\lib\site-packages\rasa\shared\utils\common.py", line 145, in decorated
    to_cache = f(self, *args, **kwargs)
  File "c:\program files\www\bot\venv\lib\site-packages\rasa\shared\importers\importer.py", line 275, in get_stories
    stories = [
  File "c:\program files\www\bot\venv\lib\site-packages\rasa\shared\importers\importer.py", line 276, in <listcomp>
    importer.get_stories(exclusion_percentage) for importer in self._importers
  File "c:\program files\www\bot\venv\lib\site-packages\rasa\shared\importers\rasa.py", line 60, in get_stories
    return utils.story_graph_from_paths(
  File "c:\program files\www\bot\venv\lib\site-packages\rasa\shared\importers\utils.py", line 21, in story_graph_from_paths
    story_steps = loading.load_data_from_files(files, domain, exclusion_percentage)
  File "c:\program files\www\bot\venv\lib\site-packages\rasa\shared\core\training_data\loading.py", line 80, in load_data_from_files
    steps = reader.read_from_file(story_file)
  File "c:\program files\www\bot\venv\lib\site-packages\rasa\shared\core\training_data\story_reader\yaml_story_reader.py", line 106, in read_from_file
    return self.read_from_string(
  File "c:\program files\www\bot\venv\lib\site-packages\rasa\shared\core\training_data\story_reader\yaml_story_reader.py", line 134, in read_from_string
    return self.read_from_parsed_yaml(yaml_content)
  File "c:\program files\www\bot\venv\lib\site-packages\rasa\shared\core\training_data\story_reader\yaml_story_reader.py", line 159, in read_from_parsed_yaml
    parser.parse_data(data)
  File "c:\program files\www\bot\venv\lib\site-packages\rasa\shared\core\training_data\story_reader\yaml_story_reader.py", line 227, in parse_data
    self._parse_plain_item(item)
  File "c:\program files\www\bot\venv\lib\site-packages\rasa\shared\core\training_data\story_reader\yaml_story_reader.py", line 257, in _parse_plain_item
    self._parse_step(step)
  File "c:\program files\www\bot\venv\lib\site-packages\rasa\shared\core\training_data\story_reader\yaml_story_reader.py", line 290, in _parse_step
    self._parse_slot(step)
  File "c:\program files\www\bot\venv\lib\site-packages\rasa\shared\core\training_data\story_reader\yaml_story_reader.py", line 505, in _parse_slot
    SlotSet.type_name, {slot: self._slot_default_value(slot)}
  File "c:\program files\www\bot\venv\lib\site-packages\rasa\shared\core\training_data\story_reader\yaml_story_reader.py", line 526, in _slot_default_value
    slot = next(slot for slot in self.domain.slots if slot.name == slot_name)
StopIteration

I have searched the rasa forum and stackoverflow and came across a few solutions but they are a mix of Rasa V2 and Rasa V3 snippets which is quite confusing. I am new to Rasa and i am doing something wrong, i just need help figuring out what it is.

0

There are 0 answers