-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11433 from RasaHQ/bugfix-session-config-follow-up
Follow-up bugfix to merging separate domain files with custom session config
- Loading branch information
Showing
8 changed files
with
245 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This fix makes sure that when a Domain object is loaded from multiple files where one file specifies a custom session config and the rest do not, the default session configuration does not override the custom session config. |
39 changes: 39 additions & 0 deletions
39
...est_domains/test_domain_files_with_no_session_config_and_custom_session_config/config.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
recipe: default.v1 | ||
language: en | ||
pipeline: [] | ||
# # No configuration for the NLU pipeline was provided. The following default pipeline was used to train your model. | ||
# # If you'd like to customize it, uncomment and adjust the pipeline. | ||
# # See https://rasa.com/docs/rasa/tuning-your-model for more information. | ||
# - name: WhitespaceTokenizer | ||
# - name: RegexFeaturizer | ||
# - name: LexicalSyntacticFeaturizer | ||
# - name: CountVectorsFeaturizer | ||
# - name: CountVectorsFeaturizer | ||
# analyzer: char_wb | ||
# min_ngram: 1 | ||
# max_ngram: 4 | ||
# - name: DIETClassifier | ||
# epochs: 100 | ||
# constrain_similarities: true | ||
# - name: EntitySynonymMapper | ||
# - name: ResponseSelector | ||
# epochs: 100 | ||
# constrain_similarities: true | ||
# - name: FallbackClassifier | ||
# threshold: 0.3 | ||
# ambiguity_threshold: 0.1 | ||
|
||
data: | ||
policies: | ||
# # No configuration for policies was provided. The following default policies were used to train your model. | ||
# # If you'd like to customize them, uncomment and adjust the policies. | ||
# # See https://rasa.com/docs/rasa/policies for more information. | ||
# - name: MemoizationPolicy | ||
# - name: RulePolicy | ||
# - name: UnexpecTEDIntentPolicy | ||
# max_history: 5 | ||
# epochs: 100 | ||
# - name: TEDPolicy | ||
# max_history: 5 | ||
# epochs: 100 | ||
# constrain_similarities: true |
91 changes: 91 additions & 0 deletions
91
...t_domains/test_domain_files_with_no_session_config_and_custom_session_config/data/nlu.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
version: "3.1" | ||
|
||
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 | ||
- intent: goodbye | ||
examples: | | ||
- 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 | ||
- intent: deny | ||
examples: | | ||
- no | ||
- n | ||
- never | ||
- I don't think so | ||
- don't like that | ||
- no way | ||
- not really | ||
- 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: bot_challenge | ||
examples: | | ||
- are you a bot? | ||
- are you a human? | ||
- am I talking to a bot? | ||
- am I talking to a human? |
6 changes: 6 additions & 0 deletions
6
...ins/test_domain_files_with_no_session_config_and_custom_session_config/data/responses.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
version: "3.1" | ||
|
||
|
||
responses: | ||
utter_test: | ||
- text: "Hey! How are you?" |
30 changes: 30 additions & 0 deletions
30
...mains/test_domain_files_with_no_session_config_and_custom_session_config/data/stories.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
version: "3.1" | ||
|
||
stories: | ||
|
||
- story: happy path | ||
steps: | ||
- intent: greet | ||
- action: utter_greet | ||
- intent: mood_great | ||
- action: utter_happy | ||
|
||
- story: sad path 1 | ||
steps: | ||
- intent: greet | ||
- action: utter_greet | ||
- intent: mood_unhappy | ||
- action: utter_cheer_up | ||
- action: utter_did_that_help | ||
- intent: affirm | ||
- action: utter_happy | ||
|
||
- story: sad path 2 | ||
steps: | ||
- intent: greet | ||
- action: utter_greet | ||
- intent: mood_unhappy | ||
- action: utter_cheer_up | ||
- action: utter_did_that_help | ||
- intent: deny | ||
- action: utter_goodbye |
34 changes: 34 additions & 0 deletions
34
...est_domains/test_domain_files_with_no_session_config_and_custom_session_config/domain.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
version: "3.1" | ||
|
||
intents: | ||
- greet | ||
- goodbye | ||
- affirm | ||
- deny | ||
- mood_great | ||
- mood_unhappy | ||
- bot_challenge | ||
|
||
responses: | ||
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." | ||
|
||
session_config: | ||
session_expiration_time: 0 | ||
carry_over_slots_to_new_session: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...ions/test_domain_merge_multiple_files_with_custom_session_config_and_no_session_config.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from rasa.shared.core.domain import SessionConfig | ||
from rasa.shared.importers.importer import TrainingDataImporter | ||
|
||
|
||
def test_merge_domain_with_custom_session_config_and_no_session_config(): | ||
expected_session_expiration_time = 0 | ||
expected_carry_over_slots = False | ||
|
||
config_path = ( | ||
"data/test_domains/" | ||
"test_domain_files_with_no_session_config_and_custom_session_config/config.yml" | ||
) | ||
domain_path = ( | ||
"data/test_domains/" | ||
"test_domain_files_with_no_session_config_and_custom_session_config/domain.yml" | ||
) | ||
training_data_paths = [ | ||
"data/test_domains/" | ||
"test_domain_files_with_no_session_config_and_custom_session_config/data" | ||
] | ||
file_importer = TrainingDataImporter.load_from_config( | ||
config_path, domain_path, training_data_paths | ||
) | ||
|
||
domain = file_importer.get_domain() | ||
|
||
assert ( | ||
domain.session_config.session_expiration_time | ||
!= SessionConfig.default().session_expiration_time | ||
) | ||
assert ( | ||
domain.session_config.carry_over_slots | ||
!= SessionConfig.default().carry_over_slots | ||
) | ||
|
||
assert ( | ||
domain.session_config.session_expiration_time | ||
== expected_session_expiration_time | ||
) | ||
assert domain.session_config.carry_over_slots == expected_carry_over_slots |