Skip to content

Commit

Permalink
Language handling fixes and logging updates (#572)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel McKnight <[email protected]>
  • Loading branch information
NeonDaniel and NeonDaniel authored Nov 9, 2023
1 parent cc59444 commit c639a83
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions neon_core/configuration/neon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ system_unit: metric
time_format: half
date_format: MDY
lang: en-us
secondary_langs: [en-us, uk-ua]
location:
city:
code: Lawrence
Expand Down
9 changes: 9 additions & 0 deletions neon_core/skills/intent_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ def __init__(self, bus: MessageBusClient):
self.converse = NeonConverseService(bus)
self.config = Configuration()
self.language_config = get_lang_config()
LOG.debug(f"Languages Adapt={self.adapt_service.engines.keys()}|"
f"Padatious={self.padatious_service.containers.keys()}")

# Initialize default user to inject into incoming messages
try:
Expand Down Expand Up @@ -154,6 +156,7 @@ def _get_parsers_service_context(self, message: Message, lang: str):
"""
utterances = message.data.get('utterances', [])
message.context["lang"] = lang
LOG.debug(f"lang={lang}|utterances={utterances}")
utterances, message.context = \
self.transformers.transform(utterances, message.context)
message.data["utterances"] = utterances
Expand All @@ -172,9 +175,15 @@ def handle_utterance(self, message):
self.bus.emit(message.response())

try:
requested_lang = message.data.get('lang')
# Get language of the utterance
lang = get_full_lang_code(
message.data.get('lang') or self.language_config["user"])
if requested_lang and \
requested_lang.split('-')[0] != lang.split('-')[0]:
lang = get_full_lang_code(requested_lang.split('-')[0])
LOG.warning(f"requested={requested_lang}|resolved={lang}")

message.data["lang"] = lang
LOG.debug(f"message_lang={lang}")
# Add or init timing data
Expand Down
2 changes: 1 addition & 1 deletion requirements/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ mock~=5.0

# default plugins
neon-lang-plugin-libretranslate~=0.2
neon-utterance-translator-plugin~=0.1
neon-utterance-translator-plugin~=0.1,>=0.1.2a0
neon-utterance-normalizer-plugin~=0.0.2

# TODO: Patching test failures https://github.com/NeonGeckoCom/NeonCore/actions/runs/4888865255/jobs/8727164992?pr=422
Expand Down
4 changes: 2 additions & 2 deletions requirements/skills_essential.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
neon-skill-about~=1.0
neon-skill-date_time~=1.0,>=1.0.1a2
neon-skill-demo~=1.0,>=1.0.1a1
neon-skill-device_controls~=1.0
neon-skill-ip_address~=1.0
neon-skill-device_controls~=1.0,>=1.0.1a2
neon-skill-ip_address~=1.0,>=1.0.1a3

0 comments on commit c639a83

Please sign in to comment.