TheShy
(shy)
June 3, 2023, 2:25am
1
When I trigger an intention, it triggers an ACTION three times, causing it to run slowly.
nlu:
- regex: user_input_name
examples: |
- (?<=查)[a-zA-Z0-9\u4e00-\u9fa5]{2,5}(?=的)
- intent: info_input_name
examples: |
- 请帮我查[张三](user_input_name)的性别
- 帮我查[张三](user_input_name)的性别
- 查[张三](user_input_name)的性别
- 我想查[张三](user_input_name)的性别
domain:
utter_output_name:
- text: "{user_input_name}的性别是{db_get_sex}"
slots:
# name:
# type: text
# mappings:
# - type: custom
# action: action_testName
user_input_name:
type: text
influence_conversation: false
mappings:
- type: from_entity
entity: user_input_name
db_get_sex:
type: text
mappings:
- type: custom
action: action_getSexByName
rules:
rules:
- rule: avtivate user_input_name form
steps:
- intent: info_input_name
- action: name_form
- action: action_getSexByName
- action: utter_output_name
stephens
(Greg Stephens)
June 3, 2023, 6:20pm
2
You’re rule doesn’t look correct. If you’re using a form, follow the best practices for using forms as shown on the docs page here .
There should be separare rules for entering and completing the form as it shows there.
1 Like
TheShy
(shy)
June 3, 2023, 6:39pm
3
Thank you.
I tried to write the correct rule, but the action still fires three times, and I see it print slot three times in the console.
However, I deleted the relevant rule without any effect on the results.Is the problem caused by me not being trained on Actions
stephens
(Greg Stephens)
June 3, 2023, 6:57pm
4
I don’t have enough information to answer your question. Attach the debug log and a link to your github repo and I will take a look.
TheShy
(shy)
June 3, 2023, 7:12pm
5
I’m sorry, it may take me two days to upload the code to github, because I can’t control that computer these days.
TheShy
(shy)
June 5, 2023, 1:09am
6
I uploaded the relevant yml files to Github.
Shy280/RasasDemo (github.com)
I modified the Rule, but it still runs three times
TheShy:
When I trigger an intention, it triggers an ACTION three times, causing it to run slowly. nlu:
- regex: user_input_name
examples: |
- (?<=查)[a-zA-Z0-9\u4e00-\u9fa5]{2,5}(?=的)
- intent: info_input_name
examples: |
- 请帮我查[张三](user_input_name)的性别
- 帮我查[张三](user_input_name)的性别
- 查[张三](user_input_name)的性别
- 我想查[张三](user_input_name)的性别
domain:
utter_output_name:
- text: "{user_input_name}的性别是{db_get_sex}"
slots:
# name:
# type: text
# mappings:
# - type: custom
# action: action_testName
user_input_name:
type: text
influence_conversation: false
mappings:
- type: from_entity
entity: user_input_name
db_get_sex:
type: text
mappings:
- type: custom
action: action_getSexByName
rules:
rules:
- rule: avtivate user_input_name form
steps:
- intent: info_input_name
- action: name_form
- action: action_getSexByName
- action: utter_output_name
Hello, It seems like you’re calling action_getSexByName
three times: once in slot mappings, then twice in your rule. To prevent the action from running multiple times, remove it from slot mappings and the rule, and only call it once within the name_form
using the FormAction
class, which will execute it in a controlled manner.
TheShy
(shy)
June 8, 2023, 1:00am
9
Sorry, I tried deleting rules and slots. Action does only run once, but the first time Action cannot obtain the value of slot. I don’t know how to use FormAction, detailed operation not found in the document
This is my project file:GitHub
TheShy
(shy)
June 8, 2023, 2:53am
10
I couldn’t find FormAction in rasa_sdk.form