dialogy.workflow package¶
Submodules¶
dialogy.workflow.workflow module¶
The Workflow represents a black box for an SLU microservice, and its terminals, input and output represent request response structure of the SLU API.
Note
The Input has some extra properties that aren’t part of the SLU API. We have kept reserves for intermediates, and flattened as most other nested inputs aren’t required and add to bloat.
What does it do?¶
Produce the response for a single turn of a conversation. It recieves (not an exhaustive list):
Utterance.
Timezone
Language code
Locale
Current State of the conversation
Slot tracker
as inputs, parses these, produces a few intermediates and finally returns the intent and optionally entities. Details will be documented within the specific plugins.
How does it do it?¶
A workflow contains a sequence of plugins. The sequence is important.
The sequence describes the order in which plugins are run.
The plugins can save their output within the workflow’s input or output.
After execution of all plugins, the workflow returns a pair of serialized input and output.
- class Workflow(plugins=NOTHING, debug=False, *, input=None, output=None)[source]¶
Bases:
object
SLU API blackbox.
- NON_SERIALIZABLE_FIELDS = ['plugins', 'debug', 'lock']¶
- debug¶
Switch on/off the debug logs for the workflow.
- execute()[source]¶
Update input, output attributes.
We iterate through pre/post processing functions and update the input and output attributes of the class. It is expected that pre-processing functions would modify the input, and post-processing functions would modify the output.
- Return type
- flush()[source]¶
Reset
workflow.input
andworkflow.output
.- Return type
Tuple
[Dict
[str
,Any
],Dict
[str
,Any
]]
- input: Optional[dialogy.base.input.Input]¶
Represents the SLU API request object. A few nested properties and intermediates are flattened out for readability.
- lock: _thread.allocate_lock¶
A workflow isn’t thread-safe by itself. We need locks to prevent race conditions.
- output: Optional[dialogy.base.output.Output]¶
Represents the SLU API response object.
- run(input_)[source]¶
Get final results from the workflow.
The current workflow exhibits the following simple procedure: pre-processing -> inference -> post-processing.
- Return type
Tuple
[Dict
[str
,Any
],Dict
[str
,Any
]]
- set(path, value, replace=False, sort_output_attributes=True)[source]¶
Set attribute path with value.
This method (re)-sets the input or output object without losing information from previous instances.
- Parameters
path (str) – A ‘.’ separated attribute path.
value (bool) – A value to set.
sort_output_attributes (
bool
) – A boolean to sort output attributes.
- Returns
This instance
- Return type
- train(training_data)[source]¶
Train all the plugins in the workflow.
Plugin’s have a no-op train method by default. The one’s that do require training should override this method. All trainable plugins manage their data validation (in case the data isn’t suitable for them) and saving/loading artifacts.
- Parameters
training_data (pd.DataFrame) – [description]
- Return type