我在Heroku上部署我的python程序,用于我的api.ai机器人的余弦计算。但是,在我得到cos的值并将值放在math.cos(value)
函数中之后,api.ai将给出
"errorDetails": "Webhook call failed. Error: Webhook response was empty."
但如果我不使用math.cos()
,程序将返回webhook响应。
计算代码:
def trig():
req = request.get_json(silent=True, force=True)
result = req.get("result")
parameters = result.get("parameters")
number = parameters.get("number")
trig_sign = parameters.get("Trigonometry")
number = float(number)
if trig_sign == "Cos":
out = "The answer is "+ str(math.cos(number)) +" !"
speechText = out
displayText = out
print("Response:")
print(out)
return {
"speech": speechText,
"displayText": displayText,
"source": "pas-robot-math-calculator"
}
如果我没有输入math.cos()
,程序将会起作用def trig():
req = request.get_json(silent=True, force=True)
result = req.get("result")
parameters = result.get("parameters")
number = parameters.get("number")
trig_sign = parameters.get("Trigonometry")
number = float(number)
#I did not put math.cos() here
out = "The answer is !"
speechText = out
displayText = out
print("Response:")
print(out)
return {
"speech": speechText,
"displayText": displayText,
"source": "pas-robot-math-calculator"
}