JC23
JC23

Reputation: 1328

Unable to train rasa with json data - InvalidUsage: Failed when parsing body as json

I want to repeatedly train rasa from an API so it provides more customized responses. The same json data is below & I tried to follow the format in the docs found here

test_json = {
"rasa_nlu_data": {
    "common_examples": [{
            "intent": "sad",
            "text": "I am not happy with the service"
        },
        {
            "intent": "praise",
            "text": "You're a genius"
        }
    ],
    "regex_features": [],
    "lookup_tables": [],
    "entity_synonyms": []
}
}

I start rasa like this rasa run -m models --enable-api --cor‘*’ --debug.

Then I try to post the json to the training endpoint like so

r2 = requests.post('http://localhost:5005/model/train', data=test_json)

A screenshot of the terminal

enter image description here

Does anyone know why it's not taking the data? Is it not formatted correctly or am I missing something else?

Upvotes: 0

Views: 520

Answers (1)

Tyler Dunn
Tyler Dunn

Reputation: 96

I want to repeatedly train rasa from an API ... I start rasa like this rasa run -m models --enable-api --cor‘*’ --debug.

In order to use a model, you need to train it first. If you add a new training example, you need to retrain the model and then you can call rasa run to use it: https://rasa.com/docs/rasa/user-guide/configuring-http-api/#using-rasa-s-http-api

r2 = requests.post('http://localhost:5005/model/train', data=test_json)

The request body schema for that endpoint does not include data. Check out the docs for training a model: https://rasa.com/docs/rasa/api/http-api/#operation/trainModel

I also recommend checking out https://forum.rasa.com/

Upvotes: 1

Related Questions