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 fb3a28108cddd79f6e6e48f589c4e174d1641fe8 Author: Aaron Radzinski <[email protected]> AuthorDate: Fri Jun 25 16:20:32 2021 -0700 WIP. --- .../org/apache/nlpcraft/common/util/NCUtils.scala | 2 +- .../apache/nlpcraft/model/tools/cmdline/NCCli.scala | 15 +++++++++++++-- .../nlpcraft/model/tools/cmdline/NCCliCommands.scala | 20 ++++++++++++++++++-- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/util/NCUtils.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/util/NCUtils.scala index dcf9feb..20f90f6 100644 --- a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/util/NCUtils.scala +++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/util/NCUtils.scala @@ -147,7 +147,7 @@ object NCUtils extends LazyLogging { def nowUtcTs(): Timestamp = new Timestamp(Instant.now().toEpochMilli) /** - * Shortcut. + * Shortcut - current timestamp in milliseconds. */ def now(): Long = System.currentTimeMillis() 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 e7893db..1551af1 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 @@ -1692,7 +1692,14 @@ object NCCli extends NCCliBase { private [cmdline] def cmdSugSyn(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 minScore = getDoubleParam(cmd, args, "minScore", 0.5) httpRest( @@ -2211,6 +2218,8 @@ object NCCli extends NCCliBase { spinner.start() + val start = U.now() + // Make the REST call. val resp = try @@ -2218,8 +2227,10 @@ object NCCli extends NCCliBase { finally spinner.stop() + val durMs = U.now() - start + // Ack HTTP response code. - logln(s"HTTP ${if (resp.code == 200) g("200") else r(resp.code)}") + logln(s"HTTP ${if (resp.code == 200) g("200") else r(resp.code)} [${durMs}ms]") if (U.isValidJson(resp.data)) logln(U.colorJson(U.prettyJson(resp.data))) 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 d78f8ab..02b292d 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 @@ -328,12 +328,20 @@ private [cmdline] object NCCliCommands { examples = Seq( Example( usage = Seq( - s"""> ask --txt="User request" --mdlId=my.model.id""", - s"""> ask --txt="User text"""" + s"""> ask --txt="User request" --mdlId=my.model.id""" ), desc = s"Issues ${y("'ask/sync'")} REST call with given text and model ID." + ), + Example( + usage = Seq( + s"""> ask --txt="User text"""" + ), + desc = + s"Issues ${y("'ask/sync'")} REST call with given text and default model ID " + + s"(single connected probe that has a single model deployed)." ) + ) ), Command( @@ -581,6 +589,14 @@ private [cmdline] object NCCliCommands { ), desc = s"Issues ${y("'model/sugsyn'")} REST call with default min score and given model ID." + ), + Example( + usage = Seq( + s"""> sugsyn""" + ), + desc = + s"Issues ${y("'model/sugsyn'")} REST call with default min score and default model ID " + + s"(single connected probe that has a single deployed model)." ) ) ),
