public final class RasaOpenSourceNLU extends Object implements NLUService
Since the input for a Rasa Open Source request is a user utterance, this
component occupies the position in Spokestack of an NLU, but a Rasa webhook
response includes results from the dialogue model, leaving out NLU results.
Therefore, this component returns a constant value as the intent and
includes the webhook response as a list inside the result context under a
"responses" key.
This component is designed to be used with a DialogueManager
built with a RasaDialoguePolicy policy, which expects results in
the format just described and converts the Rasa responses into TTS
prompts or app events as appropriate.
This component supports the following configuration properties:
| Modifier and Type | Field and Description |
|---|---|
static String |
RASA_INTENT
The designated intent produced by this component since Rasa Open Source
responses do not include classification results.
|
static String |
RESPONSE_KEY
The designated key for response messages from Rasa Open Source in an
NLUResult produced by this component. |
| Constructor and Description |
|---|
RasaOpenSourceNLU(SpeechConfig config,
NLUContext nluContext)
Create a new Rasa Open Source NLU component.
|
| Modifier and Type | Method and Description |
|---|---|
AsyncResult<NLUResult> |
classify(String utterance,
NLUContext nluContext)
Classifies a user utterance.
|
void |
close() |
public static final String RASA_INTENT
public static final String RESPONSE_KEY
NLUResult produced by this component.public RasaOpenSourceNLU(SpeechConfig config, NLUContext nluContext)
config - configuration propertiesnluContext - The NLU context used to dispatch trace events and
errors.public AsyncResult<NLUResult> classify(String utterance, NLUContext nluContext)
NLUServiceAsyncResult allows the
caller to either block while waiting for a result or register a callback
to be executed when the result is available.classify in interface NLUServiceutterance - The user utterance to be classified.nluContext - The current NLU context, containing request metadata and
the ability to fire trace events.AsyncResult representing the result of the
classification task.AsyncResult.registerCallback(io.spokestack.spokestack.util.Callback)public void close()
throws Exception
close in interface AutoCloseableExceptionCopyright © 2021. All rights reserved.