From 083d78c185504abad09effb740d439fe9da45471 Mon Sep 17 00:00:00 2001 From: NeonKirill Date: Sat, 30 Mar 2024 21:54:00 +0100 Subject: [PATCH] Fixed resolving persona data --- neon_llm_core/utils/personas/provider.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/neon_llm_core/utils/personas/provider.py b/neon_llm_core/utils/personas/provider.py index aa81702..7c2f7e6 100644 --- a/neon_llm_core/utils/personas/provider.py +++ b/neon_llm_core/utils/personas/provider.py @@ -65,21 +65,22 @@ def personas(self): @personas.setter def personas(self, data): - now = int(time()) LOG.debug(f'Setting personas={data}') - if data and isinstance(data, list): - self._personas = data - self._persona_last_sync = now - self._persona_handlers_state.clean_up_personas(ignore_items=self._personas) - elif now - self._persona_last_sync > self.PERSONA_STATE_TTL: + if int(time()) - self._persona_last_sync > self.PERSONA_STATE_TTL: LOG.warning(f'Persona state TTL expired, resetting personas config') self._personas = [] self._persona_handlers_state.init_default_handlers() + else: + self._personas = data + self._persona_handlers_state.clean_up_personas(ignore_items=self._personas) def _fetch_persona_config(self): response = send_mq_request(vhost=LLM_VHOST, request_data={"service_name": self.service_name}, - target_queue=PersonasProvider.GET_CONFIGURED_PERSONAS_QUEUE) + target_queue=PersonasProvider.GET_CONFIGURED_PERSONAS_QUEUE, + timeout=60) + if 'items' in response: + self._persona_last_sync = int(time()) response_data = response.get('items', []) personas = [] for item in response_data: