嵌套输入组

Nesting input-groups

因此,对于我的一项操作,我需要来自用户的以下输入组合:

A 或 (BAND\ORC)

或者:

A 或(B 和 C)或(B 或 C)

因此以下是有效的输入组合:

一个

B

C

B & C

我已尝试执行以下操作:

action (blah) {
  description (blah)
  type (blah)
  collect {
    input-group (inputs) {
      requires (OneOf)
      collect {
        input (a) {
          type (A)
          max (One)
        }
        input-group (bAndOrC) {
          requires (OneOrMoreOf)
          collect {
            input (b) {
              type (B)
              max (One)
            }
            input (c) {
              type (C)
              max (One)
            }
          }
        }
      }
    }
  }
  output (blah)
}

但是这给了我一个错误 "illegal combination of max-one constraint (inputs) and min-required member (bAndOrC)"。

如果我将 OneOrMoreOf 更改为 ZeroOrMoreOf,此错误就会消失。然而,这似乎意味着用户无法提供任何输入,并且将被视为有效。或者也许我误解了,外部 input-group 中的 OneOf 是内部 input-group 中的 "inherited",因此它实际上是 OneOrMoreOf?

最简单的方法是执行 2 个操作:

  • Action1 将接受 A 作为唯一输入
  • Action2 将有一个 input-group,需要 OneOrMoreOf 并收集 B 和 C 作为组内的输入。

这两个操作将正确处理输入 A、B、C 和 B&C。

在训练文件中训练多种类型的话语非常重要,以确保 Bixby 有足够的上下文来区分 InputA、InputB 和 InputC 值。

例如,"Input A is 12" 和 "A is 12" 都应该接受训练,以教导 Bixby 上下文更多地在于 "A" 而不是其他任何东西。

Action1 模型:

action (Action1) {
  type (Search)
  description (__DESCRIPTION__)

  collect {
    input (inputA) {
      type (InputA)
      min (Required) max (One)
    }
  }
  output (GenericOutput)
}

Action2 模型:

action (Action2) {
  type (Search)
  description (__DESCRIPTION__)
  collect {
    input-group (BAndOrC) {
      requires (OneOrMoreOf)
      collect {
        input (inputB) {
          type (InputB)
          min (Optional) max (One)
        }
        input (inputC) {
          type (InputC)
          min (Optional) max (One)
        } 
      }
    }
  }
  output (GenericOutput)
}

所以事实证明嵌套在 OneOf 中的 ZeroOrMoreOf 有效地将它变成了 OneOrMoreOf。在模拟器中,如果我没有提供任何输入,它会提示我输入而不是尝试在没有输入的情况下完成操作。

但是,我 运行 遇到的另一个问题是,在某些情况下,如果提供的输入过多,Bixby 无法正确列出有效输入以供用户选择。例如,如果输入是 a1、a2、a3,就可以了。在这种情况下,它会提示用户 select 三者之一。例如,如果输入是 b1、b2、c1、c2,它也可以正常工作。在这种情况下,它会提示用户对 B 输入之一和 C 输入之一进行 select。但是,如果输入是例如 a1、b1、c1,它会选择输入 a1,而忽略 b1 和 c1 而无需提示。如果输入是 a1, a2, b1, c1,它会提示用户在 a1 和 a2 之间进行选择,完全忽略 b1 和 c1。为了解决这个问题,我创建了一个初步动作,它接受 A、B 和 C 的任意组合和数量,然后输出所有可能的组合供用户选择,然后将其用作实际动作的输入。所以我的初步行动看起来像

action (preliminary) {
  description (blah)
  type (blah)
  collect {
    input-group (inputs) {
      requires (OneOrMoreOf)
      collect {
        input (a) {
          type (A)
          max (Many)
        }
        input (b) {
          type (B)
          max (Many)
        }
        input (c) {
          type (C)
          max (Many)
        }
      }
    }
  }
  output (PreliminaryOutput)
}

此操作的 Javascript 将生成一个可供用户选择的可能选项列表。例如,如果输入是 a1、a2、b1、b2、c1、c2,它将列出:

a1

a2

b1 c1

b1 c2

b2 c1

b2 c2

用户会选择其中一项进入实际操作:

action (actual) {
  description (blah)
  type (blah)
  collect {
    input (preliminary) {
      type (PreliminaryOutput)
      min (Required)
      max (One)
    }
  output (RealOutput)
}