Fix error if a custom_sentences file is empty (#93530)

* Fix #93528

* Log warning file is invalid

* More explicit log warning message

* Rewrite log message
This commit is contained in:
Tudor Sandu 2023-05-31 02:53:52 +03:00 committed by GitHub
parent d7d9143a44
commit fe472e6c5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -413,9 +413,18 @@ class DefaultAgent(AbstractConversationAgent):
encoding="utf-8"
) as custom_sentences_file:
# Merge custom sentences
merge_dict(
intents_dict, yaml.safe_load(custom_sentences_file)
)
if isinstance(
custom_sentences_yaml := yaml.safe_load(
custom_sentences_file
),
dict,
):
merge_dict(intents_dict, custom_sentences_yaml)
else:
_LOGGER.warning(
"Custom sentences file does not match expected format path=%s",
custom_sentences_file.name,
)
# Will need to recreate graph
intents_changed = True