我在python lambda hand中找不到回调参数

2024-05-08 11:32:47 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在为aws lambda-lex学习,我发现coffee bot示例代码节点.js. 在

// --------------- Main handler -----------------------
// --------------- in node.js -----------------------

// Route the incoming request based on intent.
// The JSON body of the request is provided in the event slot.

exports.handler = (event, context, callback) => {
    try {
        dispatch(event, (response) => callback(null, response));
    } catch (err) {
        callback(err);
    }
};

我想要使用回调参数,但在python中找不到它

^{pr2}$

如果你需要的话,比较一下

python docsnode.js docs


实际上我想得到这个函数(构建消息到lex)

callback(elicitSlot(outputSessionAttributes, intentRequest.currentIntent.name, slots, 'BeverageType', 
                buildMessage('Sorry, but we can only do a mocha or a chai. What kind of beverage would you like?'), 
                buildResponseCard("Menu", "Today's Menu", menuItem)));

完整的示例代码在这里(https://github.com/awslabs/amz-ai-building-better-bots/blob/master/src/index.js

有人能帮我吗?在


Tags: ofthe代码ineventnode示例docs
1条回答
网友
1楼 · 发布于 2024-05-08 11:32:47

使用回调是NodeJS中用于管理异步执行的一种模式。在Python中不需要它(对于这个特定的用例)。在

NodeJS中的这个片段。。。在

callback(null, response)

相当于

^{2}$

在Python中。在

相关问题 更多 >