Rasa: RASA: Story generation

Created on 11 Jul 2018  路  5Comments  路  Source: RasaHQ/rasa

Rasa Core version:0.9.6

Python version: 3.6

Operating system (windows, osx, ...): Windows 10

Issue:
I want to find a way to automatically convert any conversation into a story format to be able to train my bot.
I have generated my stories using the online training session, or the machine teaching offered by RASA Core, but I found this technique impractical when I want to have a big training data.
I want to use any conversation and be able to automatically convert it into a story without having to do so manually. Any ideas?

Content of domain file (if used & relevant):


Most helpful comment

Thanks, it worked !

All 5 comments

If you are following the @JustinaPetr Video tutorial

This can be done by adding a end action.
For example:
If conversations end with bye statement, just create a action for bye which has a function to create stories and at the end of the conversation it will convert the entire conversation into the story and save the same into a file you named.
Add the below lines to you action.py file

action.py

from rasa_core.events import Restarted
from rasa_core.events import StoryExported

#---------------Your Entire Action Code here-----------------------

class ActionByeBye (Action):
    def name(self):
        return 'action_bye'
    def run (self, dispatcher, tracker, domain):
        return[StoryExported("data.md"),Restarted()]

Change the stories.md file with the below file.

stories.md

## Generated Story 3320800183399695936
* greet
    - utter_greet
* inform
    - utter_ask_location
* inform{"location": "italy"}
    - slot{"location": "italy"}
    - action_weather
    - slot{"location": "italy"}
* goodbye
    - utter_goodbye
    - action_bye
    - export
## Generated Story -3351152636827275381
* greet
    - utter_greet
* inform[location=London]
    - slot{"location": "London"}
    - action_weather
* goodbye
    - utter_goodbye
    - action_bye
    - export
## Generated Story 8921121480760034253
* greet
    - utter_greet
* inform
    - utter_ask_location
* inform[location=London]
    - slot{"location": "London"}
    - action_weather
* goodbye
    - utter_goodbye
    - action_bye
    - export
## Generated Story -5208991511085841103
    - slot{"location": "London"}
    - action_weather
* goodbye
    - utter_goodbye
    - action_bye
    - export
## Generated Story -5208991511085841103
    - slot{"location": "London"}
    - action_weather
* goodbye
    - utter_goodbye
    - action_bye
    - export
## story_001
* greet
   - utter_greet
* inform
   - utter_ask_location
* inform[location=London]
   - slot{"location": "London"}
   - action_weather
* goodbye
    - utter_goodbye
    - action_bye
    - export
## story_002
* greet
   - utter_greet
* inform[location=Paris]
   - slot{"location": "Paris"}
   - action_weather
* goodbye
    - utter_goodbye
    - action_bye
    - export
## story_003
* greet
   - utter_greet
* inform
   - utter_ask_location
* inform[location=Vilnius]
   - slot{"location": "Vilnius"}
   - action_weather
* goodbye
    - utter_goodbye
    - action_bye
    - export
## story_004
* greet
   - utter_greet
* inform[location=Italy]
   - slot{"location": "Italy"}
   - action_weather
* goodbye
    - utter_goodbye
    - action_bye
    - export
## story_005
* greet
   - utter_greet
* inform
   - utter_ask_location
* inform[location=Lithuania]
   - slot{"location": "Lithuania"}
   - action_weather
* goodbye
    - utter_goodbye
    - action_bye
    - export

Change the weather_domian.yml file with the below file.

weather_domain.yml

slots:
  location:
    type: text


intents:
 - greet
 - goodbye
 - inform


entities:
 - location

templates:
  utter_greet:
    - 'Hello! How can I help?'
  utter_goodbye:
    - 'Talk to you later.'
    - 'Bye bye :('
  utter_ask_location:
    - 'In what location?'


actions:
 - utter_greet
 - utter_goodbye
 - utter_ask_location
 - actions.ActionWeather
 - actions.ActionByeBye

Thanks, it worked !

I see that you used return[StoryExported("data.md"),Restarted()] in action.py and - export in stories.md so I wanted to ask if - export is necessary since you already return this... or in contrast if you should have added - action_restart in the stories.md after the - export action? Or either solution would work?

@balinda-1995 do you need any more help or can we close this issue?

yes i am done, thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nicolasfarina picture nicolasfarina  路  3Comments

yondu22 picture yondu22  路  3Comments

mit4dev picture mit4dev  路  4Comments

nikhilcss97 picture nikhilcss97  路  3Comments

rayush7 picture rayush7  路  3Comments