Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
|
wiki:software:beuthbot:deconcentrator-js [22.07.2020 18:49] Lukas Danckwerth |
wiki:software:beuthbot:deconcentrator-js [22.07.2020 19:20] (aktuell) Lukas Danckwerth [Requirements Analysis] |
||
|---|---|---|---|
| Zeile 1: | Zeile 1: | ||
| ===== Deconcentrator-JS ===== | ===== Deconcentrator-JS ===== | ||
| - | [[http://php.net|{{https:// | + | [[https://raw.githubusercontent.com/ |
| > BeuthBot deconcentrator written in JavaScript | > BeuthBot deconcentrator written in JavaScript | ||
| Zeile 13: | Zeile 13: | ||
| == Prerequisites == | == Prerequisites == | ||
| - | * [node.js](https:// | + | |
| - | * [Docker](https:// | + | * [[https:// |
| - | * [docker-compose](https:// | + | * [[https:// |
| == Clone Repository == | == Clone Repository == | ||
| - | ```shell script | + | < |
| # clone project | # clone project | ||
| $ git clone https:// | $ git clone https:// | ||
| Zeile 28: | Zeile 28: | ||
| # copy environment file and edit properly | # copy environment file and edit properly | ||
| $ cp .env.sample .env | $ cp .env.sample .env | ||
| - | ``` | + | </ |
| == Install == | == Install == | ||
| Zeile 34: | Zeile 34: | ||
| There are two different ways running the deconcentrator. First is with `Node.js`' | There are two different ways running the deconcentrator. First is with `Node.js`' | ||
| - | = Install with npm = | + | == Install with npm == |
| Using npm you simply type in the following command. | Using npm you simply type in the following command. | ||
| - | ```shell script | + | < |
| # install dependencies | # install dependencies | ||
| $ npm install | $ npm install | ||
| Zeile 42: | Zeile 42: | ||
| # start running the deconcentrator at localhost: | # start running the deconcentrator at localhost: | ||
| $ npm start run | $ npm start run | ||
| - | ``` | + | </ |
| This will run the deconcentrator on it's default port `8338` and with the default RASA service url `http:// | This will run the deconcentrator on it's default port `8338` and with the default RASA service url `http:// | ||
| - | = Install with docker-compose.yml = | + | == Install with docker-compose.yml |
| Using docker-compose is prossibly the easiest way of running the deconcentrator. Simply type | Using docker-compose is prossibly the easiest way of running the deconcentrator. Simply type | ||
| - | ```shell script | + | < |
| $ docker-compose up | $ docker-compose up | ||
| - | ``` | + | </ |
| to run a container with the deconcentrator. The docker-compose file also uses port `8338` as a default one. The endpoint of RASA is taken from the `.env`. Make sure to edit it to your needs. Have a look at the sample file `.env.sample` and the section [.env](# | to run a container with the deconcentrator. The docker-compose file also uses port `8338` as a default one. The endpoint of RASA is taken from the `.env`. Make sure to edit it to your needs. Have a look at the sample file `.env.sample` and the section [.env](# | ||
| ==== Overview ==== | ==== Overview ==== | ||
| - | ### Structure | + | === Structure |
| - | | Location | + | ^ Location |
| - | | -------------------- | ----------------------------------------------------- | | + | |
| | `.documentation/ | | `.documentation/ | ||
| | `model/ | | `model/ | ||
| Zeile 71: | Zeile 71: | ||
| - | ### Functionality | + | === Functionality === |
| + | |||
| + | |||
| + | < | ||
| + | @startuml | ||
| + | |||
| + | participant " | ||
| + | |||
| + | box " | ||
| + | participant " | ||
| + | participant " | ||
| + | participant " | ||
| + | participant " | ||
| + | participant " | ||
| + | end box | ||
| + | |||
| + | GW -> DC: request\nwith message | ||
| + | activate DC | ||
| + | DC -> DC: create and fill queue | ||
| + | DC -> PQ: run | ||
| + | activate PQ | ||
| + | PQ -> RP: (async) request | ||
| + | activate RP | ||
| + | PQ -> P1: (async) request | ||
| + | activate P1 | ||
| + | RP -> PQ: interpretation | ||
| + | deactivate RP | ||
| + | PQ -> P2: (async) request | ||
| + | activate P2 | ||
| + | P1 -> PQ: interpretation | ||
| + | deactivate P1 | ||
| + | P2 -> PQ: interpretation | ||
| + | deactivate P2 | ||
| + | PQ -> DC: all\ninterpretations | ||
| + | deactivate PQ | ||
| + | DC -> DC: filter out\nbest intent | ||
| + | DC -> GW: response\nwith intent | ||
| + | deactivate DC | ||
| + | |||
| + | @enduml | ||
| + | </ | ||
| - |  | + | |
| + | * ... | ||
| - | * ... | + | === Add new NLU processor |
| - | + | ||
| - | + | ||
| - | + | ||
| - | ### Add new NLU processor | + | |
| == Setp 1: == | == Setp 1: == | ||
| Zeile 114: | Zeile 150: | ||
| The following lists the resources that can be requested with the deconcentrator API. | The following lists the resources that can be requested with the deconcentrator API. | ||
| - | ```http | + | < |
| GET | GET | ||
| - | ``` | + | </ |
| Returns a live sign of the deconcentrator. | Returns a live sign of the deconcentrator. | ||
| - | ```http | + | < |
| POST http:// | POST http:// | ||
| - | ``` | + | </ |
| - | ### Request Schema - `Message` | + | === Request Schema - `Message` |
| - | ```json | + | < |
| { | { | ||
| " | " | ||
| Zeile 132: | Zeile 168: | ||
| " | " | ||
| } | } | ||
| - | ``` | + | </ |
| Whereas the specification of the `min_confidence_score` and the`processors` is optional. If not minimum confidence score is given a default one is used (by now this is `0.8`). For now there is only the usage of RASA implemented so there is no effect of specifying the `processors` property. | Whereas the specification of the `min_confidence_score` and the`processors` is optional. If not minimum confidence score is given a default one is used (by now this is `0.8`). For now there is only the usage of RASA implemented so there is no effect of specifying the `processors` property. | ||
| Zeile 138: | Zeile 174: | ||
| == Class Diagramm == | == Class Diagramm == | ||
| - | ![alternative text](http:// | + | <uml> |
| + | @startuml | ||
| - | ### Response Schema - `Answer` | + | class Message { |
| + | text: String | ||
| + | min_confidence_score: | ||
| + | processors: Array< | ||
| + | } | ||
| + | |||
| + | @enduml | ||
| + | </ | ||
| + | |||
| + | === Response Schema - `Answer` | ||
| The response for a successfully processed request to the deconcentrator contains the following information. | The response for a successfully processed request to the deconcentrator contains the following information. | ||
| - | ```json | + | < |
| { | { | ||
| " | " | ||
| Zeile 172: | Zeile 218: | ||
| " | " | ||
| } | } | ||
| - | ``` | + | </ |
| The response for a unsuccessfully processed request to the deconcentrator or when an error occures contains the following information. | The response for a unsuccessfully processed request to the deconcentrator or when an error occures contains the following information. | ||
| - | ```json | + | < |
| { | { | ||
| " | " | ||
| " | " | ||
| } | } | ||
| - | ``` | + | </ |
| == Class Diagramm == | == Class Diagramm == | ||
| - | ![alternative | + | < |
| + | @startuml | ||
| + | |||
| + | class Answer { | ||
| + | | ||
| + | intent: Intent | ||
| + | entities: Array< | ||
| + | error: String | ||
| + | } | ||
| + | |||
| + | class Intent { | ||
| + | name: String | ||
| + | confidence: Float | ||
| + | } | ||
| + | |||
| + | class Entity { | ||
| + | start: Int | ||
| + | end: Int | ||
| + | text: String | ||
| + | value: String | ||
| + | confidence: Float | ||
| + | additional_info: | ||
| + | entity: String | ||
| + | } | ||
| + | |||
| + | class AdditionalInfo { | ||
| + | value: String | ||
| + | grain: String | ||
| + | type: String | ||
| + | values: Dictionary< | ||
| + | } | ||
| + | |||
| + | Answer *--- Intent | ||
| + | Answer *--- Entity | ||
| + | Entity *--- AdditionalInfo | ||
| + | |||
| + | @enduml | ||
| + | </uml> | ||
| ==== Implemented and connected NLU processors ==== | ==== Implemented and connected NLU processors ==== | ||
| - | | Provider | + | ^ Provider |
| - | | -------- |---------------- | -------------- | | + | | [[https:// |
| - | | [RASA](https:// | + | |
| - | ### More NLU processors candidates | + | === More NLU processors candidates |
| - | - [Microsoft LUIS](https:// | + | * [[https:// |
| - | - [Google Cloud NLU](https:// | + | * [[https:// |
| - | - [IBM Watson | + | * [[https:// |
| ==== .env ==== | ==== .env ==== | ||
| Zeile 202: | Zeile 284: | ||
| With the `.env` file the deconcentrator can be configured. The following demonstrates a sample file. The same content can be found in the`.env.sample` file of the project. | With the `.env` file the deconcentrator can be configured. The following demonstrates a sample file. The same content can be found in the`.env.sample` file of the project. | ||
| - | ```dotenv | + | < |
| RASA_ENDPOINT=http:// | RASA_ENDPOINT=http:// | ||
| # Optional | # Optional | ||
| MIN_CONFIDENCE_SCORE=0.85 | MIN_CONFIDENCE_SCORE=0.85 | ||
| - | ``` | + | </ |
| Zeile 213: | Zeile 295: | ||
| ==== Requirements Analysis ==== | ==== Requirements Analysis ==== | ||
| - | * [x] `/DCF100/` The deconcentrator responds to incoming POST requests by delegating the message to a collection of NLU processor which try to interpretate the given message | + | |
| - | * [x] `/DCF101/` The deconcentrator accepts incoming messages as defined via the Request Schema | + | * [x] '' |
| - | * [x] `/DCF102/` The deconcentrator sends answers as defined via the Response Schema | + | * [x] '' |
| - | * [x] `/DCF103/` The deconcentrator answers with proper messages for occuring errors | + | * [x] '' |
| - | * [x] `/DCF104/` New NLU processors muss be easy to integrate | + | * [x] '' |
| - | * [x] `/DCF105/` The deconcentrator has a default value for the minimum confidence score | + | * [x] '' |
| - | * [x] `/DCF106/` The deconcentrator has a default value for the list of processors | + | * [x] '' |
| - | * [x] `/DCF107/` The minimum confidence score can be set globally within the Dockerfile | + | * [x] '' |
| - | * [ ] `/DCF108/` The list of processors to be used can be set globally within the Dockerfile | + | * [ ] '' |