Rasa 2.0 - API /model/train doesn't work

I can’t get API /model/train endpoint working on Rasa 2.0. Even if I copy your example from Rasa Open Source Documentation I’m keep getting 500

Running a fresh Rasa 2.0 rasa init project

$ rasa --version
Rasa Version     : 2.0.0
Rasa SDK Version : 2.0.0
Rasa X Version   : None
Python Version   : 3.6.9 (default, Oct  8 2020, 12:12:24)
Operating System : Linux-4.15.0-66-generic-x86_64-with-Ubuntu-18.04-bionic
Python Path      : /usr/bin/python3

$ rasa run --enable-api

Request copied from docs

{
  "domain": "intents:\n  - greet\n  - goodbye\n  - affirm\n  - deny\n  - mood_great\n  - mood_unhappy\n\nresponses:\n  utter_greet:\n  - text: \"Hey! How are you?\"\n\n  utter_cheer_up:\n  - text: \"Here is something to cheer you up:\"\n    image: \"https://i.imgur.com/nGF1K8f.jpg\"\n\n  utter_did_that_help:\n  - text: \"Did that help you?\"\n\n  utter_happy:\n  - text: \"Great carry on!\"\n\n  utter_goodbye:\n  - text: \"Bye\"",
  "config": "language: en\npipeline: supervised_embeddings\npolicies:\n  - name: MemoizationPolicy\n  - name: TEDPolicy",
  "nlu": "- intent: greet\n  examples: |\n    - hey\n    - hello\n    - hi\n\n- intent: goodbye\n  examples: |\n    - bye\n    - goodbye\n    - have a nice day\n    - see you\n\n- intent: affirm\n  examples: |\n    - yes\n    - indeed\n\n- intent: deny\n  examples: |\n    - no\n    - never\n\n- intent: mood_great\n  examples: |\n    - perfect\n    - very good\n    - great\n\n- intent: mood_unhappy\n  examples: |\n    - sad\n    - not good\n    - unhappy",
  "responses": "chitchat/ask_name: - text: my name is Sara, Rasa's documentation bot! chitchat/ask_weather: - text: it's always sunny where I live",
  "stories": "- story: happy path\n  steps:\n  - intent: greet\n  - action: utter_greet\n  - intent: mood_great\n  - action: utter_happy\n\n- story: sad path 1\n  steps:\n  - intent: greet\n  - action: utter_greet\n  - intent: mood_unhappy\n  - action: utter_cheer_up\n  - action: utter_did_that_help\n  - intent: affirm\n  - action: utter_happy\n\n- story: sad path 2\n  steps:\n  - intent: greet\n  - action: utter_greet\n  - intent: mood_unhappy\n  - action: utter_cheer_up\n  - action: utter_did_that_help\n  - intent: deny\n  - action: utter_goodbye\n\n- story: say goodbye\n  steps:\n  - intent: goodbye\n  - action: utter_goodbye"
}

Response

{
    "version": "2.0.0",
    "status": "failure",
    "message": "Ran training, but it finished without a trained model.",
    "reason": "TrainingError",
    "details": {},
    "help": null,
    "code": 500
}

and this is in terminal

No training data given. Please provide stories and NLU data in order to train a Rasa model using the '--data' argument.
2020-10-15 09:40:20 ERROR    rasa.server  - Ran training, but it finished without a trained model.

What’s wrong please?

Hi @mbukovy, thanks for reporting this.

Can you try replacing nlu: and stories: with a single data: key that contains all of the training data together?

I have had the same issue. I am very new to Rasa. I do not understand how to combine nlu and stories with a data key. Appreciate a bit more detail. Thanks

@b-quachtran Well, that didn’t work :slight_smile:

{
    "version": "2.0.0",
    "status": "failure",
    "message": "To train a Rasa model you need to specify at least one type of training data. Add `nlu` and/or `stories` to the request.",
    "reason": "BadRequest",
    "details": {
        "parameters": [
            "nlu",
            "stories"
        ],
        "in": "body"
    },
    "help": null,
    "code": 400
}

@akelad @b-quachtran up ^ Please, this is a big issue preventing us to upgrade to Rasa 2.0

Hi @mbukovy, it appears our documentation is in need of an update to match the YAML spec.

You can use the /model/train endpoint with YAML by setting the request header’s Content-Type to application/x-yaml. Inside the request body, you’ll pass in a single YAML formatted string containing the configuration, domain definitions, and training data.

For example:

stories:
- story: My story
  steps:
  - intent: greet
  - action: utter_greet

rules:
- rule: My rule
  steps:
  - intent: greet
  - action: utter_greet

intents:
- greet

nlu:
- intent: greet
  examples: |
   - hi
   - hello
- intent: bye
  examples: |
   - goodbye
   - bye

responses:
  utter_greet:
  - text: Hi

language: en

polices:
   - name: RulePolicy

pipeline:
   - name: WhitespaceTokenizer
   - name: CountVectorsFeaturizer
   - name: DucklingHTTPExtractor
   - name: DIETClassifier
     epochs: 1

Thank you @b-quachtran it seems to be working well. And it’s even better then the old json request :slight_smile:

Keep up the great work!