RASA学习笔记-新建第一个rasa项目(二)

在第上篇新建的rasa项目基础上添加form

一、修改domain.yml

在domain.yml中定义slots,添加如下所示内容

定义response 模板

二、修改data/nlu.yml

补充训练数据

三、修改 data/stories.yml

在stories.yml中添加如下内容:

version: "2.0"
nlu:
- intent: greet
  examples: |
    - hey
    - hello
    - hi
    - hello there
    - good morning
    - good evening
    - moin
    - hey there
    - let's go
    - hey dude
    - goodmorning
    - goodevening
    - good afternoon
    - fine, thank you, and you?
- intent: goodbye
  examples: |
    - good afternoon
    - 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
    - sure
    - ok
    - why not
    - ok great
    - yes I did
    - yeah, great
    - pretty good
    - fine
    - I sure did
    - more or less
- intent: deny
  examples: |
    - no
    - n
    - never
    - I don't think so
    - don't like that
    - no way
    - not really
    - none
    - absolutely not
    - no thanks
    - didn't do any
    - no I didn't 
    - could have been better
    - not great 
    - nope
- intent: inform
  examples: |
    - a full [8 hours](sleep)
    - only [four hours](sleep)
    - about [6 hours](sleep)
    - [low](stress)
    - [medium](stress)
    - [high](stress)
    - yes, I went for a [run](exercise)
    - played [football](exercise)
    - I did a [workout](exercise) video
    - Be more patient with my family
    - eat better
    - eat less junk food
    - Go to bed earlier
    - too much sweets
    
- intent: out_of_scope
  examples: |
    - that's not what i want to do 
    - wait stop
    - your are no help
    - this is no help at all
    - how old are you
    - I want to order a pizza
    - tell me the weather
    - I already told you that
    - none of your business
    - stop asking
    - never mind
    - I want to do something else
    - I changed my mind
- 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 don't feel very well
    - I am disappointed
    - super sad
    - I'm so sad
    - sad
    - very sad
    - unhappy
    - not good
    - not very good
    - extremly sad
    - so saad
    - so sad
- intent: thankyou
  examples: |
    - okay great thanks
    - thank you
    - sure thanks
    - thanks bye
    - thanks
- 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: ask_lower_stress
  examples: |
    - What do I do if I'm too stressed?
    - How can I lower my stress level
    - What are some good ways to lower stress?
    - What are good ways to relax?
    - What are some things I can do to lower my stress?
- intent: ask_eat_healthy
  examples: |
    - What's considered a healthy diet?
    - What's considered a good diet?
    - How do I follow a healthy diet?
    - How do I eat healthy?
- intent: ask_exercise
  examples: |
    - What's a good amount of exercise for someone in their thirties?
    - How much exercise should I be getting?
    - How much exercise is recommended?
    - Is walking once a day enough exercise?
    - How much exercise should I do every day?
    - How many times per week should I go to the gym?
- intent: n
  examples: |
    - stop

四、修改 actions/action.py

五、修改 config.yml

添加横线部分内容

六、修改 end_points.yml

七、训练模型

rasa train

八、启动模型

  1. 在一个窗口开启服务
rasa run actions

  1. 另开一个窗口,启动应用
rasa shell

九、对话

原文地址:https://www.cnblogs.com/happygirl-zjj/p/14031803.html