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 2021/06/25 23:20:42 UTC

[incubator-nlpcraft] 02/03: WIP.

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

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

commit ad7fea7cbb242993da3ee0cae2e5436c4f097c82
Author: Aaron Radzinski <ar...@datalingvo.com>
AuthorDate: Fri Jun 25 15:57:09 2021 -0700

    WIP.
---
 .../scala/org/apache/nlpcraft/model/tools/cmdline/NCCli.scala  |  9 ++++++++-
 .../org/apache/nlpcraft/model/tools/cmdline/NCCliBase.scala    |  1 +
 .../apache/nlpcraft/model/tools/cmdline/NCCliCommands.scala    | 10 +++++-----
 3 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCli.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCli.scala
index 2676651..e7893db 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCli.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCli.scala
@@ -1719,7 +1719,14 @@ object NCCli extends NCCliBase {
     private [cmdline] def cmdAsk(cmd: Command, args: Seq[Argument], repl: Boolean): Unit =
         state.accessToken match {
             case Some(acsTok) =>
-                val mdlId = getParam(cmd, args, "mdlId")
+                val mdlId = getParamOpt(cmd, args, "mdlId") match {
+                    case Some(id) => id
+                    case None =>
+                        if (state.probes.size == 1 && state.probes.head.models.length == 1)
+                            state.probes.head.models.head.id
+                        else
+                            throw MissingOptionalParameter(cmd, "mdlId")
+                }
                 val txt = getParam(cmd, args, "txt")
                 val data = getParamOrNull(cmd, args, "data")
                 val enableLog = getFlagParam(cmd, args, "enableLog", dflt = false)
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCliBase.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCliBase.scala
index 9a19e3e..bde8ddd 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCliBase.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCliBase.scala
@@ -141,6 +141,7 @@ class NCCliBase extends App {
     case class TooManyArguments(cmd: Command) extends ISE(s"Too many arguments, ${help(cmd)}")
     case class NotEnoughArguments(cmd: Command) extends ISE(s"Not enough arguments, ${help(cmd)}")
     case class MissingParameter(cmd: Command, paramId: String) extends ISE( s"Missing mandatory parameter $C${"'" + cmd.params.find(_.id == paramId).get.names.head + "'"}$RST, ${help(cmd)}")
+    case class MissingOptionalParameter(cmd: Command, paramId: String) extends ISE( s"Missing optional but required in this context parameter $C${"'" + cmd.params.find(_.id == paramId).get.names.head + "'"}$RST, ${help(cmd)}")
     case class MissingMandatoryJsonParameters(cmd: Command, missingParams: Seq[RestSpecParameter], path: String) extends ISE(s"Missing mandatory JSON parameters (${missingParams.map(s => y(s.name)).mkString(",")}) for $C${"'" + cmd.name + s" --path=$path'"}$RST, ${help(cmd)}")
     case class InvalidParameter(cmd: Command, paramId: String) extends ISE(s"Invalid parameter $C${"'" + cmd.params.find(_.id == paramId).get.names.head + "'"}$RST, ${help(cmd)}")
     case class InvalidJsonParameter(cmd: Command, param: String) extends ISE(s"Invalid JSON parameter $C${"'" + param + "'"}$RST, ${help(cmd)}")
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCliCommands.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCliCommands.scala
index 8235e5b..d78f8ab 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCliCommands.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCliCommands.scala
@@ -299,9 +299,9 @@ private [cmdline] object NCCliCommands {
                     value = Some("model.id"),
                     optional = true,
                     desc =
-                        s"ID of the data model to send the request to. Note that this is optional ONLY if the connected " +
-                        s"probe has only one model deployed - which will be used by default. If the probe has more " +
-                        s"than one model deployed - this parameter is mandatory." +
+                        s"ID of the data model to send the request to. Note that this is optional ONLY if there is only one " +
+                        s"connected probe and it has only one model deployed - which will be used by default. In all other " +
+                        s"cases - this parameter is mandatory." +
                         s"In REPL mode, hit ${rv(" Tab ")} to see auto-suggestion for possible model IDs."
                 ),
                 Parameter(
@@ -563,8 +563,8 @@ private [cmdline] object NCCliCommands {
                     desc =
                         s"ID of the model to run synonym suggestion on. " +
                         s"In REPL mode, hit ${rv(" Tab ")} to see auto-suggestion for possible model IDs. Note that " +
-                        s"this is optional ONLY if the connected probe has only one model deployed - which will be " +
-                        s"used by default. If the probe has more than one model deployed - this parameter is mandatory." 
+                        s"this is optional ONLY if there is only one connected probe and it has only one model deployed - which will be " +
+                        s"used by default. In all other cases - this parameter is mandatory."
                 ),
                 Parameter(
                     id = "minScore",