多模态 Rails
本节介绍如何在 Colang 2.0 中创建多模态 rails。
定义
多模态 rails 是一种考虑多种类型输入/输出模态(例如,文本、语音、手势、姿势、图像)的 rails。
用法
下面的示例展示了如何控制交互式化身的问候行为。
注意
Colang 标准库 (CSL) 包括一个 avatars 模块,其中包含用于多模态事件和操作的流程,以实现交互式化身用例。
examples/v2_x/tutorial/multi_modal/main.co
1import core
2import avatars
3
4flow main
5 user expressed greeting
6 bot express greeting
7
8flow user expressed greeting
9 user expressed verbal greeting
10 or user gestured "Greeting gesture"
11
12flow user expressed verbal greeting
13 user said "hi"
14 or user said "hello"
15
16flow bot express greeting
17 bot express verbal greeting
18 and bot gesture "Smile and wave with one hand."
19
20flow bot express verbal greeting
21 bot say "Hi there!"
22 or bot say "Welcome!"
23 or bot say "Hello!"
在上面的流程中,第 9 行和第 17 行使用预定义的流程 user gestured
和 bot gesture
,它们匹配用户手势并控制机器人手势。
幕后原理
在幕后,使用上面 Colang 脚本的交互式系统需要生成 GestureUserActionFinished
事件(这是 user gestured
流程正在等待的事件),并知道如何处理 StartGestureBotAction
事件(这是 bot gesture
流程触发的事件)。
测试
要使用 NeMo Guardrails CLI 测试上述逻辑,您可以手动发送事件,方法是以 /
开头消息
$ nemoguardrails chat --config=examples/v2_x/tutorial/guardrails_1
> hi
Welcome!
Gesture: Smile and wave with one hand.
> /GestureUserActionFinished(gesture="Greeting gesture")
Hi there!
Gesture: Smile and wave with one hand.
下一个示例 将向您展示如何定义输入 rails。