Rasa如何从用户获取值(插槽)

时间:2019-10-11 20:40:11

标签: rasa-nlu rasa-core

我希望rasa在要求用户提供零件编号预测时回复他们。

从我的阅读中,我知道我需要使用插槽,但是我找不到一个清楚的例子,我无法理解如何从用户那里获得零件编号。

如果我可以在其中看到示例性的nlu,故事和域,那么这将给我一个领先的机会

  1. 要求用户提供零件号
  2. 用户输入零件号
  3. Rasa会提供零件号。

这是我到目前为止的情况。

domain.yml

intents:
- greet
- goodbye
- affirm
- deny
- mood_great
- mood_unhappy
- bot_challenge
- get_supplier_forecast
entities:
- partnumber
slots:
  partnumber:
    type: text
templates:
  utter_greet:
  - text: Hey! How are 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_get_part_number:
  - text: can you give me the part number please
  utter_give_me_a_minute_while_i_check:
  - text: Give me a minute while I see if I can find a forecast for {partnumber}
  utter_confirm_part_number:
  - text: Thanks you asked for forecast for {partnumber} did this help?
actions:
- utter_greet
- utter_cheer_up
- utter_did_that_help
- utter_happy
- utter_goodbye
- utter_iamabot
- utter_get_part_number
- utter_give_me_a_minute_while_i_check
- utter_confirm_part_number

nlu.md

## intent:greet
- hey
- hello
- hi
- good morning
- good evening
- hey there

## intent:goodbye
- bye
- goodbye
- see you around
- see you later

## intent:affirm
- yes
- indeed
- of course
- that sounds good
- correct

## intent:deny
- no
- never
- I don't think so
- don't like that
- no way
- not really

## intent:mood_great
- perfect
- very good
- great
- amazing
- wonderful
- I am feeling very good
- I am great
- I'm good

## intent:mood_unhappy
- sad
- very sad
- unhappy
- bad
- very bad
- awful
- terrible
- not very good
- extremely sad
- so sad

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

## intent:get_supplier_forecast
- Give me a forecast
- Give me a part number forecast
- I want a forecast
- I want a part number forecast
- I want a forecast for a part
- I want a supplier forecast
- Forecast delivery date
- I need a part number delivery date
- I need an item delivery date
- When will i get a part delivered

stories.md

## happy path
* greet
  - utter_greet
* mood_great
  - utter_happy

## sad path 1
* greet
  - utter_greet
* mood_unhappy
  - utter_cheer_up
  - utter_did_that_help
* affirm
  - utter_happy

## sad path 2
* greet
  - utter_greet
* mood_unhappy
  - utter_cheer_up
  - utter_did_that_help
* deny
  - utter_goodbye

## say goodbye
* goodbye
  - utter_goodbye

## bot challenge
* bot_challenge
  - utter_iamabot

## give me a forecast
* get_supplier_forecast{"partnumber":"J12345-001"}
  - slot {"partnumber":"J12345-001"}
  - utter_get_part_number
  - utter_confirm_part_number

1 个答案:

答案 0 :(得分:0)

域文件保持不变。尝试以下事情。

故事文件:

## give me a forecast path1
* get_supplier_forecast{"partnumber":null}
  - slot {"partnumber":null}
  - utter_get_part_number
## give me a forecast path2
* get_supplier_forecast{"partnumber":"J12345-001"}
  - slot {"partnumber":"J12345-001"}
  - utter_confirm_part_number

包括此NLU文件:

## intent:get_supplier_forecast
#this is how to mention slots in nlu file
- ['J12345-001'](partnumber)

注意:我不知道您的情况下的“ 零件号”是什么。如果它们太多,您可能想使用“查找表”。

如果插槽为空,{p> 1将触发上面的更改,并且如果插槽中填充了值utter_get_part_number,则会触发

如果这不能满足您的需求或无法按预期工作,则可以尝试rasa交互式培训。只需在CMD上运行utter_confirm_part_number或尝试rasa x交互式对话即可。由此,您可以选择对机器人的期望