HTTP API --enable_api ( and Questions about the training run flow )

HI All, My goal is use the API with my first bot

I am using

python -m rasa_core.run     --enable_api    -d models/dialogue    -u models/nlu/current    -o out.log

But I receive this error:

usage: run.py [-h] -d CORE [-u NLU] [-p PORT] [-o LOG_FILE]
              [--credentials CREDENTIALS]
              [-c {facebook,slack,telegram,mattermost,cmdline,twilio}]
              [--debug] [-v]
run.py: error: unrecognized arguments: --enable_api

Reference of documentation I am using:

Thank you

Update: [NOT SOLVED] but I found a precedent discussion that said that API is removed and suggest to use RestInput channel instead.

Reference:

Which version are you using?

Hi souvikg10!

This is my setup:

rasa_nlu: 0.12.3 
rasa_core: 0.9.6
python: 3.6.3

Thanks

@linediconsine hi so the rasa core version you are using has a different way to setup endpoint. It uses

pythom -m rasa_core.server…something like this! Upgrade to newer version of core then you’ll be able to run --enable_api. Or you can simply search for rasa_core: 0.9.6 version docs if you don’t want to upgrade.

1 Like

Word!!

1 Like

hey @souvikg10 Please can you take a look at my topic!

Thanks in Advance

Eih @Akshit, This is not very polite, I still didn’t solve my problems and you are spamming with this messages…

Let make this forum a happy open source community!

Thanks

hey @linediconsine sorry If you got upset, I gave you a solution. Did you try that?

Hi Akshit, Thanks , I moved a bit forward to understand the setup flow thanks to you!

Long story short : After a couple of test I upgraded the core model and the NLU model

Now let me share my flow from training to run the model:

Now I am using

rasa_nlu: 0.13.8 
rasa_core: 0.13.0a5

On Osx

Trianing NLU

For training NLU I used:

from rasa_nlu.training_data import load_data
from rasa_nlu.config import RasaNLUModelConfig
from rasa_nlu.model import Trainer
from rasa_nlu import config

# loading the nlu training samples
training_data = load_data("NLU/nlu.json")

# trainer to educate our pipeline
trainer = Trainer(config.load("NLU/config.yml"))

# train the model!
interpreter = trainer.train(training_data)

# store it for future use
model_directory = trainer.persist("./models/nlu", 
                                  fixed_model_name="current")

Confusion matrix

06%20AM

Question 1: The confusion matrix is not great ( how I can improve it ?)

Now is time to train the core model, I use:

from rasa_core.policies import FallbackPolicy, KerasPolicy, MemoizationPolicy
from rasa_core.agent import Agent

# this will catch predictions the model isn't very certain about
# there is a threshold for the NLU predictions as well as the action predictions


agent = Agent('domain.yml', policies=[MemoizationPolicy(), KerasPolicy()])

# loading our neatly defined training dialogues
training_data = agent.load_data('stories/stories.md')

agent.train(
    training_data,
    validation_split=1.0
)

agent.persist('models/dialogue')

2. Run core and NLU model

From console something weird happens ( I cannot see any reply from my bot ) and I have a couples of warning about some pythons libraries :

$ python -m rasa_core.run -d models/dialogue -u ./models/nlu/default/current/

python -m rasa_core.run --enable_api -d models/dialogue -u ./models/nlu/default/current/ -o out.log

API mode is running with :

 python -m rasa_core.run --enable_api -d models/dialogue -u ./models/nlu/default/current/ -o out.log

25%20AM

python -m rasa_core.run -d models/dialogue -u models/current/nlu --port 5002 --credentials credentials0.yml

with insider credentials0.yml

  rest:
  # you don't need to provide anything here - this channel doesn't
  # require any credentials

The server is running, question: Somebody has created a postman ( a list of example of possible call Rasa code accept… I think I might be fighting with old ones example:

curl -XPOST http://localhost:5002/webhooks/myio/webhook   -d '{"sender": "user1", "message": "hello"}' -H "Content-type: application/json"

Is NOT working in my test, I receive 500

Thanks you for any help!

Hey! @linediconsine This should be

localhost:5005/conversations/default/respond?q=hello

Default can be anything as it’s just the user_id

Hey @linediconsine according to this doc

you url should be like : http://localhost:5002/webhooks/rest/webhook body parameters : { “sender”: “user1”, “message”: “Hello” }

hope that helps

hey @Akshit according to this doc https://rasa.com/docs/core/server/#operation/respond the url which you specified is deprecated :sweat_smile:

yeah actually for the first question he used this HTTP api after that he used the REST api… I only answered for the http api call. I know it’s deprecated but it’s working for some time! :slight_smile: It’s just for learning purpose only