
[英]AWS Lex bot calling a lambda function in fulfilment section of the lex bot, I don't see a place to call the lambda function
[英]AWS LEX: Slot update, intent update and then new publishing bot through a Lambda function
我正在写一个 lambda function,它有一个我想放入 slotType 的单词数组,基本上每次都更新它。 这是怎么回事。 最初,slotType 的值为 ['car', 'bus']。 下次我运行 lambda function 时,值会更新为 ['car', 'bus', 'train', 'flight'] ,这基本上是在将新数组附加到旧数组之后。
我想知道每次调用 Lambda function 时我是如何发布机器人的,所以下次我从前端点击 lex 机器人时,它会在意图中使用最新的 slotType 和新发布的机器人别名。 是的,还有别名!
我知道put_slot_type()
正在工作,因为插槽正在机器人中更新。
这是 function,它基本上将新标签作为参数。
def lex_extend_slots(new_labels):
print('entering lex model...')
lex = boto3.client('lex-models')
slot_name = 'keysDb'
intent_name = 'searchKeys'
bot_name = 'photosBot'
res = lex.get_slot_type(
name = slot_name,
version = '$LATEST'
)
current_labels = res['enumerationValues']
latest_checksum = res['checksum']
arr = [x['value'] for x in current_labels]
labels = arr + new_labels
print('arry: ', arr)
print('new_labels', new_labels)
print('labels in lex: ', labels)
labels = list(set(labels))
enumerationList = [{'value': label, 'synonyms': []} for label in labels]
print('getting ready to push enum..: ', enumerationList)
res_slot = lex.put_slot_type(
name = slot_name,
description = 'updated slots...',
enumerationValues = enumerationList,
valueSelectionStrategy = 'TOP_RESOLUTION',
)
res_build_intent = lex.create_intent_version(
name = intent_name
)
res_build_bot = lex.create_bot_version(
name = bot_name,
checksum = latest_checksum
)
return current_labels
看起来您在 Boto3 上使用 Lex 模型 API 的版本 1。
您可以使用lex-models
客户端中的put_bot
方法来有效地创建或更新您的 Lex bot。
put_bot
方法需要完整的意图列表来构建机器人。 值得一提的是,您首先需要使用put_intent
来更新您的意图,以确保它们使用您更新后的 slotType 的最新版本。
这是put_intent
的文档。
创建和更新别名的适当方法包含在我上面共享的同一链接中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.