Skip to content

Commit

Permalink
Fixed resolving persona data
Browse files Browse the repository at this point in the history
  • Loading branch information
kirgrim committed Mar 30, 2024
1 parent 9d4bdee commit 083d78c
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions neon_llm_core/utils/personas/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 083d78c

Please sign in to comment.