RasaHQ / rasa

💬 Open source machine learning framework to automate text- and voice-based conversations: NLU, dialogue management, connect to Slack, Facebook, and more - Create chatbots and voice assistants
https://rasa.com/docs/rasa/
Apache License 2.0
18.74k stars 4.62k forks source link

Issues With Slots in domain.yml #10763

Closed AR210689 closed 2 years ago

AR210689 commented 2 years ago

Rasa Open Source version

3.0.0

Rasa SDK version

3.0.3

Rasa X version

No response

Python version

3.7

What operating system are you using?

OSX

What happened?

I have the following domain.yml file for a simple chatbot, and the error I am getting is very unhelpful in its message. I keep getting the following error:

slot = slot_class(slot_name, **slot_dict[slot_name]) TypeError: init() got an unexpected keyword argument 'values'

I have pasted the domain file here. Please look into this.

Thank you!

Command / Request


version: "3.0"

intents:
  - greet
  - general
  - purchase:          #If customer has a straight intent to buy an item
      use_entities:
      - age_stage
      - garment_type
      - colour
      - pattern
      - fabric_type
      - gender
      - size
      - occasion 
  - browse:            #If the customer is just browsing
      use_entities:
        - age_stage
        - garment_type
        - colour
        - pattern
        - fabric_type
        - gender
        - size
        - occasion 
  - description:       #Customers can manually describe an item they desire
      use_entities:
          - age_stage
          - garment_type
          - colour
          - pattern
          - fabric_type
          - gender
          - size
          - occasion 
  - reference        #Reference can be an image or a link to a product
  - acknowledge_info  #to acknowledge any additional info
  - goodbye
  - unhappy
  - affirm            #Affirm if no further help is needed
  - bot_challenge
      # use_entities: [] 

entities:
  - customer_mood
  - customer_intention
  - customer_age:
      role:
        - babies
        - kids
        - teens
        - middle_age
        - senior
  - customer_garment_choice:
      roles:
        - upper
        - lower
        - whole
  - customer_accessories
  - customer_preferred_colour
  - customer_preferred_pattern
  - customer_given_reference     #this is for an image or a link to an item
  - fabric_type
  - customer_gender
  - customer_size
  - customer_occasion 

slots: #from user input
  mood:
    type: categorical
    influence_conversation: false     #can be modified later
    mappings: 
    - type: from_entity
      entity: customer_intention #extract value from this entity
    values:
      - happy
      - unhappy

  intention: #possible values for customer's intention
    type: categorical
    influence_conversation: false     #can be modified later
    mappings: 
    - type: from_entity
      entity: customer_intention #extract value from this entity
    values:
      - browsing
      - purchasing

  age_stage: #possible values for intended age
    type: categorical
    influence_conversation: false     #can be modified later
    values:
      - babies
      - kids
      - teens
      - middle_age
      - senior 
    mappings: 
    - type: from_entity
      entity: customer_age

  garment_type:  #possible values for different garment types-- all inclusive
    type: text  #can take name of any of the garment types the website hosts
    influence_conversation: false     #can be modified later
    mappings: 
    - type: from_entity
      entity: customer_garment_choice
    values: 
      - formal_shirts
      - casual_shirts
      - trousers
      - t_shirts
      - shorts
      - shoes
      - cargo_shorts
      - women_clothes

  accessories:
    type: text
    influence_conversation: false     #can be modified later
    mappings:
    - type: from_entity
      entity: customer_accessories
    values:
      - tie
      - socks
      - stole

  size: #possible values for sizes
    type: categorical
    influence_conversation: false     #can be modified later
    mappings: 
    - type: from_entity
      entity: customer_size
    values: 
      - small
      - medium
      - large
      - XL
      - XLL
      - XLLL
      - 32 waist
      - waist 37

  colour: #possible values for colour
    type: text
    influence_conversation: false     #can be modified later
    mappings: 
    - type: from_entity
      entity: customer_preferred_colour
    # values:
    #   - black
    #   - white
    #   - grey
    #   - blue
    #   - red
    #   - green
    #   - yellow     

  pattern: #possible values for colour
    type: text
    influence_conversation: false     #can be modified later
    mappings: 
    - type: from_entity
      entity: customer_preferred_pattern

  gender: #possible values for gender
    type: categorical
    influence_conversation: false     #can be modified later
    mappings: 
    - type: from_entity
      entity: customer_gender
    values:
      - male
      - female
      - unisex

  occasion: #possible values for occasion
    type: categorical
    influence_conversation: false     #can be modified later
    mappings: 
    - type: from_entity
      entity: customer_occasion
    values:
      - casual
      - formal
      - ethnic

  reference: # a slot which has an image or a link to an item
    type: text
    influence_conversation: false     #can be modified later
    mappings: 
    - type: from_entity
      entity: customer_given_reference

forms:
  inquiry_form:
    required_slots:
      - intention
      - age_stage
      - garment_type
      - gender

responses: #agen to user
  utter_greet:
    - text: "Hello! What can I help you with?"

  utter_browse:
    - text: "What can I help you search for?"

  utter_purchase:
    - text: "What are you looking for today?"

  utter_description:
    - text: "Can you roughly describe the item and its features so I can find them for you?"

  utter_reference:
    - text: "Do you have a product image or a link which I can use as a reference?"

  utter_acknowledge_info:
    - text: "Thank you! I will search for a suitable item..."

  utter_window_shopping:
    - text: "What do you have in mind?"

  utter_unhappy:
    - text: "Ohh... I am sorry!!!"
    - text: "Could you describe what you have in mind?"
    - text: "I will try again... and find something better"

  utter_show_result:
    - text: "These are what I've found which match your specifications..."

  utter_did_that_help:
    - text: "Did that help with what you had in mind?"

  utter_general:
    - text: "I am here if you need me..."

  utter_affirm:
    - text: "Anything else I can help you with..."

  utter_goodbye:
    - text: "See you next time..."

  utter_iamabot:
    - text: "I know you want to challenge me..."
    - text: "but I am just a bot designed to help you but clothes."

session_config:
  session_expiration_time: 100 # value in minutes
  carry_over_slots_to_new_session: true

Relevant log output

rasa train
Traceback (most recent call last):
  File "/Users/ani/conversational_ai_RASA/rasa_env/bin/rasa", line 8, in <module>
    sys.exit(main())
  File "/Users/ani/conversational_ai_RASA/rasa_env/lib/python3.7/site-packages/rasa/__main__.py", line 121, in main
    cmdline_arguments.func(cmdline_arguments)
  File "/Users/ani/conversational_ai_RASA/rasa_env/lib/python3.7/site-packages/rasa/cli/train.py", line 59, in <lambda>
    train_parser.set_defaults(func=lambda args: run_training(args, can_exit=True))
  File "/Users/ani/conversational_ai_RASA/rasa_env/lib/python3.7/site-packages/rasa/cli/train.py", line 103, in run_training
    finetuning_epoch_fraction=args.epoch_fraction,
  File "/Users/ani/conversational_ai_RASA/rasa_env/lib/python3.7/site-packages/rasa/api.py", line 117, in train
    finetuning_epoch_fraction=finetuning_epoch_fraction,
  File "/Users/ani/conversational_ai_RASA/rasa_env/lib/python3.7/site-packages/rasa/model_training.py", line 129, in train
    stories = file_importer.get_stories()
  File "/Users/ani/conversational_ai_RASA/rasa_env/lib/python3.7/site-packages/rasa/shared/importers/importer.py", line 458, in get_stories
    return self.importer.get_stories(exclusion_percentage)
  File "/Users/ani/conversational_ai_RASA/rasa_env/lib/python3.7/site-packages/rasa/shared/importers/importer.py", line 375, in get_stories
    return self._importer.get_stories(exclusion_percentage)
  File "/Users/ani/conversational_ai_RASA/rasa_env/lib/python3.7/site-packages/rasa/shared/utils/common.py", line 146, in decorated
    to_cache = f(self, *args, **kwargs)
  File "/Users/ani/conversational_ai_RASA/rasa_env/lib/python3.7/site-packages/rasa/shared/importers/importer.py", line 254, in get_stories
    importer.get_stories(exclusion_percentage) for importer in self._importers
  File "/Users/ani/conversational_ai_RASA/rasa_env/lib/python3.7/site-packages/rasa/shared/importers/importer.py", line 254, in <listcomp>
    importer.get_stories(exclusion_percentage) for importer in self._importers
  File "/Users/ani/conversational_ai_RASA/rasa_env/lib/python3.7/site-packages/rasa/shared/importers/rasa.py", line 52, in get_stories
    self._story_files, self.get_domain(), exclusion_percentage,
  File "/Users/ani/conversational_ai_RASA/rasa_env/lib/python3.7/site-packages/rasa/shared/importers/rasa.py", line 73, in get_domain
    domain = Domain.load(self._domain_path)
  File "/Users/ani/conversational_ai_RASA/rasa_env/lib/python3.7/site-packages/rasa/shared/core/domain.py", line 145, in load
    other = cls.from_path(path)
  File "/Users/ani/conversational_ai_RASA/rasa_env/lib/python3.7/site-packages/rasa/shared/core/domain.py", line 155, in from_path
    domain = cls.from_file(path)
  File "/Users/ani/conversational_ai_RASA/rasa_env/lib/python3.7/site-packages/rasa/shared/core/domain.py", line 169, in from_file
    return cls.from_yaml(rasa.shared.utils.io.read_file(path), path)
  File "/Users/ani/conversational_ai_RASA/rasa_env/lib/python3.7/site-packages/rasa/shared/core/domain.py", line 182, in from_yaml
    return cls.from_dict(data)
  File "/Users/ani/conversational_ai_RASA/rasa_env/lib/python3.7/site-packages/rasa/shared/core/domain.py", line 201, in from_dict
    slots = cls.collect_slots(domain_slots)
  File "/Users/ani/conversational_ai_RASA/rasa_env/lib/python3.7/site-packages/rasa/shared/core/domain.py", line 328, in collect_slots
    slot = slot_class(slot_name, **slot_dict[slot_name])
TypeError: __init__() got an unexpected keyword argument 'values'
indam23 commented 2 years ago

The issue here is that a text slot does not accept values; only categorical slots do. e.g. this:

garment_type:  #possible values for different garment types-- all inclusive
    type: text  #can take name of any of the garment types the website hosts
    influence_conversation: false     #can be modified later
    mappings: 
    - type: from_entity
      entity: customer_garment_choice
    values: 
      - formal_shirts
      - casual_shirts
      - trousers
      - t_shirts
      - shorts
      - shoes
      - cargo_shorts
      - women_clothes

needs to be categorical to make use of a specific list of values

AR210689 commented 2 years ago

It worked! Silly mistake. Thank you very much! This error message should be changed though.

indam23 commented 2 years ago

It would help if the slot name was listed, yes. Glad it worked.