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.55k stars 4.59k forks source link

interactive training issue #2579

Closed e8180kimo closed 5 years ago

e8180kimo commented 5 years ago
**Rasa Core version**: master **Python version**: 3.6 **Operating system** (windows, osx, ...): osx **Issue**: When I am running interactive learning and when i am on the slot part, after `utter_ask_thesis`, it should come with a `requested_slot` right? But it went to ask user input (`action_listen`), then the next action I pick is the slot action I define in `actions.py`, which is `action_topic`. The stories generated by the interactive learning is like this: ``` ... * confirm_completion - utter_ask_thesis * thesis1 - action_thesis - slot{"requested_slot": "slot_thesis"} ... ``` This resulted in showing the `slot_thesis` has no value when I run the bot The stories should look like this right? First, after `utter_ask_thesis` comes with a `requested_slot`, then after `action_listen` and user input followed by `action_thesis` and `slot_thesis` to store the slot. ``` ... ... * confirm_completion - utter_ask_thesis - slot{"requested_slot": "slot_thesis"} * thesis1 - action_thesis - slot{"slot_thesis": "my thesis statement is xxxxxxxxxxxx"} ... ``` actions.py ``` from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals import os from bot import RestaurantAPI from rasa_core_sdk import Action from rasa_core_sdk.events import SlotSet """ from rasa_core import utils from rasa_core.agent import Agent from rasa_core_sdk.events import * from rasa_core.featurizers import ( MaxHistoryTrackerFeaturizer, BinarySingleStateFeaturizer) from rasa_core.interpreter import RasaNLUInterpreter from rasa_core.policies.memoization import MemoizationPolicy """ from rasa_core_sdk.forms import ( BooleanFormField, EntityFormField, FormAction, FreeTextFormField ) import logging logger = logging.getLogger(__name__) class BookingInfo(object): def save(self, slot_topic): logger.debug("-------slot_topic---------") logger.debug(format(slot_topic)) logger.debug("-------slot_topic---------") return class ThesisInfo(object): def save(self, slot_thesis): logger.debug("-------slot_thesis---------") logger.debug(format(slot_thesis)) logger.debug("-------slot_thesis---------") return class ThesisUpdateInfo(object): def save(self, slot_ThesisUpdate): logger.debug("-------slot_ThesisUpdate---------") logger.debug(format(slot_ThesisUpdate)) logger.debug("-------slot_ThesisUpdate---------") return class ActionTopic(FormAction): RANDOMIZE = False @staticmethod def required_fields(): return [ EntityFormField("slot_topic", "slot_topic") ] def name(self): return 'action_topic' def submit(self, dispatcher, tracker, domain): Bookinginfo = BookingInfo() booking = Bookinginfo.save(tracker.get_slot("slot_topic")) #indexFile_topic = open('C:/Users/e8180/Documents/sfu/py_rasabot/dd0628/dd/' + 'testextract.txt', 'a+') #indexFile_topic.write(tracker.get_slot("essay_topic") + str('\n\n')) #indexFile_topic.close() #return[SlotSet("matches", booking)] return[] class ActionThesis(FormAction): RANDOMIZE = False @staticmethod def required_fields(): return [ FreeTextFormField("slot_thesis") ] def name(self): return 'action_thesis' def submit(self, dispatcher, tracker, domain): Thesis_Info = ThesisInfo() booking = Thesis_Info.save(tracker.get_slot("slot_thesis")) return[] class ActionThesisUpdate(FormAction): RANDOMIZE = False @staticmethod def required_fields(): return [ FreeTextFormField("slot_ThesisUpdate") ] def name(self): return 'action_ThesisUpdate' def submit(self, dispatcher, tracker, domain): ThesisUpdate_info = ThesisUpdateInfo() booking = ThesisUpdate_info.save(tracker.get_slot("slot_ThesisUpdate")) return[] ``` **Content of domain file** (if used & relevant): ```domain.yaml intents: - greet - request_essay_help - choose_argument - choose_no - confirm_completion - topic - thesis1 - thesis2 - goodbye - out_of_scope - thesis_help - topic_help - modify_thesis - reading - argumentation - counterargument - start - evaluatethesis - out_of_scope actions: - utter_greet - utter_show_reading_list - utter_need_other_help - utter_tell_me_more - utter_modify_thesis - utter_focused_info - utter_arguable_info - utter_type_of_help - utter_refer_TA - utter_ending_print_conv - utter_confirm_thesis_arguable - utter_confirm_thesis_focused - utter_thesis_define - utter_try_reading_stra - utter_reading_stra - utter_open_reading - utter_have_reading - utter_not_related_ed - utter_have_topic - utter_knowing_thesis - utter_have_thesis - utter_ask_topic - utter_ask_thesis - utter_ask_ThesisUpdate - action_topic - action_thesis - action_ThesisUpdate - utter_default entities: - slot_topic - slot_thesis - slot_ThesisUpdate slots: slot_topic: type: text slot_thesis: type: text slot_ThesisUpdate: type: text requested_slot: type: unfeaturized templates: utter_default : - text: "Sorry, I didn’t understand that" utter_greet: - text: "Hi, welcome to nStudy Bot" buttons: - title: "Get me started" payload: "Get me started" utter_show_reading_list: - text: "Here's the link to the reading resources for EDUC 220 final essay. Please open the link below. Click Done when you finished." buttons: - title: "Done" payload: "Done" utter_tell_me_more: - text: "Sorry. I am not smart enough to help you with this. Could you tell me more about your issues?" buttons: - title: "OK" payload: "OK" utter_ask_ThesisUpdate: - text: "What is your new thesis statement?" utter_modify_thesis: - text: "Do you want to modify your thesis statement?" buttons: - title: "Yes" payload: "Yes" - title: "No" payload: "No" utter_focused_info: - text: "A focused thesis statement means that your thesis statement should not be too broad. For example, bullying can affect children's cognitive development. The example thesis statement is too broad. You must say something like this: Bullying can affect children's cognitive development because A, B, and C. Referring to the handout here for more information. " buttons: - title: "Okay" payload: "Okay" - title: "Okay. Go to handout...develop in the future" payload: "Okay. Go to handout" utter_arguable_info: - text: "A thesis statement should not be a fact, which means that somebody can disargee with your thesis statement. This is what an arguable thesis should be. Check out the handout here for more information. " buttons: - title: "Okay. Take me back" payload: "Okay. Take me back" - title: "Okay. Go to handout" payload: "Okay. Go to handout" utter_type_of_help: - text: "Which of the following help do you need?" buttons: - title: "Help me come up with a topic for essay" payload: "Help me come up with a topic for essay" - title: "Plan my essay outline" payload: "Plan my essay outline" - title: "Thesis statement" payload: "Thesis statement" - title: "Argumentation" payload: "Argumentation" - title: "Counterarguments" payload: "Counterarguments" - title: "Reading strategies" payload: "Reading strategies" - title: "Strategies for polishing my essay" payload: "Strategies for polishing my essay" - title: "Evaluating my essay's thesis statement" payload: "Evaluating my essay's thesis statement" - title: "Goal Setting for studying" payload: "Goal Setting for studying" utter_refer_TA: - text: "At this point, I recommend you go for TA or your instructor for help. Ok?" buttons: - title: "Okay" payload: "Okay" utter_ending_print_conv: - text: "Thank you for using nStudy Bot. Do you want to print our conversation?" buttons: - title: "Yes" payload: "Yes" - title: "No" payload: "No" utter_need_other_help: - text: "Do you need any other help?" buttons: - title: "Yes" payload: "Yes" - title: "No" payload: "No" utter_confirm_thesis_focused: - text: "Is your thesis statement focused?" buttons: - title: "Yes" payload: "yes" - title: "No" payload: "no" utter_confirm_thesis_arguable: - text: "Is your thesis statement arguable/contestable?" buttons: - title: "Yes" payload: "yes" - title: "No" payload: "no" utter_thesis_define: - text: "In university writing, a thesis statement is typically a sentence or two which establishes your argument and forecasts the main points your paper will argue. It is the backbone of your paper, because everything that follows should support this central argument. A thesis has to be arguable/contestable and cannot be a statement of fact. Do you understand? " buttons: - title: "Yes" payload: "yes" - title: "No" payload: "no" utter_ask_thesis: - text: "What is your thesis statement?" utter_try_reading_stra: - text: "Would you like to try one of the following reading strategies? " buttons: - title: "Highlighting" payload: "Highlighting" - title: "Note-taking" payload: "Note-taking" - title: "Summarizing" payload: "Summarizing" - title: "Outlining" payload: "Outlining" - title: "Show me termnet" payload: "Show me termnet" - title: "I do not want to try any of these" payload: "I do not want to try any of these" utter_reading_stra: - text: "Did you do any of the followings when you consulted your reading resources? For example, highlighting, notetaking, summarizing, outlining, or mindmapping? " utter_open_reading: - text: "Open and review the reading resources. Let me know when you are done. " buttons: - title: "Done" payload: "Done" utter_have_reading: - text: "Do you have any reading resources? " buttons: - title: "Yes" payload: "yes" - title: "No" payload: "no" utter_not_related_ed: - text: "Could you find a topic in educaitonal psychology that is related to {slot_topic}? " buttons: - title: "Yes" payload: "yes" - title: "No" payload: "no" utter_show_topic: - text: "What kind of topics in educational psychology that you know about?" utter_ask_topic: - text: "What is your topic?" utter_have_topic: - text: "Do you have a topic in mind?" buttons: - title: "Yes" payload: "yes" - title: "No" payload: "no" utter_knowing_thesis: - text: "Do you know what a thesis statement is?" buttons: - title: "Yes" payload: "yes" - title: "No" payload: "no" utter_have_thesis: - text: "Do you have a thesis statement?" buttons: - title: "Yes" payload: "yes" - title: "No" payload: "no" ```
akelad commented 5 years ago

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

Ghostvv commented 5 years ago

It is hard to understand where exactly is the issue. Could you please restructure your question, indicating where is an error, what is returned by rasa, and what is expected by you

e8180kimo commented 5 years ago

It is hard to understand where exactly is the issue. Could you please restructure your question, indicating where is an error, what is returned by rasa, and what is expected by you

I just rephrase my question, thanks.

e8180kimo commented 5 years ago

any update?

Ghostvv commented 5 years ago

action_thesis being the form, emits utter_ask_thesis automatically, so you should call action_thesis instead. There story would look something like:


...
* confirm_completion
    - action_thesis
    - slot{"requested_slot": "slot_thesis"}
* thesis1
    - action_thesis
...
e8180kimo commented 5 years ago

action_thesis being the form, emits utter_ask_thesis automatically, so you should call action_thesis instead. There story would look something like:

...
* confirm_completion
    - action_thesis
    - slot{"requested_slot": "slot_thesis"}
* thesis1
    - action_thesis
...

But if I am manually adding the stories, should I use the format below (like the one shown as an example on Rasa docs) or same as the one you just said?

* confirm_completion
    - utter_ask_thesis
    - slot{"requested_slot": "slot_thesis"}
* thesis1
    - action_thesis
    - slot{"slot_thesis": "my thesis statement is xxxxxxxxxxxx"}
Ghostvv commented 5 years ago

for FormAction, please take a look at the docs here: https://www.rasa.com/docs/core/slotfilling/#slot-filling-with-a-formaction there is an example of the story for restaurant form

Since there is no bug, and this is a discussion on how to use the FormAction, please go to our forum: https://forum.rasa.com