Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue Proxying Rasa Parse #51

Closed
btotharye opened this issue Mar 27, 2018 · 16 comments
Closed

Issue Proxying Rasa Parse #51

btotharye opened this issue Mar 27, 2018 · 16 comments

Comments

@btotharye
Copy link
Contributor

So I setup the docker instance and modified the rasanluendpoint to include my address where my Rasa instance is.

So then I sent the following command to the Rasa UI to parse hoping it would go to that system but I'm getting a auth error and not sure what the payload expects:

http://192.168.99.100:5001/api/v2/rasa/parse - the URL I used
params = {"q": question, "project": "chatbot"} - the payload and question is just a simple hello.

The error I get is:

{'message': 'No Authorization header.', 'success': False}

So what is the right format for this call?

Thanks

@paschmann
Copy link
Owner

Hi @btotharye - could you check this: https://github.com/paschmann/rasa-ui/wiki/Using-Rasa-UI-as-Middleware and see if it solves your problem?

@btotharye
Copy link
Contributor Author

Sure also is what I'm doing the right process to have this interact with a external Rasa server I already have setup? Sorry didn't know about that in the wiki I'll check it out.

Thanks

@paschmann
Copy link
Owner

Yes, what you are doing is correct. Are you able to use the Rasa UI? Are you able to use the sidebar chat dialog to interact with the Rasa NLU backend successfully?

@jr4c
Copy link

jr4c commented Mar 27, 2018

hey @btotharye i know that this is another question, but, can you share the coe that you use to change the rasanluendpioint and how you run the dockerfile (i have been trying doing this too)

@btotharye
Copy link
Contributor Author

@rafaelariad I just basically modified https://github.com/paschmann/rasa-ui/blob/master/Dockerfile#L47 to include my rasa server address then did docker build -t rasa-ui . to build it and docker run -itd -p 5001:5001 rasa-ui to spin it up

@btotharye
Copy link
Contributor Author

btotharye commented Mar 27, 2018

@paschmann just to make sure should the payload look like this after I have my token:

url = "http://192.168.99.100:5001/api/v2/rasa/parse"
question = 'hello'
headers = {
    'Accept': 'application/json',
    'Authorization': 'Bearer {}'.format(token)
    }
params = {"q": question, "project": "chatbot"}
r = requests.get(url, headers=headers, params=params)

This is how I do my other api calls but I'm still getting cannot get /api/v2/rasa/parse as the error atm. I can definitely see the redirect is happening cause I see the requests coming into my Rasa server.

@paschmann
Copy link
Owner

paschmann commented Mar 27, 2018

@btotharye - the method should be a POST, something like this:

var request = require("request");

var options = { method: 'POST',
  url: 'http://localhost:5001/api/v2/rasa/parse',
  headers: 
   { 'Postman-Token': 'fc7b3022-70c4-bdf8-5eff-425c0d7b55b1',
     'Cache-Control': 'no-cache',
     Authorization: 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1MjA0Nzk3NjJ9.nSCzx1V-bS_S77G8uICZgFJub_5q4sukByiq6f_sgY4',
     'Content-Type': 'application/json' },
  body: 
   { q: 'resturants in new york',
     project: 'Dining Out',
     model: 'model_20180307-131724' },
  json: true };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});

@btotharye
Copy link
Contributor Author

Ok sorry getting closer what does this mean?

{'message': {'data': {'type': 'undefined'},
  'errorcode': 'EKEYTYPE',
  'message': 'The key argument has to be of type `string` or `number`. Found: `undefined`',
  'name': 'EKEYTYPE'},
 'status': 'error'}

I wasn't sure if I had to send it the actual model or if just the project is enough and in this case the project is the Project in Rasa UI or my project in my Rasa server?

@paschmann
Copy link
Owner

I am not entirely sure to be honest - not a very descriptive error ...

You would need to send the project name on the Rasa Server.

@btotharye
Copy link
Contributor Author

interesting thats what I'm doing but its failing I tried inside postman and this is the response back:

{
    "status": "error",
    "message": {
        "expose": true,
        "statusCode": 400,
        "status": 400,
        "body": "{ q: 'hello',\r\nproject: 'Cisco Chatbot',\r\nmodel: 'chatbot*model_20180326-185644' },\r\njson: true };",
        "type": "entity.parse.failed"
    }
}

I'll have to keep messing around to figure out what is up

@paschmann
Copy link
Owner

Could you check if you have a Agent in Rasa UI called "Cisco Chatbot"?

@paschmann
Copy link
Owner

Lets also move the conversation here: https://gitter.im/rasa-ui/Lobby

@btotharye
Copy link
Contributor Author

I created it manually wasn't sure if that had to be there or not, I already have on my rasa server a model trained called chatbot which is what I'm trying to proxy this stuff to. All I did so far was modify the https://github.com/paschmann/rasa-ui/blob/master/Dockerfile#L47 to be my ip address of my rasa server and spun it up, wasn't sure if there were other steps required or not.

@pradeepmvn
Copy link
Collaborator

@btotharye Rasa UI needs to have Agent information in its database. There is logging and webhook information tied to an agent that gets pulled for every request. There are multiple ways you can get to it

  • Either manually create an agent and start adding intents, entities, utterance details.
  • or by uploading an existing rasa_nlu domain data in JSON format

The later one would be more suitable in your case since you already have domain data from nlu. Also remember that Project name in NLU servers should be same as the Agent name in Rasa-ui.

@btotharye
Copy link
Contributor Author

I was working with @paschmann on this in gitter it actually appears to be an issue with https://github.com/paschmann/rasa-ui/blob/master/server/routes/middleware.js#L43 through 45 because once I commented that out everything started working the way it should with my remote NLU server I already have setup.

I'm gonna work on it a bit and see if I can see what is causing all the issues.

@btotharye
Copy link
Contributor Author

actually it wasn't a bug after all in those lines I just tested now and its working I think part of it was how I was issuing the output so for documentation purposes this is how I have it working:

url = "http://192.168.99.100:5001/api/v2/rasa/parse"
question = "hello"
payload = "q={}&project=chatbot".format(question)
headers = {
    'Content-Type': 'application/x-www-form-urlencoded',
    'Authorization': 'Bearer {}'.format(token)
    }
r = requests.post(url, data=payload, headers=headers)
response.json()

which now works properly and proxies to my Rasa server and gives me back the results:

{'entities': [{'confidence': 0.7423392842897176,
   'end': 5,
   'entity': 'serial',
   'extractor': 'ner_crf',
   'start': 0,
   'value': 'hello'}],
 'intent': {'confidence': 0.5612418049086964, 'name': 'greet'},
 'intent_ranking': [{'confidence': 0.5612418049086964, 'name': 'greet'},
  {'confidence': 0.12778262542564556, 'name': 'goodbye'},
  {'confidence': 0.12426149548459074, 'name': 'affirm'},
  {'confidence': 0.06779630706788278, 'name': 'cisco_serial'},
  {'confidence': 0.06100715539325644, 'name': 'about'},
  {'confidence': 0.05791061171992811, 'name': 'help'}],
 'text': 'hello'}

So sorry for the issue seems it was just how I was making the call and I didn't realize the project needed to be equal to my agent name.

Thanks again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants