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:43] 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 ===== | ||
- | # deconcentrator-js | + | [[https:// |
- | + | ||
- |  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 | ||
+ | </ | ||
+ | |||
+ | |||
+ | == deconcentrator.js | ||
Uses an express application to listen for incoming messages. For an incoming message it then creates a processor-queue. The processor to can be specified with the `processors` property of an message. See [Request Schema - `Message`](Request-Schema ---Message) for more information. After all processor are done with interpretation the result with a confidence score which is too low are filtered out. | Uses an express application to listen for incoming messages. For an incoming message it then creates a processor-queue. The processor to can be specified with the `processors` property of an message. See [Request Schema - `Message`](Request-Schema ---Message) for more information. After all processor are done with interpretation the result with a confidence score which is too low are filtered out. | ||
- | #### processor-queue.js | + | == processor-queue.js |
For every incoming message the deconcentrator creates a new `ProcessorQueue` (defined in `processor-queue.js`) and adds all available processors to it. When calling the `.interpretate(message)` function of the queue it starts requesting the processors for an interpretation. The number of asynchronous requests can be set with the `numOfSynchronProcessors` property of the queue. | For every incoming message the deconcentrator creates a new `ProcessorQueue` (defined in `processor-queue.js`) and adds all available processors to it. When calling the `.interpretate(message)` function of the queue it starts requesting the processors for an interpretation. The number of asynchronous requests can be set with the `numOfSynchronProcessors` property of the queue. | ||
- | #### processor.js | + | == processor.js |
Defines the interface of a NLU processor. | Defines the interface of a NLU processor. | ||
- | #### Implemented Processors | + | == Implemented Processors |
- | * [rasa-processor.js](model/rasa-processor.js) | + | * [[https:// |
+ | * ... | ||
- | * ... | + | === Add new NLU processor === |
- | + | == Setp 1: == | |
- | + | ||
- | ### Add new NLU processor | + | |
- | + | ||
- | #### Setp 1: | + | |
Create a new NLU processor service. | Create a new NLU processor service. | ||
- | #### Step 2: | + | == Step 2: == |
Create a new `PROCESSOR_NAME-processor.js` file in the `model` directory of the project. | Create a new `PROCESSOR_NAME-processor.js` file in the `model` directory of the project. | ||
- | #### Step 3: | + | == Step 3: == |
Implement the `name` property and the `interpretate` function. Make sure the response looks like the one from rasa or the demo processor. | Implement the `name` property and the `interpretate` function. Make sure the response looks like the one from rasa or the demo processor. | ||
- | #### Step 4: | + | == Step 4: == |
Add the name of the processor to the `default_processors` in the `deconcentrator.js` file. | Add the name of the processor to the `default_processors` in the `deconcentrator.js` file. | ||
- | ## API | + | ==== API ==== |
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 134: | 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. | ||
- | #### 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 174: | 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 text](http:// | + | <uml> |
+ | @startuml | ||
- | ## Implemented and connected NLU processors | + | class Answer { |
+ | text: String | ||
+ | intent: Intent | ||
+ | entities: Array< | ||
+ | error: String | ||
+ | } | ||
- | | Provider |BeuthBot Project | Processor File | | + | class Intent { |
- | | -------- |---------------- | -------------- | | + | name: String |
- | | [RASA](https:// | + | |
+ | } | ||
- | ### More NLU processors candidates | + | class Entity { |
+ | start: Int | ||
+ | end: Int | ||
+ | text: String | ||
+ | value: String | ||
+ | confidence: Float | ||
+ | additional_info: | ||
+ | entity: String | ||
+ | } | ||
- | - [Microsoft LUIS](https:// | + | class AdditionalInfo { |
- | - [Google Cloud NLU](https:// | + | value: String |
- | - [IBM Watson NLU](https:// | + | grain: String |
+ | type: String | ||
+ | values: Dictionary< | ||
+ | } | ||
- | ## .env | + | Answer *--- Intent |
+ | Answer *--- Entity | ||
+ | Entity *--- AdditionalInfo | ||
+ | |||
+ | @enduml | ||
+ | </ | ||
+ | |||
+ | ==== Implemented and connected NLU processors ==== | ||
+ | |||
+ | ^ Provider ^BeuthBot Project ^ Processor File ^ | ||
+ | | [[https:// | ||
+ | |||
+ | === More NLU processors candidates === | ||
+ | |||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | |||
+ | ==== .env ==== | ||
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 | ||
- | ``` | + | </ |
+ | |||
+ | ==== Requirements Analysis ==== | ||
+ | * [x] ''/ | ||
+ | * [x] ''/ | ||
+ | * [x] ''/ | ||
+ | * [x] ''/ | ||
+ | * [x] ''/ | ||
+ | * [x] ''/ | ||
+ | * [x] ''/ | ||
+ | * [x] ''/ | ||
+ | * [ ] ''/ | ||
- | ## 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] `/DCF102/` The deconcentrator sends answers as defined via the Response Schema | ||
- | * [x] `/DCF103/` The deconcentrator answers with proper messages for occuring errors | ||
- | * [x] `/DCF104/` New NLU processors muss be easy to integrate | ||
- | * [x] `/DCF105/` The deconcentrator has a default value for the minimum confidence score | ||
- | * [x] `/DCF106/` The deconcentrator has a default value for the list of processors | ||
- | * [x] `/DCF107/` The minimum confidence score can be set globally within the Dockerfile | ||
- | * [ ] `/DCF108/` The list of processors to be used can be set globally within the Dockerfile |