Hi Tom, I’m trying to run a specific NLU server based on the language slot in the tracker.
I understand that since all of Rasa code is in async mode, you can’t just call an async function any more. 2 methods are given to invoke an async function–“await” and loop.run_until_complete().
I tried the following:
asyncio.run() that you see below, but nothing works. It looks like _pick_interpreter is not getting hit and I never get a the print statement in my output and the code just hangs. Am I missing something basic?
async def _pick_interpreter(self, tracker):
language = tracker.get_slot('language')
if language == 'english' :
current_interpeteter = self.interpreter
elif language == 'spanish' :
current_interpreter = self.interpreter2
else:
current_interpeteter = self.interpreter
print('current interpreter is', current_interpreter)
return current_interpreter
async def _parse_message(self, message):
# for testing - you can short-cut the NLU part with a message
# in the format /intent{"entity1": val1, "entity2": val2}
# parse_data is a dict of intent & entities
print('reached here"')
current_interpreter = asyncio.run(_pick_interpreter(tracker))
'''loop = asyncio.get_event_loop()
current_interpreter = loop.run_until_complete(self._pick_interpreter(tracker))
#print('passed pick_interpreter')
loop.close()'''
Do you have to unzip your models and reference the files directly in agent then? What’s the point of a model server if you need to load the files directly into the agent?