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

用于处理用户注意力的流。

跟踪 用户 注意力

要自动处理用户注意力事件,您需要激活此流以跟踪上次用户话语期间的用户注意力水平。此信息将用于改变所有 用户 说过 流的功能,以便在用户注意力不集中时说话时,这些流不再结束。

示例

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

     ...
用户 说过 (已覆盖)

当您在 Bot 文件夹中包含 attention.co 时,它会覆盖所有与 用户 说过 相关的流,以便这些流只在用户注意力集中时考虑用户话语。您可以通过覆盖下面解释的 注意力 检查 流来覆盖默认的注意力检查。对于您的首次测试,默认实现应该与 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"
注意力 检查 $event -> $is_attentive

每当系统需要决定用户话语是否在用户注意力集中时完成时,都会调用 注意力 检查 流。您可以通过在您的 Bot 脚本中覆盖此流来覆盖默认行为。

示例

import core
import attention

@override
flow attention checks $event -> $is_attentive
     # Implement your custom attention logic here
     $is_attentive = True
     return $is_attentive
用户 注意力不集中时 说了 点什么

用户在注意力不集中时说了点什么。使用此流告知用户 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"