public final class RasaDialoguePolicy extends Object implements DialoguePolicy
RasaOpenSourceNLU
component and dispatches events
based on its contents.
A text
response is dispatched as a PROMPT
event, and an image
is dispatched as an ACTION
event with an appAction
of "displayImage"
and a systemPrompt
containing the image URL.
Intents that do not match the one produced by RasaOpenSourceNLU
are
not supported and will result in ERROR
events.
Constructor and Description |
---|
RasaDialoguePolicy(SpeechConfig speechConfig)
Create a new dialogue policy for handling responses from Rasa Open
Source.
|
Modifier and Type | Method and Description |
---|---|
void |
completeTurn(boolean success,
ConversationData conversationData,
DialogueDispatcher eventDispatcher)
Complete the pending user turn.
|
String |
dump(ConversationData conversationData)
Store the internal state of the dialogue policy in the specified data
store for cross-session persistence.
|
void |
handleTurn(NLUResult userTurn,
ConversationData conversationData,
DialogueDispatcher eventDispatcher)
Process a user turn and return a relevant response.
|
void |
load(String state,
ConversationData conversationData)
Load previously serialized internal state.
|
public RasaDialoguePolicy(SpeechConfig speechConfig)
speechConfig
- configuration properties for this policy.public String dump(ConversationData conversationData)
DialoguePolicy
dump
in interface DialoguePolicy
conversationData
- The data store where policy state should be
saved.public void load(String state, ConversationData conversationData)
DialoguePolicy
load
in interface DialoguePolicy
state
- Policy state serialized using dump()
.conversationData
- The data store where any relevant policy state
should be loaded.public void handleTurn(NLUResult userTurn, ConversationData conversationData, DialogueDispatcher eventDispatcher)
DialoguePolicy
handleTurn
in interface DialoguePolicy
userTurn
- The user input as determined by the NLU
component.conversationData
- Conversation data used to resolve and prepare a
response.eventDispatcher
- Dispatcher used to notify listeners of dialogue
events.public void completeTurn(boolean success, ConversationData conversationData, DialogueDispatcher eventDispatcher)
DialoguePolicy
This method should be called after any actions or data retrieval pending in the app are completed.
completeTurn
in interface DialoguePolicy
success
- true
if the user's request/desired action
was fulfilled successfully; false
otherwise.conversationData
- Conversation data used to resolve and prepare a
response.eventDispatcher
- Dispatcher used to notify listeners of dialogueCopyright © 2021. All rights reserved.