You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nlpcraft.apache.org by ar...@apache.org on 2020/09/22 00:06:02 UTC

[incubator-nlpcraft] branch master updated: Removed separate dialog timeout from conversation implementation.

This is an automated email from the ASF dual-hosted git repository.

aradzinski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git


The following commit(s) were added to refs/heads/master by this push:
     new 412e4de  Removed separate dialog timeout from conversation implementation.
412e4de is described below

commit 412e4de8c5d545aa0632a21c8358e63765e66cc5
Author: Aaron Radzinski <ar...@datalingvo.com>
AuthorDate: Mon Sep 21 17:05:52 2020 -0700

    Removed separate dialog timeout from conversation implementation.
---
 .../apache/nlpcraft/examples/sql/SqlModel.scala    | 10 ++++-----
 .../org/apache/nlpcraft/model/NCConversation.java  | 20 -----------------
 .../org/apache/nlpcraft/model/NCModelView.java     | 25 ----------------------
 .../probe/mgrs/deploy/NCDeployManager.scala        |  1 -
 .../mgrs/dialogflow/NCDialogFlowManager.scala      |  2 +-
 5 files changed, 6 insertions(+), 52 deletions(-)

diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/sql/SqlModel.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/sql/SqlModel.scala
index 761fe71..931f7ac 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/sql/SqlModel.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/sql/SqlModel.scala
@@ -62,12 +62,12 @@ class SqlModel extends NCModelFileAdapter("org/apache/nlpcraft/examples/sql/sql_
     /**
       * Converts execution error to JSON.
       *
-      * @param error Error text.
+      * @param err Error text.
       */
-    private def toJson(error: String): String = {
+    private def toJson(err: String): String = {
         val m = new java.util.HashMap[String, Any]()
 
-        m.put("error", error)
+        m.put("error", err)
 
         GSON.toJson(m)
     }
@@ -112,7 +112,7 @@ class SqlModel extends NCModelFileAdapter("org/apache/nlpcraft/examples/sql/sql_
     }
     
     /**
-      * Find any first column token in the given token or its constittuent tokens.
+      * Find any first column token in the given token or its constituent tokens.
       *
       * @param tok Token.
       * @return Column token or throws exception.
@@ -424,7 +424,7 @@ class SqlModel extends NCModelFileAdapter("org/apache/nlpcraft/examples/sql/sql_
             val ok = toks.forall(isValue) || toks.forall(isColumn) || toks.size == 1 && isDate(toks.head)
 
             if (!ok) {
-                m.getContext.getConversation.clearAllStm()
+                m.getContext.getConversation.clearStm(_ ⇒ true)
 
                 logger.info("Conversation reset, trying without conversation.")
             }
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCConversation.java b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCConversation.java
index 76ba91b..5655426 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCConversation.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCConversation.java
@@ -72,16 +72,6 @@ public interface NCConversation {
     void clearStm(Predicate<NCToken> filter);
 
     /**
-     * Removes all tokens from the conversation STM. It is equivalent to:
-     * <pre class="brush: java">
-     *     clearStm(tok -&gt; true);
-     * </pre>
-     */
-    default void clearAllStm() {
-        clearStm(tok -> true);
-    }
-
-    /**
      * Clears history of matched intents using given intent predicate.
      * <p>
      * History of matched intents (i.e. the dialog flow) can be used in intent definition as part of its
@@ -93,14 +83,4 @@ public interface NCConversation {
      * @param filter Dialog flow filter based on IDs of previously matched intents.
      */
     void clearDialog(Predicate<String/* Intent ID. */> filter);
-
-    /**
-     * Clears entire history of matched intents. It is equivalent to:
-     * <pre class="brush: java">
-     *     clearDialog(id -&gt; true);
-     * </pre>
-     */
-    default void clearAllDialog() {
-        clearDialog(id -> true);
-    }
 }
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCModelView.java b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCModelView.java
index 8bcafb1..26b142a 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCModelView.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCModelView.java
@@ -64,11 +64,6 @@ public interface NCModelView extends NCMetadata {
     int DFLT_CONV_DEPTH = 3;
 
     /**
-     * Default value for {@link #getDialogTimeout()} method.
-     */
-    long DFLT_DIALOG_TIMEOUT_MS = Duration.ofMinutes(60).toMillis();
-
-    /**
      * Default value for {@link #getJiggleFactor()} method.
      */
     Map<String, Object> DFLT_METADATA = new HashMap<>();
@@ -1031,24 +1026,4 @@ public interface NCModelView extends NCMetadata {
      * @see #getConversationTimeout()
      */
     default int getConversationDepth() { return DFLT_CONV_DEPTH; }
-
-    /**
-     * Gets timeout in ms after which given user input is removed from dialog flow history.
-     * <p>
-     * <b>Default</b>
-     * <br>
-     * If not provided by the model the default value {@link #DFLT_DIALOG_TIMEOUT_MS} will be used.
-     * <p>
-     * <b>JSON</b>
-     * <br>
-     * If using JSON/YAML model presentation this is set by <code>dialogTimeout</code> property:
-     * <pre class="brush: js">
-     * {
-     *      "dialogTimeout": 300000
-     * }
-     * </pre>
-     *
-     * @return Timeout in ms after which given user input is removed from dialog flow history.
-     */
-    default long getDialogTimeout() { return DFLT_DIALOG_TIMEOUT_MS; }
 }
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/deploy/NCDeployManager.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/deploy/NCDeployManager.scala
index 72b343f..226343f 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/deploy/NCDeployManager.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/deploy/NCDeployManager.scala
@@ -852,7 +852,6 @@ object NCDeployManager extends NCService with DecorateAsScala {
         checkMandatoryString(mdl.getVersion, "version", 16)
 
         checkNum(mdl.getConversationTimeout, "conversationTimeout")
-        checkNum(mdl.getDialogTimeout, "dialogTimeout")
         checkNum(mdl.getMaxUnknownWords, "maxUnknownWords")
         checkNum(mdl.getMaxFreeWords, "maxFreeWords")
         checkNum(mdl.getMaxSuspiciousWords, "maxSuspiciousWords")
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/dialogflow/NCDialogFlowManager.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/dialogflow/NCDialogFlowManager.scala
index b59e811..7984199 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/dialogflow/NCDialogFlowManager.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/dialogflow/NCDialogFlowManager.scala
@@ -122,7 +122,7 @@ object NCDialogFlowManager extends NCService {
                 for ((key, values) ← flow)
                     NCModelManager.getModelOpt(key.mdlId) match {
                         case Some(data) ⇒
-                            val ms = System.currentTimeMillis() - data.model.getDialogTimeout
+                            val ms = System.currentTimeMillis() - data.model.getConversationTimeout
 
                             values --= values.filter(_.tstamp < ms)