NCConversation
Conversation container. Conversation contains everything that should be implicitly remembered during the active, ongoing conversation and forgotten once the conversation ends or timed out. Conversation contains the following elements:
- List of entities comprising a "short-term-memory" (STM) of this conversation.
- Chronological list of previously matched intents.
- Auto-expiring user data.
Note that the conversation is unique for given combination of user and data model.
Conversation management is based on idea of a "short-term-memory" (STM). STM can be viewed as a condensed short-term history of the input for a given user and data model. Every submitted user request that wasn't rejected is added to the conversation STM as a list of tokens. Existing STM tokens belonging to the same group will be overridden by the more recent tokens from the same group. Note also that tokens in STM automatically expire (i.e. context is "forgotten") after a certain period of time and/or based on the depth of the conversation since the last mention.
You can also maintain user state-machine between requests using conversation's session. Conversation's data is a mutable thread-safe container that can hold any arbitrary user data while supporting the same expiration logic as the rest of the conversation elements (i.e. tokens and previously matched intent IDs).
Conversation expiration policy is configured by two configuration properties:
- See also:
- Source:
- NCConversation.scala
Value members
Abstract methods
Removes all previously matched intents using given dialog flow item predicate.
Removes all previously matched intents using given dialog flow item predicate.
History of matched intents (i.e. the dialog flow) can be used in intent definition as part of its matching template. NLPCraft maintains the window of previously matched intents based on time, i.e. after certain period of time the oldest previously matched intents are forgotten and removed from dialog flow. This method allows explicitly clear previously matched intents from the dialog flow based on user logic other than time window.
- Value parameters:
- filter
Dialog flow filter.
- Source:
- NCConversation.scala
Removes all entities satisfying given predicate from the conversation STM. This is particularly useful when the logic processing the user input makes an implicit assumption not present in the user input itself. Such assumption may alter the conversation (without having an explicit entities responsible for it) and therefore this method can be used to remove "stale" entities from conversation STM.
Removes all entities satisfying given predicate from the conversation STM. This is particularly useful when the logic processing the user input makes an implicit assumption not present in the user input itself. Such assumption may alter the conversation (without having an explicit entities responsible for it) and therefore this method can be used to remove "stale" entities from conversation STM.
For example, in some cases the intent logic can assume the user current location as an implicit geographical location and therefore all existing geographical-related entities should be removed from the conversation STM to maintain correct context.
- Value parameters:
- filter
Entity remove filter.
- Source:
- NCConversation.scala
Gets user-defined data as a mutable thread-safe property container. Note tha this container has the same expiration policy as the conversation it belongs to. Specifically, the returned container will be cleared when the conversation gets cleared automatically (by timeout or depth) or manually.
Gets user-defined data as a mutable thread-safe property container. Note tha this container has the same expiration policy as the conversation it belongs to. Specifically, the returned container will be cleared when the conversation gets cleared automatically (by timeout or depth) or manually.
- Returns:
User-defined conversation data container. Can be empty but never
null
.- Source:
- NCConversation.scala
Gets the chronologically ordered list of previously matched intents sorted from oldest to newest for the current user.
Gets the chronologically ordered list of previously matched intents sorted from oldest to newest for the current user.
- Returns:
List of chronologically ordered previously matched dialog flow items.
- Source:
- NCConversation.scala
Gets an ordered list of entities stored in the conversation STM for the current user and data model. Entities in the returned list are ordered by their conversational depth, i.e. the entities from more recent requests appear before entities from older requests.
Gets an ordered list of entities stored in the conversation STM for the current user and data model. Entities in the returned list are ordered by their conversational depth, i.e. the entities from more recent requests appear before entities from older requests.
Note that specific rules by which STM operates are undefined for the purpose of this function - caller should not rely on any observed behavior of how STM stores and evicts its content.
- Returns:
List of entities for this conversation's STM. The list can be empty which indicates that conversation is brand new or expired - but never
null
.- Source:
- NCConversation.scala