Paranet Actors
The following sections describe more advanced usage of the native Paranet support in Paraflow.
Skill Implementation
The expanded form of the skill declaration offers the additional features:
- Calculate derived values to be used as parameters to the skill goal
- Handle questions from the skill requester
- Handle status messages from the skill requester
- Handle a canceled request
For example,
skill basic/test($case string) {
let $t = Now();
new !Test($case, $t);
} handle {
question progress -> with !Test(case == $case, $t) {
pncp answer(message -> "working " + TimeElapsed($t, Now()));
}
status { $notice } -> log warn(`requester says $notice`);
cancel -> {
log warn(`requester cancel`);
cancel !Test($case);
}
}
The start block is executed when a skill request is received and the handle cases are executed when a the corresponding message is received. Note that the skill input parameters are available in handlers. The entire handle block is optional as well as each individual handle case.
Skill Requests
The expanded form of the delegate declaration offers the additional features:
- Calculate derived values to be used as parameters to the skill request
- Ability to do post-processing of the response
- Handle errors from the skill provider
- Handle a cancel from the skill provider
For example,
delegate !DoRequest($case) {
let $deadline = Now() + 5 min;
let { $answer } = pncp request basic/handler($case, $deadline) in {
pncp response(result -> "success", $answer);
}
} handle {
error { $error } -> pncp response(result -> "failed", $error);
cancel -> pncp response(result -> "canceled");
}
Questions
Actors can ask each other questions during the coarse of a skill request. Paraflow actors can ask questions by declaring how a goal maps to a question. Since questions are associated with a active skill request, the goal must be part of a skill-request workflow. The concise form of the question declaration has the following syntax.
<question-declaration> := "question" <goal-pattern> "is" <question-id> <call-bindings> [ "output" <output-clause> ] ";"
<output-clause> := "{" <output-field> [ "," <output-field> ] "}"
<output-field> := <variable> | <field> ":" <variable>
For example,
question !Confirm($name) is sure(message->"Are you sure (y/n)") output { $answer };
The question declaration also has an expanded form which support do some pre- and/or post-processing of the question inputs/outputs. For example,
question !Confirm($case) {
let { $ok } = pncp question sure(message->"Are you sure (y/n)") in {
log info("got "+$answer);
}
}