Formatters are the functions that allow converting the input and output API of services into Agent’s API. In the provided example configuraton file you can find that each service has its own formatter function:

{
"name": "odqa",
"formatter": odqa_formatter
}

DeepPavlov Formatters

The pre-built DeepPavlov formatters exist for demonstration purposes. These formatters have three attributes:

  • payload

    If mode==in payload is a batch of input states (dialogs) to the model. If the model can’t accept a list of dialog dictionaries, they can be formatted into something else, for example into a batch of last utterances from each dialog.

    If mode==out payload is the result returned by the DeepPavlov model. Unlike in mode, here we format a a single element of batch results returned by the model. The same formatting is applied to all other elements of the batch. Here the result should be formatted according to the Agent’s Services HTTP API.

  • model_args_names

    Should be the same names as the particular DeepPavlov model config accepts.

  • mode

    Can be in or out. In the in mode we format everything that goes from the Agent to the service. In the out mode we format everything that goes from the service to the Agent.

Output Formatters

Output Formatters allows regularization of what the Agent’s HTTP server can return. By default the Agent’s server returns only a bot utterance and a user id:

{
  "user_id": "same user id as in request",
  "response": "phrase, which were generated by skills in order to respond"
}

But if you need the server to return some additional information, for example the name of the active skill, you can do the following:

  • Edit the code in the state_formatters/http_debug_output_formatter() method. It accepts the whole Agent’s state as payload argument, so anything available in the state can be extracted from payload.
  • Run run.py with debug==True option.