Overview
Each stream is composed by a DAG of processors though which the data is processed. Each processor has a set of properties that can be configured to customize its behavior. Those properties are defined inside a stream configuration template, and it can look similar to this:Conversational to Formal.
This can be done by creating a configuration patch that overrides the default value of the tone property.
Configuration patches
A configuration patch is a JSON Patch that respects the RFC 6902 standard, with some imposed limitations. The limitations are:- the only supported operations are
add,replace, andremove - it can only apply to the
propertiesobject of a processor - the added/replaced values can be either a primitive value or an array of primitive values
- string
- number
- boolean
- null
Conversational to Formal looks like this:
The json paths can be also expressed using
..For example, properties.0.properties.tone, properties/0/properties/tone and /properties/0/properties/tone are all equivalent paths.Specifying patches
The JSON Patch format proposed in the RFC 6902 standard is not always suitable for specifying configuration patches. For this reason, the system allows specifying configuration patches asquery parameters in the URL (all gateways) or using a configuration message (WS Gateway only).
Query parameters
The query parameters are specified in the URL of the request, and they are used to specify the configuration patches that should be applied to the stream configuration template. Every patch query parameter can be explicitly marked as a patch by using thepatches. prefix. If the prefix is not specified, all undocumented query parameters are considered as patches.
For example, the equivalent of this JSON Patch:
Operation
By default, the operation isreplace.
Add/Replace
Add/Replace
To use the
add operation, prefix the patch value with +. For example, to add the language property with the value en, use the following query parameter:The
replace operation will behave as the add operation if the property does not exist.So, the equivalent of the previous query parameter is:Remove
Remove
To use the
remove operation, set the patch value to -. For example, to remove the tone property, use the following query parameter:Escape
Escape
To escape the
+ and - characters, use the \ character. For example, to set the tone property to +Formal, use the following query parameter:In most of the cases, the
replace operation is enough, and you don’t need to specify it explicitly.Configuration message
The configuration message is a WebSocket message sent by the client as an initial message to theWS Gateway, with the following structure:
Conversational to Formal looks like this:
. notation:
A configuration message can contain as many patches as needed, and without any (reasonable) length limitation.
The configuration message can be used alongside the query parameters, and the patches from the configuration message will overwrite the patches from the query parameters.
Simplifying paths
Processor index
Each patch path must contain the index of the processor to which the patch should be applied. This may be problematic if the processors order is changed, and the indexes are not updated accordingly. This can be avoided by using the processor ID instead of the index. For example, the following patch:Path alias
Each processor can specify a path alias that can be used to simplify the patch path. Given the following stream configuration template:The equivalence chain
To better understand, we’ll take the following example, and we’ll rewrite it from the most complex to the simplest form. Given the following stream configuration template:patches. prefix
add operation for language with replace
tone and language
Examples
Replace
Replace
Given:To enable the summary, use the following query parameter:
Add
Add
Given:To add the summary language, use the following query parameter:
Set array
Set array
Given:To set the allowed languages to
["en", "fr"], use the following query parameter:Replace with configuration message
Replace with configuration message
Given:To enable the summary and set the tone to
Formal, use the following configuration message: