Skip to content

Commit

Permalink
Remove neon.languages.get handler
Browse files Browse the repository at this point in the history
Allow passing a MessageBusClient to init
  • Loading branch information
NeonDaniel committed Nov 28, 2023
1 parent 27ad338 commit d34ce90
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions neon_messagebus_mq_connector/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ class ChatAPIProxy(MQConnector):
Proxy module for establishing connection between Neon Core and an MQ Broker
"""

def __init__(self, config: dict, service_name: str):
def __init__(self, config: dict, service_name: str,
bus: MessageBusClient = None):
config = config or Configuration()
mq_config = config.get("MQ", config)
super().__init__(mq_config, service_name)
Expand All @@ -61,7 +62,7 @@ def __init__(self, config: dict, service_name: str):
"1.0.0")
self.bus_config = config.get("MESSAGEBUS")
self._vhost = '/neon_chat_api'
self._bus = None
self._bus = bus
self.connect_bus()
self.register_consumer(name=f'neon_api_request_{self.service_id}',
vhost=self.vhost,
Expand All @@ -88,7 +89,6 @@ def register_bus_handlers(self):
self._bus.on('complete.intent.failure', self.handle_neon_message)
self._bus.on('intent_aborted', self.handle_neon_message)
self._bus.on('neon.profile_update', self.handle_neon_profile_update)
self._bus.on('neon.languages.get', self.handle_get_languages)
self._bus.on('neon.clear_data', self.handle_neon_message)
self._bus.on('neon.audio_input.response', self.handle_neon_message)
self._bus.on('neon.get_tts.response', self.handle_neon_message)
Expand Down Expand Up @@ -182,18 +182,6 @@ def handle_neon_profile_update(self, message: Message):
LOG.debug(f"ignoring profile update for "
f"user={message.data['profile']['user']['username']}")

def handle_get_languages(self, message: Message):
"""
Handle a request to get languages supported by Neon Core.
@param message: neon.languages.get Message
"""
from neon_utils.language_utils import get_supported_languages
supported_langs = get_supported_languages()
self.bus.emit(message.response({"stt": list(supported_langs.stt),
"tts": list(supported_langs.tts),
"skills": list(supported_langs.skills)
}))

@staticmethod
def __validate_message_templates(
msg_data: dict,
Expand Down

0 comments on commit d34ce90

Please sign in to comment.