RASA bots

from rasa_core.policies import FallbackPolicy, KerasPolicy, MemoizationPolicy

from rasa_core.agent import Agent

import asyncio

agent = Agent(‘domain.yml’, policies=[MemoizationPolicy(), KerasPolicy(epochs=200)])

loop = asyncio.get_event_loop()

training_data =loop.run_until_complete(agent.load_data(‘stories.md’))

agent.train(

training_data,

validation_split=0.0

)

agent.persist(‘models/dialogue’)

ERROR:

RuntimeError: This event loop is already running

Can you please format your question?

1 Like

Edited . Could be please suggest something to solve this?. I have tried all the suggestion .

  • At which point does this exception happen?
  • Is this the stack trace or you code?

please check this code and suggest me what things i need to change. Its not working in my jupyter notebook . The training phase

I have read many posts saying policy has been changed and when I updated policy then it was showing coroutines are not iterable then I used asyncio but then it was showing that this event loop is already running(see the first post) but I’m not able to solve this issue . Please suggest sample code or exact changes I need to do in this code.

rasa==1.1.7 rasa-sdk==1.1.0 python=3.6

RuntimeError Traceback (most recent call last) in 7 loop = asyncio.get_event_loop() 8 # loading our neatly defined training dialogues ----> 9 training_data = loop.run_until_complete(agent.load_data(‘stories.md’)) 10 11

/usr/lib/python3.6/asyncio/base_events.py in run_until_complete(self, future) 469 future.add_done_callback(_run_until_complete_cb) 470 try: –> 471 self.run_forever() 472 except: 473 if new_task and future.done() and not future.cancelled():

/usr/lib/python3.6/asyncio/base_events.py in run_forever(self) 423 self._check_closed() 424 if self.is_running(): –> 425 raise RuntimeError(‘This event loop is already running’) 426 if events._get_running_loop() is not None: 427 raise RuntimeError(

RuntimeError: This event loop is already running

Hi @ashish, are you running in a jupyter notebook? if so please follow the beginning instructions here to avoid the event loop problem

Yes , I am working in a jupyter notebook. from this instructions , I have to add only these lines .

import nest_asyncio

nest_asyncio.apply()

print(“Event loop ready.”)

Right? I am a beginner ,Anything I missed?

Well you have to pip install nest_asyncio in the environment before launching the notebook, or alternatively try to do it from within the notebook, i think ! pip install nest_asyncio should do it.