pythonchatbotrasa

Not able to understand this rasa train command error


Rasa train command output

Traceback (most recent call last):
  File "/Users/nc24497dhruvsinghal/Documents/rasa_init/venv/lib/python3.9/site-packages/rasa/engine/graph.py", line 496, in __call__
    output = self._fn(self._component, **run_kwargs)
  File "/Users/nc24497dhruvsinghal/Documents/rasa_init/venv/lib/python3.9/site-packages/rasa/core/policies/ted_policy.py", line 718, in train
    model_data, label_ids = self._prepare_for_training(
  File "/Users/nc24497dhruvsinghal/Documents/rasa_init/venv/lib/python3.9/site-packages/rasa/core/policies/ted_policy.py", line 608, in _prepare_for_training
    tracker_state_features, label_ids, entity_tags = self._featurize_for_training(
  File "/Users/nc24497dhruvsinghal/Documents/rasa_init/venv/lib/python3.9/site-packages/rasa/core/policies/policy.py", line 241, in _featurize_for_training
    state_features, label_ids, entity_tags = self.featurizer.featurize_trackers(
  File "/Users/nc24497dhruvsinghal/Documents/rasa_init/venv/lib/python3.9/site-packages/rasa/core/featurizers/tracker_featurizers.py", line 352, in featurize_trackers
    label_ids = self._convert_labels_to_ids(trackers_as_labels, domain)
  File "/Users/nc24497dhruvsinghal/Documents/rasa_init/venv/lib/python3.9/site-packages/rasa/core/featurizers/tracker_featurizers.py", line 922, in _convert_labels_to_ids
    label_ids = [
  File "/Users/nc24497dhruvsinghal/Documents/rasa_init/venv/lib/python3.9/site-packages/rasa/core/featurizers/tracker_featurizers.py", line 923, in <listcomp>
    [domain.intents.index(intent) for intent in tracker_intents]
  File "/Users/nc24497dhruvsinghal/Documents/rasa_init/venv/lib/python3.9/site-packages/rasa/core/featurizers/tracker_featurizers.py", line 923, in <listcomp>
    [domain.intents.index(intent) for intent in tracker_intents]
ValueError: 'give_category' is not in list

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/nc24497dhruvsinghal/Documents/rasa_init/venv/bin/rasa", line 8, in <module>
    sys.exit(main())
  File "/Users/nc24497dhruvsinghal/Documents/rasa_init/venv/lib/python3.9/site-packages/rasa/__main__.py", line 133, in main
    cmdline_arguments.func(cmdline_arguments)
  File "/Users/nc24497dhruvsinghal/Documents/rasa_init/venv/lib/python3.9/site-packages/rasa/cli/train.py", line 61, in <lambda>
    train_parser.set_defaults(func=lambda args: run_training(args, can_exit=True))
  File "/Users/nc24497dhruvsinghal/Documents/rasa_init/venv/lib/python3.9/site-packages/rasa/cli/train.py", line 101, in run_training
    training_result = train_all(
  File "/Users/nc24497dhruvsinghal/Documents/rasa_init/venv/lib/python3.9/site-packages/rasa/api.py", line 105, in train
    return train(
  File "/Users/nc24497dhruvsinghal/Documents/rasa_init/venv/lib/python3.9/site-packages/rasa/model_training.py", line 207, in train
    return _train_graph(
  File "/Users/nc24497dhruvsinghal/Documents/rasa_init/venv/lib/python3.9/site-packages/rasa/model_training.py", line 286, in _train_graph
    trainer.train(
  File "/Users/nc24497dhruvsinghal/Documents/rasa_init/venv/lib/python3.9/site-packages/rasa/engine/training/graph_trainer.py", line 105, in train
    graph_runner.run(inputs={PLACEHOLDER_IMPORTER: importer})
  File "/Users/nc24497dhruvsinghal/Documents/rasa_init/venv/lib/python3.9/site-packages/rasa/engine/runner/dask.py", line 101, in run
    dask_result = dask.get(run_graph, run_targets)
  File "/Users/nc24497dhruvsinghal/Documents/rasa_init/venv/lib/python3.9/site-packages/dask/local.py", line 557, in get_sync
    return get_async(
  File "/Users/nc24497dhruvsinghal/Documents/rasa_init/venv/lib/python3.9/site-packages/dask/local.py", line 500, in get_async
    for key, res_info, failed in queue_get(queue).result():
  File "/Users/nc24497dhruvsinghal/.pyenv/versions/3.9.18/lib/python3.9/concurrent/futures/_base.py", line 439, in result
    return self.__get_result()
  File "/Users/nc24497dhruvsinghal/.pyenv/versions/3.9.18/lib/python3.9/concurrent/futures/_base.py", line 391, in __get_result
    raise self._exception
  File "/Users/nc24497dhruvsinghal/Documents/rasa_init/venv/lib/python3.9/site-packages/dask/local.py", line 542, in submit
    fut.set_result(fn(*args, **kwargs))
  File "/Users/nc24497dhruvsinghal/Documents/rasa_init/venv/lib/python3.9/site-packages/dask/local.py", line 238, in batch_execute_tasks
    return [execute_task(*a) for a in it]
  File "/Users/nc24497dhruvsinghal/Documents/rasa_init/venv/lib/python3.9/site-packages/dask/local.py", line 238, in <listcomp>
    return [execute_task(*a) for a in it]
  File "/Users/nc24497dhruvsinghal/Documents/rasa_init/venv/lib/python3.9/site-packages/dask/local.py", line 229, in execute_task
    result = pack_exception(e, dumps)
  File "/Users/nc24497dhruvsinghal/Documents/rasa_init/venv/lib/python3.9/site-packages/dask/local.py", line 224, in execute_task
    result = _execute_task(task, data)
  File "/Users/nc24497dhruvsinghal/Documents/rasa_init/venv/lib/python3.9/site-packages/dask/core.py", line 119, in _execute_task
    return func(*(_execute_task(a, cache) for a in args))
  File "/Users/nc24497dhruvsinghal/Documents/rasa_init/venv/lib/python3.9/site-packages/rasa/engine/graph.py", line 503, in __call__
    raise GraphComponentException(
rasa.engine.exceptions.GraphComponentException: Error running graph component for node train_UnexpecTEDIntentPolicy2.

nlu.yml

v

ersion: "3.1"
nlu:
- intent: greet
  examples: |
    - hey
    - hello
    - hi
    - hello there
    - good morning
    - good evening
    - moin
    - hey there
    - hey dude
    - goodmorning
    - goodevening
    - good afternoon

- intent: goodbye
  examples: |
    - cu
    - good by
    - cee you later
    - good night
    - bye
    - goodbye
    - have a nice day
    - see you around
    - bye bye
    - see you later

- intent: affirm
  examples: |
    - yes
    - y
    - indeed
    - of course
    - that sounds good
    - correct

- intent: deny
  examples: |
    - no
    - n
    - never
    - I dont think so
    - dont like that
    - no way
    - not really

- intent: mood_great
  examples: |
    - perfect
    - great
    - amazing
    - feeling like a king
    - wonderful
    - I am feeling very good
    - I am great
    - I am amazing
    - I am going to save the world
    - super stoked
    - extremely good
    - so so perfect
    - so good
    - so perfect

- intent: mood_unhappy
  examples: |
    - my day was horrible
    - I am sad
    - I dont feel very well
    - I am disappointed
    - super sad
    - Im so sad
    - sad
    - very sad
    - unhappy
    - not good
    - not very good
    - extremly sad
    - so saad
    - so sad

- intent: bot_challenge
  examples: |
    - are you a bot?
    - are you a human?
    - am I talking to a bot?
    - am I talking to a human?

- intent: supply_contact_info
  examples: |
    - My name is [John](name). emails [john@email.com](email)
    - name: [David](name) email: [david@email.com](email)
    - Yeah sure. Im [Barbara](name). My email is [barbara@email.com](email)
    - [Susan](name), [susan@email.com](email)
    - Sure. Its [Fred](name). My email is [fred@email.com](email).
    

- intent: select_category
  examples: |
    - Show me categories
    - Choose a category
    - category
    - I want categories
    - list me categories
    - can u show me categories

- intent: give_category
  examples: |
    - Onion
    - Potato
    - Ginger
    - Carrot

- intent: select_mandi
  examples: |
    - Select a mandi
    - Choose a mandi

- intent: give_mandi
  examples: |
    - Bangalore
    - Chennai
    - Delhi
    - Mumbai
    

- intent: check_price
  examples: |
    - What is the price?
    - Check the price

- intent: select_another_mandi
  examples: |
    - Select another mandi
    - Choose another mandi

- intent: exit
  examples: |
    - Exit
    - Quit
    - Stop

stories.yml

- story: user supplies customer info
  steps:
  - intent: greet
  - action: utter_ask_for_contact_info
  - intent: supply_contact_info
    entities:
    - name
    - email
  - action: utter_acknowledge_provided_info

- story: Showing prices for categories and mandi selected by the user.
  steps:
    - intent: greet
    - action: utter_greet
    - intent: select_category
      entities:
        - category
    - action: utter_select_category
    - intent: give_category
    - entities:
        - mandi
    - action: utter_give_category
    - intent: give_mandi
    - action: utter_give_mandi
    - intent: select_another_mandi
    - action: utter_select_another_mandi
    - intent: exit
    - action: utter_exit

domain.yml

version: '3.1'
intents:
  - greet
  - goodbye
  - affirm
  - deny
  - mood_great
  - mood_unhappy
  - bot_challenge
  - supply_contact_info
  - select_category
  - select_mandi
  - check_price
  - select_another_mandi
  - exit

entities:
  - category
  - mandi

responses:
  utter_greet:
    - text: Hey! How are you, How i can help you?
  utter_cheer_up:
    - text: 'Here is something to cheer you up:'
      image: 'https://i.imgur.com/nGF1K8f.jpg'
  utter_did_that_help:
    - text: Did that help you?
  utter_happy:
    - text: 'Great, carry on!'
  utter_goodbye:
    - text: Bye
  utter_iamabot:
    - text: 'I am a bot, powered by Rasa.'
  utter_ask_for_contact_info:
    - text: Hello! Could you please provide your contact information?
  utter_acknowledge_provided_info:
    - text: Thanks {name} for provided your info!

  utter_select_category:
    - text: "Please select a category of your choice."
  utter_give_category:
    - text: "Sure, Now select the popular mandis for this category."

  utter_select_mandi:
    - text: "Great choice! Now select a mandi within the chosen category."

  utter_give_mandi:
    - text: "Great So the price for your selected stuff is 1500."

  utter_check_price:
    - text: "Sure! Checking the price for your selection..."

  utter_select_another_mandi:
    - text: "Sure list the mandi of it."

  utter_exit:
    - text: "Thank you for using the chatbot. Have a great day!"
session_config:
  session_expiration_time: 60
  carry_over_slots_to_new_session: true

I have a very basic flow of rasa to greet, to look for categories, to ask price, will add APIS currently its hardcoded but on running it is giving error, I tried a lot but not able to understand what is causing the error, any help would be appreciated.


Solution

  • If you look at the stack trace you included in your question, it gives the type and reason for the exception you are facing ValueError: 'give_category' is not in list

    You have a ValueError because give_category is not in your list. A ValueError occurs when an incorrect value is supplied so you can fix this by either including give_category in your list or modifying your program accordingly.