A really simple HTTP server that parses text using Rasa NLU. Models in the /models
directory are preloaded and cached in memory for fast text parsing.
Python 3.6+
After cloning the repository install all the dependencies with pip:
$ pip3 install -r requirements.txt
You will need to install a spacy language model as they are not included. For example:
$ python -m spacy download en_core_web_sm
Start the server with uvicorn:
$ uvicorn server:app
You can start the server with the included Dockerfile and docker-compose files but as there is not default language model it will be of little use. The best way is to create your own Docker image from the base image:
FROM ccoreilly/rasa-nlu-microservice
WORKDIR /app
RUN pip install https://github.com/ccoreilly/spacy-catala/releases/download/0.1.0/ca_fasttext_wiki-0.1.0-py3-none-any.whl && \
python -m spacy link --force ca_fasttext_wiki ca
EXPOSE 8000
CMD ["gunicorn", "-k", "uvicorn.workers.UvicornWorker", "server:app"]
You can configure the gunicorn server running inside the docker image using environment variables.
The server exposes the following three endpoints:
A JSON object following the Rasa NLU JSON training format
{
"message": "Training started"
}
{
"text": "I want to book a flight to Barcelona"
}
{
"intent": {
"name": "flight_booking",
"confidence": 0.9999189376831055
},
"entities": [
{
"entity": "LOC",
"value": "Barcelona",
"start": 12,
"confidence": null,
"end": 18,
"extractor": "SpacyEntityExtractor",
"processors": [
"EntitySynonymMapper"
]
}
],
"intent_ranking": [
{
"name": "flight_booking",
"confidence": 0.9999189376831055
},
{
"name": "mood_great",
"confidence": 0.0000021114367427799152
},
{
"name": "goodbye",
"confidence": 0.000002077534645650303
},
],
"text": "I want to book a flight to Barcelona"
}
{
"training_status": "TRAINING" | "READY" | "UNKNOWN",
"training_time": "15.34"
}
With training time being the elapsed training time in seconds.