Training rasa using http Api endpoint

Hi Guys! i’m trying to use the api endpoint /model/train to train rasa using the below command

curl -X POST \
  http://localhost:5005/model/train \
  -H 'Accept-Encoding: gzip, deflate' \
  -H 'Content-Type: application/json' \
  -d '{
"config": "language: en\npipeline:\n - name: WhitespaceTokenizer\n - name: RegexFeaturizer\n - name: CRFEntityExtractor\n - name: EntitySynonymMapper\n - name:\ CountVectorsFeaturizer\n - name: EmbeddingIntentClassifier\npolicies:\n - name: MemoizationPolicy\n - name: KerasPolicy\n - name: MappingPolicy\n - name: FormPolicy\n",\
"nlu": "## intent:new_intent_to_train_on\n - new_utter_to_train_on for new_entity_to_train_on_value\n - new_utter_to_train_on for new_entity_to_train_on_value\n##\ intent:greet\n - hey\n - hello\n## intent:goodbye\n - cu\n - goodbye\n## intent:mood_great\n - Great!!\n - happy\n## intent:mood_unhappy\n - sad\n - Terrible",\
"stories": "##new_intent_to_train_on Path from model train without utter_slot_values\n* greet\n - utter_greet\n* new_intent_to_train_on\n -\ new_intent_to_train_on_form\n - form{\"name\": \"new_intent_to_train_on_form\"}\n - form{\"name\": null}\n\n## happy path\n * greet\n - utter_greet\n* mood_great\n -\ utter_happy\n\n## sad path 1\n * greet\n - utter_greet\n* mood_unhappy\n - utter_cheer_up\n",\
"domain": "entities:\n - new_entity_to_train_on\nintents:\n - new_intent_to_train_on\n - greet\n - goodbye\n - affirm\n - deny\n - mood_great\n -\ mood_unhappy\n\nactions:\n - utter_slots_values\n - utter_greet\n - utter_cheer_up\n - utter_did_that_help\n - utter_happy\n - utter_goodbye\ntemplates:\n\ utter_slots_values:\n - text: new_utter_output_to_send:\n\n- new_entity_to_train_message_values : {new_entity_to_train_on}\n\n\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:\\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\n\nforms:\n - new_intent_to_train_on_form\nslots:\n new_entity_to_train_on:\n type:\ unfeaturized\n auto_fill: false",\
"out": "models",\
"force": true\

I started rasa as an http server in one of the terminal before this using rasa run -m models --enable-api --cors “*” --debug.

The above data is just for testing and i have all the files including domain.yml file.

But i’m getting this warnings

/rasaaa/lib/python3.7/site-packages/rasa/utils/ UserWarning: Loading domain from ‘/tmp/tmp1ns5z1bz/domain.yml’ failed. Using empty domain. Error: ‘The provided yaml file is invalid. You can use to validate the yaml syntax of your file.’

Core training was skipped because no valid domain file was found. Only an nlu-model was created.Please specify a valid domain using ‘–domain’ argument or check if the provided domain file exists.

Am i making some mistake? How can i train rasa using curl ? also is there any way i can directly add a new intent using any api endpoint? I’m using rasa 1.10.3.

Thanks in advance.

I did get this working in Python, but a cursory look gives this (I took you domain element and replaced \n with (in vi):

“domain”: "entities:

  • new_entity_to_train_on intents:
  • new_intent_to_train_on
  • greet
  • goodbye
  • affirm
  • deny
  • mood_great -\ mood_unhappy actions:
  • utter_slots_values
  • utter_greet
  • utter_cheer_up
  • utter_did_that_help
  • utter_happy
  • utter_goodbye templates: \ utter_slots_values:
  • text: new_utter_output_to_send:
  • new_entity_to_train_message_values : {new_entity_to_train_on} utter_greet:
  • text: Hey! How are\ you? utter_cheer_up:
  • text: Here is something to cheer you up: image:
  • text: Did that help\ you? utter_happy:
  • text: Great carry on! utter_goodbye:
  • text: Bye forms:
  • new_intent_to_train_on_form slots: new_entity_to_train_on: type:\ unfeaturized auto_fill: false",\

it appears to have several typos ?

I took the domain I wanted and then simply replaced with \n to get a single line (string).

I was thinking about this a while back and it would be nice to have a POJO (DAO type) object to use when building these to make sure it comes out syntactically correct when using API calls (granted I was using Python to make the call).

Other than the typos I see it should work as you are making the call the same way I am (headers/etc).


Hi Jason , Thanks for replying . I didn’t actually get what you modified to make it working .can you do some modification in the command i ran above to make me understand? Yes there may be many typos as I’m just trying to train model this way and just testing it with some random input.

this should work: (it is the base rasa init model), use the following as a single line. [HINT: spacing matters tremendously and you have to double the single quotes inside a string (double quotes)]

curl -X POST ‘http://localhost:5005/model/train’ -H ‘Accept-Encoding: gzip, deflate’ -H ‘Content-Type: application/json’ -d ‘{ “config”: “language: en\npipeline:\n - name: WhitespaceTokenizer\n - name: RegexFeaturizer\n - name: LexicalSyntacticFeaturizer\n - name: CountVectorsFeaturizer\n - name: CountVectorsFeaturizer\n analyzer: “char_wb”\n min_ngram: 1\n max_ngram: 4\n - name: DIETClassifier\n epochs: 100\n - name: EntitySynonymMapper\n - name: ResponseSelector\n epochs: 100\npolicies:\n - name: MemoizationPolicy\n - name: TEDPolicy\n max_history: 1\n epochs: 100\n - name: MappingPolicy\n\n”, “nlu”: "## intent:greet\n- hey\n- hello\n- hi\n- good morning\n- good evening\n- hey there\n\n## intent:goodbye\n- bye\n- goodbye\n- see you around\n- see you later\n\n## intent:affirm\n- yes\n- indeed\n- of course\n- that sounds good\n- correct\n\n## intent:deny\n- no\n- never\n- I don’‘t think so\n- don’‘t like that\n- no way\n- not really\n\n## intent:mood_great\n- perfect\n- very good\n- great\n- amazing\n- wonderful\n- I am feeling very good\n- I am great\n- I’‘m good\n\n## intent:mood_unhappy\n- sad\n- very sad\n- unhappy\n- bad\n- very bad\n- awful\n- terrible\n- not very good\n- extremely sad\n- so sad\n\n## intent:bot_challenge\n- are you a bot?\n- are you a human?\n- am I talking to a bot?\n- am I talking to a human?\n", “stories”: “## happy path\n* greet\n - utter_greet\n* mood_great\n - utter_happy\n\n## sad path 1\n* greet\n - utter_greet\n* mood_unhappy\n - utter_cheer_up\n - utter_did_that_help\n* affirm\n - utter_happy\n\n## sad path 2\n* greet\n - utter_greet\n* mood_unhappy\n - utter_cheer_up\n - utter_did_that_help\n* deny\n - utter_goodbye\n\n## say goodbye\n* goodbye\n - utter_goodbye\n\n## bot challenge\n* bot_challenge\n - utter_iamabot\n”, “domain”: “intents:\n - greet\n - goodbye\n - affirm\n - deny\n - mood_great\n - mood_unhappy\n - bot_challenge\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: “”\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”\n\n utter_iamabot:\n - text: “I am a bot, powered by Rasa.”\n\nsession_config:\n session_expiration_time: 60\n carry_over_slots_to_new_session: true\n”, “out”: “models”, “force”: true }’

1 Like

Hi ! I was wondering if we can give the path of the files in .md/.json/.yml format instead of giving the data in the format discussed above as plain string. is that possible?

Thanks in advance.