gpt4 book ai didi

python - flask-ask 插槽总是被映射到 None

转载 作者:太空狗 更新时间:2023-10-29 21:11:43 26 4
gpt4 key购买 nike

我的自定义 intent 插槽始终被识别为

我有一个如下所示的 intent 架构:

{
"interactionModel": {
"languageModel": {
"invocationName": "name_of_app",
"intents": [
{
"name": "AMAZON.CancelIntent",
"samples": []
},
{
"name": "AMAZON.HelpIntent",
"samples": []
},
{
"name": "AMAZON.StopIntent",
"samples": []
},
{
"name": "EventsIntent",
"slots": [
{
"name": "eventCity",
"type": "AMAZON.GB_CITY"
}
],
"samples": [
"whats on in {eventCity}",
"whats going on in {eventCity} ",
"tell me what events are in {eventCity}"
]
}
],
"types": []
}
}
}

我的代码是在 python 中,使用 flask-ask 框架。我的主要入口点看起来像这样:

@ask.launch
def start_skill():
welcome_message = 'Welcome to name_of_app, what do you want?'
return question(welcome_message)

@ask.intent('EventsIntent', mapping={'city': 'eventCity'})
def weather(city):
return statement('you have selected {}'.format(city))

即使是这个简单的例子,当输入是:

"whats on in London?"

我在亚马逊开发者控制台的测试面板中尝试使用小写字母和带/不带标点符号,但返回始终是:

"you have selected None"

表示 None 作为“eventCity”传递。我是否在 intent 模式或代码中错误地传递了这个插槽?

谢谢

最佳答案

嘿,伙计,以下是您问题的解决方案:

@ask.launch
def start_skill():
welcome_message = 'Welcome to name_of_app, what do you want?'
return question(welcome_message)

@ask.intent('EventsIntent', convert={'eventCity': str})
def weather(eventCity):
return statement('you have selected {}'.format(eventCity))

我也遇到了类似的问题,这件事解决了我的问题。

关于python - flask-ask 插槽总是被映射到 None,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49989604/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com