动作
操作让角色决定在你的场景中做什么。你在连接时声明可用的功能;角色会根据对话决定何时以及要做什么。
1. 配置 actionConfig 在连接时
actionConfig 在连接时const client = useConvaiClient({
apiKey: '...',
characterId: '...',
actionConfig: {
// 角色可以发出的动作名称
actions: ['Move To', 'Pick Up', 'Drop', 'Follow', 'Wave', 'Attack'],
// 场景中角色可以作用的对象
objects: [
{ name: 'sword', description: '地上的一把锋利钢剑' },
{ name: 'chest', description: '角落里的一个木制宝箱' },
{ name: 'torch', description: '墙上的一支燃烧火把' },
],
// 机器人可以引用或作用的其他角色
characters: [
{ name: 'Player', bio: '当前用户' },
{ name: 'Guard', bio: '附近的一名守卫 NPC' },
],
// 可选:角色开始时关注的对象
current_attention_object: 'sword',
},
});2. 接收 actionResponse
actionResponse3. 在运行时更新关注点
4. 更新描述性场景上下文
5. 以编程方式触发动作
完整示例
API 参考
actionConfig (connect 选项)
actionConfig (connect 选项)字段
类型
描述
actionResponse 事件
actionResponse 事件updateContext (attention)
updateContext (attention)字段
类型
描述
updateSceneMetadata(items)
updateSceneMetadata(items)字段
类型
描述
sendTriggerMessage(triggerName?, triggerMessage?)
sendTriggerMessage(triggerName?, triggerMessage?)最后更新于
这有帮助吗?