用户注意力流 (attention.co)#

处理用户注意力的流。

tracking user attention

为了自动处理用户注意力事件,您需要激活此流以跟踪用户在上一次话语期间的注意力水平。此信息将用于更改所有 user said 流的功能,以便当用户在不专心时说话时,这些流将不再完成。

示例

import core
import attention

flow main
     # Activate the flow at the beginning to make sure user attention events are tracked properly
     activate tracking user attention

     ...
user said (overwritten)

当您在您的 bot 文件夹中包含 attention.co 时,它会覆盖所有 user said 相关流,以便这些流仅在用户专心时才考虑用户的说话。您可以通过覆盖下面解释的 attention checks 流来覆盖默认的注意力检查。对于您的第一次测试,默认实现应该在 Tokkio 设置下工作良好。

示例

import core
import attention

flow main
     activate tracking user attention

     # Since the attention module overwrites all user said related flows, this line will wait until the user says
     # something while being attentive.
     user said something
     bot say "I heard you and you are attentive"
attention checks $event -> $is_attentive

当系统需要决定用户的说话是否在用户专心时完成时,将调用 attention checks 流。您可以通过在您的 bot 脚本中覆盖此流来覆盖默认行为。

示例

import core
import attention

@override
flow attention checks $event -> $is_attentive
     # Implement your custom attention logic here
     $is_attentive = True
     return $is_attentive
user said something inattentively

用户在不专心时说了一些话。使用此流来告知用户,bot 假设用户不专心,并且该话语将被忽略。

示例

import core
import attention
import avatar # Only needed for the optional bot gesture we use below

flow main
     activate tracking user attention
     when user said something
          bot say "I hear you"
     or when user said something inattentively
          bot say "You seem distracted. Can you repeat?" and bot gesture "asking if something refers to them, being unsure if they're being addressed"