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.92k stars 4.63k forks source link

tracker.getslot transforms data to None #3235

Closed antoinecomp closed 5 years ago

antoinecomp commented 5 years ago
**Rasa version**: rasa-core 0.12.4 rasa-core-sdk 0.12.2 rasa-nlu 0.13.8 **Python version**: 3.6.7 **Operating system** (windows, osx, ...): Windows 10 **Issue**: I am trying to develop [this chatbot](https://github.com/antoinecomp/bookchatbot) based on rasa starter pack. I added some action, especially one that is used to book a room and store the bookings in MySQL database. On the client side I start conversing with it and everything seems alright. Yet when reaching to the point it has to do an action. Triggering `action.py` it has to get to the database and store information. And while triggering this I have the following error `TypeError: Parser must be a string or character stream, not NoneType`. Indeed, in ActionBookRoom I try to get the information from a conversation that looks like: ``` I want to book a room 2019-04-09 18:49:36 WARNING py.warnings - C:\Users\antoi\Documents\Programming\Nathalie\18_2_2019\starter-pack-rasa-stack\staenv\lib\site-packages\sklearn\preprocessing\label.py:151: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty. if diff: 127.0.0.1 - - [2019-04-09 18:49:36] "POST /webhooks/rest/webhook?stream=true&token= HTTP/1.1" 200 181 0.054772 In what room? Red 2019-04-09 18:49:39 WARNING py.warnings - C:\Users\antoi\Documents\Programming\Nathalie\18_2_2019\starter-pack-rasa-stack\staenv\lib\site-packages\sklearn\preprocessing\label.py:151: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty. if diff: What day?127.0.0.1 - - [2019-04-09 18:49:39] "POST /webhooks/rest/webhook?stream=true&token= HTTP/1.1" 200 177 0.061889 Tomorrow 2019-04-09 18:49:42 WARNING py.warnings - C:\Users\antoi\Documents\Programming\Nathalie\18_2_2019\starter-pack-rasa-stack\staenv\lib\site-packages\sklearn\preprocessing\label.py:151: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty. if diff: What time do you want to start your meeting?127.0.0.1 - - [2019-04-09 18:49:42] "POST /webhooks/rest/webhook?stream=true&token= HTTP/1.1" 200 212 0.034834 1pm 2019-04-09 18:49:46 WARNING py.warnings - C:\Users\antoi\Documents\Programming\Nathalie\18_2_2019\starter-pack-rasa-stack\staenv\lib\site-packages\sklearn\preprocessing\label.py:151: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty. if diff: How long would you need ?127.0.0.1 - - [2019-04-09 18:49:46] "POST /webhooks/rest/webhook?stream=true&token= HTTP/1.1" 200 193 0.054826 30 min 2019-04-09 18:49:52 WARNING py.warnings - C:\Users\antoi\Documents\Programming\Nathalie\18_2_2019\starter-pack-rasa-stack\staenv\lib\site-packages\sklearn\preprocessing\label.py:151: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty. if diff: ``` I got `None tomorrow None 30 min`. To get these information I used `tracker.getslot`: ```python class ActionBookRoom(Action): def name(self): return 'action_room' def run(self, dispatcher, tracker, domain): print("inside run") name_room = tracker.get_slot('name_room') day = tracker.get_slot('day') hour_start = tracker.get_slot('hour_start') duration = tracker.get_slot('duration') ``` And on the action server side I have then the following error message: ``` (staenv) C:\Users\antoi\Documents\Programming\Nathalie\18_2_2019\starter-pack-rasa-stack>python -m rasa_core_sdk.endpoint --actions actions 2019-04-09 18:48:14 INFO __main__ - Starting action endpoint server... 2019-04-09 18:48:15 INFO rasa_core_sdk.executor - Registered function for 'action_joke'. 2019-04-09 18:48:15 INFO rasa_core_sdk.executor - Registered function for 'action_room'. 2019-04-09 18:48:15 INFO __main__ - Action endpoint is up and running. on ('0.0.0.0', 5055) inside run before booking_answer None tomorrow None 30 min [2019-04-09 18:49:54,104] ERROR in app: Exception on /webhook [POST] Traceback (most recent call last): File "C:\Users\antoi\Documents\Programming\Nathalie\18_2_2019\starter-pack-rasa-stack\staenv\lib\site-packages\flask\app.py", line 2292, in wsgi_app response = self.full_dispatch_request() File "C:\Users\antoi\Documents\Programming\Nathalie\18_2_2019\starter-pack-rasa-stack\staenv\lib\site-packages\flask\app.py", line 1815, in full_dispatch_request rv = self.handle_user_exception(e) File "C:\Users\antoi\Documents\Programming\Nathalie\18_2_2019\starter-pack-rasa-stack\staenv\lib\site-packages\flask_cors\extension.py", line 161, in wrapped_function return cors_after_request(app.make_response(f(*args, **kwargs))) File "C:\Users\antoi\Documents\Programming\Nathalie\18_2_2019\starter-pack-rasa-stack\staenv\lib\site-packages\flask\app.py", line 1718, in handle_user_exception reraise(exc_type, exc_value, tb) File "C:\Users\antoi\Documents\Programming\Nathalie\18_2_2019\starter-pack-rasa-stack\staenv\lib\site-packages\flask\_compat.py", line 35, in reraise raise value File "C:\Users\antoi\Documents\Programming\Nathalie\18_2_2019\starter-pack-rasa-stack\staenv\lib\site-packages\flask\app.py", line 1813, in full_dispatch_request rv = self.dispatch_request() File "C:\Users\antoi\Documents\Programming\Nathalie\18_2_2019\starter-pack-rasa-stack\staenv\lib\site-packages\flask\app.py", line 1799, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "C:\Users\antoi\Documents\Programming\Nathalie\18_2_2019\starter-pack-rasa-stack\staenv\lib\site-packages\flask_cors\decorator.py", line 128, in wrapped_function resp = make_response(f(*args, **kwargs)) File "C:\Users\antoi\Documents\Programming\Nathalie\18_2_2019\starter-pack-rasa-stack\staenv\lib\site-packages\rasa_core_sdk\endpoint.py", line 86, in webhook response = executor.run(action_call) File "C:\Users\antoi\Documents\Programming\Nathalie\18_2_2019\starter-pack-rasa-stack\staenv\lib\site-packages\rasa_core_sdk\executor.py", line 177, in run events = action(dispatcher, tracker, domain) File "C:\Users\antoi\Documents\Programming\Nathalie\18_2_2019\starter-pack-rasa-stack\actions.py", line 43, in run booking_answer = make_a_booking(name_room, day, hour_start, duration) File "C:\Users\antoi\Documents\Programming\Nathalie\18_2_2019\starter-pack-rasa-stack\booking.py", line 68, in make_a_booking hour_start_parsed = dateutil.parser.parse(hour_start, fuzzy_with_tokens=True) File "C:\Users\antoi\Documents\Programming\Nathalie\18_2_2019\starter-pack-rasa-stack\staenv\lib\site-packages\dateutil\parser\_parser.py", line 1356, in parse return DEFAULTPARSER.parse(timestr, **kwargs) File "C:\Users\antoi\Documents\Programming\Nathalie\18_2_2019\starter-pack-rasa-stack\staenv\lib\site-packages\dateutil\parser\_parser.py", line 645, in parse res, skipped_tokens = self._parse(timestr, **kwargs) File "C:\Users\antoi\Documents\Programming\Nathalie\18_2_2019\starter-pack-rasa-stack\staenv\lib\site-packages\dateutil\parser\_parser.py", line 721, in _parse l = _timelex.split(timestr) # Splits the timestr into tokens File "C:\Users\antoi\Documents\Programming\Nathalie\18_2_2019\starter-pack-rasa-stack\staenv\lib\site-packages\dateutil\parser\_parser.py", line 207, in split return list(cls(s)) File "C:\Users\antoi\Documents\Programming\Nathalie\18_2_2019\starter-pack-rasa-stack\staenv\lib\site-packages\dateutil\parser\_parser.py", line 76, in __init__ '{itype}'.format(itype=instream.__class__.__name__)) TypeError: Parser must be a string or character stream, not NoneType 2019-04-09 18:49:54 ERROR flask.app - Exception on /webhook [POST] Traceback (most recent call last): File "C:\Users\antoi\Documents\Programming\Nathalie\18_2_2019\starter-pack-rasa-stack\staenv\lib\site-packages\flask\app.py", line 2292, in wsgi_app response = self.full_dispatch_request() File "C:\Users\antoi\Documents\Programming\Nathalie\18_2_2019\starter-pack-rasa-stack\staenv\lib\site-packages\flask\app.py", line 1815, in full_dispatch_request rv = self.handle_user_exception(e) File "C:\Users\antoi\Documents\Programming\Nathalie\18_2_2019\starter-pack-rasa-stack\staenv\lib\site-packages\flask_cors\extension.py", line 161, in wrapped_function return cors_after_request(app.make_response(f(*args, **kwargs))) File "C:\Users\antoi\Documents\Programming\Nathalie\18_2_2019\starter-pack-rasa-stack\staenv\lib\site-packages\flask\app.py", line 1718, in handle_user_exception reraise(exc_type, exc_value, tb) File "C:\Users\antoi\Documents\Programming\Nathalie\18_2_2019\starter-pack-rasa-stack\staenv\lib\site-packages\flask\_compat.py", line 35, in reraise raise value File "C:\Users\antoi\Documents\Programming\Nathalie\18_2_2019\starter-pack-rasa-stack\staenv\lib\site-packages\flask\app.py", line 1813, in full_dispatch_request rv = self.dispatch_request() File "C:\Users\antoi\Documents\Programming\Nathalie\18_2_2019\starter-pack-rasa-stack\staenv\lib\site-packages\flask\app.py", line 1799, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "C:\Users\antoi\Documents\Programming\Nathalie\18_2_2019\starter-pack-rasa-stack\staenv\lib\site-packages\flask_cors\decorator.py", line 128, in wrapped_function resp = make_response(f(*args, **kwargs)) File "C:\Users\antoi\Documents\Programming\Nathalie\18_2_2019\starter-pack-rasa-stack\staenv\lib\site-packages\rasa_core_sdk\endpoint.py", line 86, in webhook response = executor.run(action_call) File "C:\Users\antoi\Documents\Programming\Nathalie\18_2_2019\starter-pack-rasa-stack\staenv\lib\site-packages\rasa_core_sdk\executor.py", line 177, in run events = action(dispatcher, tracker, domain) File "C:\Users\antoi\Documents\Programming\Nathalie\18_2_2019\starter-pack-rasa-stack\actions.py", line 43, in run booking_answer = make_a_booking(name_room, day, hour_start, duration) File "C:\Users\antoi\Documents\Programming\Nathalie\18_2_2019\starter-pack-rasa-stack\booking.py", line 68, in make_a_booking hour_start_parsed = dateutil.parser.parse(hour_start, fuzzy_with_tokens=True) File "C:\Users\antoi\Documents\Programming\Nathalie\18_2_2019\starter-pack-rasa-stack\staenv\lib\site-packages\dateutil\parser\_parser.py", line 1356, in parse return DEFAULTPARSER.parse(timestr, **kwargs) File "C:\Users\antoi\Documents\Programming\Nathalie\18_2_2019\starter-pack-rasa-stack\staenv\lib\site-packages\dateutil\parser\_parser.py", line 645, in parse res, skipped_tokens = self._parse(timestr, **kwargs) File "C:\Users\antoi\Documents\Programming\Nathalie\18_2_2019\starter-pack-rasa-stack\staenv\lib\site-packages\dateutil\parser\_parser.py", line 721, in _parse l = _timelex.split(timestr) # Splits the timestr into tokens File "C:\Users\antoi\Documents\Programming\Nathalie\18_2_2019\starter-pack-rasa-stack\staenv\lib\site-packages\dateutil\parser\_parser.py", line 207, in split return list(cls(s)) File "C:\Users\antoi\Documents\Programming\Nathalie\18_2_2019\starter-pack-rasa-stack\staenv\lib\site-packages\dateutil\parser\_parser.py", line 76, in __init__ '{itype}'.format(itype=instream.__class__.__name__)) TypeError: Parser must be a string or character stream, not NoneType 127.0.0.1 - - [2019-04-09 18:49:54] "POST /webhook HTTP/1.1" 500 412 1.047401 ``` I tried to know if it is able to recognize the missing entities, the one that are transformed to `None` then in interactive mode: ``` ? Next user input (Ctr-c to abort): Red C:\Users\antoi\Documents\Programming\Nathalie\18_2_2019\starter-pack-rasa-stack\staenv\lib\site-packages\sklearn\preprocessing\label.py:151: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty. if diff: ? Is the NLU classification for 'Red' with intent 'book_room' correct? Yes ------ Chat History # Bot You ───────────────────────────────────────────────────────────────────────────── 1 action_listen ───────────────────────────────────────────────────────────────────────────── 2 Hello intent: greet 0.68 ───────────────────────────────────────────────────────────────────────────── 3 utter_greet 0.51 Nice to you meet you None. How can I help? action_listen 1.00 ───────────────────────────────────────────────────────────────────────────── 4 Can I book a room? intent: book_room 0.25 ───────────────────────────────────────────────────────────────────────────── 5 utter_ask_room 1.00 In what room? action_listen 1.00 ───────────────────────────────────────────────────────────────────────────── 6 Red intent: book_room 0.61 Current slots: day: None, duration: None, hour_start: None, name: None, name_room: None ``` As far as `name_room: None` is still `None` I think it is not able. **Content of configuration file (config.yml)**: ```yml ``` **Content of domain file (domain.yml)** (if used & relevant): ```yaml intents: - greet - goodbye - thanks - deny - joke - name entities: - name - name_room - day - hour_start - duration slots: name: type: text name_room: type: text day: type: text hour_start: type: text duration: type: text actions: - utter_name - utter_thanks - utter_greet - utter_goodbye - action_joke - utter_ask_room - utter_ask_day - utter_ask_hour_start - utter_ask_duration - action_room templates: utter_name: - text: "Hey there! Tell me your name." utter_greet: - text: "Nice to you meet you {name}. How can I help?" utter_goodbye: - text: "Talk to you later!" utter_thanks: - text: "My pleasure." utter_ask_room: - 'In what room?' utter_ask_day: - 'What day?' utter_ask_hour_start: - 'What time do you want to start your meeting?' utter_ask_duration: - 'How long would you need ?' ```
akelad commented 5 years ago

Thanks for raising this issue, @erohmensing will get back to you about it soon.

erohmensing commented 5 years ago

Hmm okay. Have you tried running your bot with the --debug flag? When you run in debug, it prints out the slots each time so that you can see if your slot is actually being filled (my hunch is that the problem is that the slot isn't being filled, instead of the tracker.get_slot() turning it into None). This would happen if the entity recognition isn't detecting your entity, a result of not enough training data.

What does your training data for the name_room entity look like?

halloTheCoder commented 5 years ago

As you have mentioned me in issue #2638, I am answering here. It has been quite a while for me since I last used RASA so I am quite unsure of what I am speaking. Correct me if I am wrong.

I agree with @erohmensing The problem I think is that the entities missing are not being detected, Can you also add the screenshot of interactive learning related to what happens after you entered Red, like what entities are being detected. If the entities are not being detected implies the NLU part is not trained well, otherwise, I cannot think anything suitable that is wrong with the code. Also, add those parts when you added entities like 30 mins and tomorrow in the interactive learning as they are being detected correctly by rasa.

no-response[bot] commented 5 years ago

This issue has been automatically closed because there has been no response to our request for more information from the original author. Without this, we don't have enough information to help you. Please comment below with the requested information if you still need help.