# Help me on deprecated code

**URL:** <https://forum.rasa.com/t/help-me-on-deprecated-code/37932>\
**Category:** Rasa Open Source\
**Created:** [December 11, 2020, 11:25am UTC](https://forum.rasa.com/t/help-me-on-deprecated-code/37932 "2020-12-11T11:25:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeruji](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/jeruji/32/12355_2.png) [@jeruji](https://forum.rasa.com/u/jeruji)\
**Post date:** [December 11, 2020, 11:25am UTC](https://forum.rasa.com/t/help-me-on-deprecated-code/37932/1 "2020-12-11T11:25:37Z")

</div>

I read a book with title " Building Chatbots with Python: Using Natural Language Processing and Machine Learning" by Sumit Raj and follow the code that written there. And then I came to an example code how to train online the conversation, but then I found out that the code is deprecated. This is the code :

```
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import logging
from rasa_core import utils, train
from rasa_core.training import online
from rasa_core.interpreter import NaturalLanguageInterpreter
logger = logging.getLogger( __name__ )
def train_agent(interpreter):
    return train.train_dialog_model(domain_file="horoscope_domain.yml",
    stories_file="data/stories.md", output_path="models/dialog", nlu_model_path=interpreter, 
    endpoints="endpoints.yml", max_history=2, kwargs={"batch_size": 50,"epochs": 200, 
    "max_training_samples": 300 })

if __name__ == ' __main__': 
    utils.configure_colored_logging(loglevel="DEBUG") 
    nlu_model_path = "./models/nlu/default/horoscopebot" interpreter = 
    NaturalLanguageInterpreter.create(nlu_model_path) agent = train_agent(interpreter)
    online.serve_agent(agent)

```

then the result is “ImportError: cannot import name ‘online’ from ‘rasa\_core.training’” . Please help me how the code looks like in the newest version. When i check i use rasa nlu 0.15.1 version.

Many thanks for your help.

---

<div class="post-metadata">

**Author:** ![marcos.allysson](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/marcos.allysson/32/12107_2.png) [@marcos.allysson](https://forum.rasa.com/u/marcos.allysson)\
**Post date:** [December 12, 2020, 3:02am UTC](https://forum.rasa.com/t/help-me-on-deprecated-code/37932/2 "2020-12-12T03:02:09Z")

</div>

@jeruji, read the docs of [SDK actions](https://rasa.com/docs/action-server/sdk-actions) and you’ll write your code. Hope it helps 😃

---

<div class="post-metadata">

**Author:** ![jeruji](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/jeruji/32/12355_2.png) [@jeruji](https://forum.rasa.com/u/jeruji)\
**Post date:** [December 12, 2020, 3:38am UTC](https://forum.rasa.com/t/help-me-on-deprecated-code/37932/3 "2020-12-12T03:38:47Z")

</div>

I already have the actions and it works well. But when it comes to train the dialog\_model, the code is deprecated. Do you know how to use train\_dialog\_model in 0.15.1 version?

---

<div class="post-metadata">

**Author:** ![marcos.allysson](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/marcos.allysson/32/12107_2.png) [@marcos.allysson](https://forum.rasa.com/u/marcos.allysson)\
**Post date:** [December 12, 2020, 7:46pm UTC](https://forum.rasa.com/t/help-me-on-deprecated-code/37932/4 "2020-12-12T19:46:47Z")

</div>

> [@jeruji](#):
>
> train\_dialog\_model in 0.15.1 version

you can try this command:

```auto
python -m rasa_core.train -d domain.yml -s data/stories.md \
  -o models/current/dialogue -c config.yml 

```

where do I find it? That was similar question [on StackOverflow](https://stackoverflow.com/questions/58684197/rasa-nlu-model-unsupportedmodelerror-the-model-version-is-to-old-to-be-loaded-b), in case you want to check too.
