We need to use the /model/parse and /webhooks/rest/webhook endpoints in a scalable environment, so I deployed rasa-x using the official helm chart. I have seen that rasa-x provides conversation endpoints like /api/conversations/{conversation_id}/messages but how do I use NLU-only with rasa-x? (We need the same functionallity that /model/parse provides)
I have seen you can target the rasa API in rasa-x with /core and /core/model/parse exists. I was able to get the bearer token with /api/auth, which worked for the /api/conversations/{conversation_id}/messages endpoint, the /core/model/parse endpoint, however, gives me a code 500. Looking into the rasa-production pod’s logs:
[2020-04-03 10:01:05 +0000] [1] [ERROR] Exception occurred while handling uri: 'http://<some-ip>/model/parse'
Traceback (most recent call last):
File "/opt/venv/lib/python3.6/site-packages/sanic/app.py", line 976, in handle_request
response = await response
File "/opt/venv/lib/python3.6/site-packages/rasa/server.py", line 159, in decorated
request
File "/opt/venv/lib/python3.6/site-packages/sanic_jwt/authentication.py", line 486, in is_authenticated
is_valid, *_ = self._verify(request)
File "/opt/venv/lib/python3.6/site-packages/sanic_jwt/authentication.py", line 348, in _verify
payload = self._decode(token, verify=verify)
File "/opt/venv/lib/python3.6/site-packages/sanic_jwt/authentication.py", line 172, in _decode
**kwargs
File "/opt/venv/lib/python3.6/site-packages/jwt/api_jwt.py", line 92, in decode
jwt, key=key, algorithms=algorithms, options=options, **kwargs
File "/opt/venv/lib/python3.6/site-packages/jwt/api_jws.py", line 156, in decode
key, algorithms)
File "/opt/venv/lib/python3.6/site-packages/jwt/api_jws.py", line 216, in _verify_signature
raise InvalidAlgorithmError('The specified alg value is not allowed')
jwt.exceptions.InvalidAlgorithmError: The specified alg value is not allowed
So I tried to use the jw-token authentication described as here:
with:
import jwt
import requests
body = {
"message": "Hi"
}
payload = {"user": {"username": "me", "role": "admin",}}
signed = jwt.encode(payload, "jwtSecret", algorithm='HS256')
headers = {
"Authorization": "Bearer {}".format(signed),
"Content-Type": "application/json"
}
print("querrying...")
r = requests.post(f"{ADDRESS}core/model/parse",
data=json.dumps(body),
headers=headers)
I get an authentication error:
{'version': '1.8.1', 'status': 'failure', 'message': 'User is not authenticated.', 'reason': 'NotAuthenticated', 'details': {}, 'help': 'https://rasa.com/docs/rasa/user-guide/configuring-http-api/#security-considerations', 'code': 401}
{
"code": 401,
"details": {},
"help": "https://rasa.com/docs/rasa/user-guide/configuring-http-api/#security-considerations",
"message": "User is not authenticated.",
"reason": "NotAuthenticated",
"status": "failure",
"version": "1.8.1"
}
Did I get something wrong with the call? I placed jwtSecret in the values.yaml file of the helm setup. Rasa version is 1.8.1, Rasa-x is 0.26.3. Is there maybe a more rasa-xish way to get /model/parse functionallity?