我正在使用rasa(最新版本),但是由于handle_channel方法而无法将响应发送到chatbot,现在我遇到以下错误
"error": "Object of type coroutine is not JSON serializable"
这是我的代码,我错了吗?
@app.route('/api/v1/<sender_id>/respond', methods=['GET', 'POST'])
def respond(self, request, sender_id):
request.setHeader('Content-Type', 'application/json')
request.setHeader('Access-Control-Allow-Origin', '*')
request_params = request_parameters(request)
if 'query' in request_params:
message = request_params.pop('query')
elif 'q' in request_params:
message = request_params.pop('q')
else:
request.setResponseCode(400)
return json.dumps({"error": "Invalid parse parameter specified"})
try:
out = CollectingOutputChannel()
response = self.agent.handle_message(message, output_channel=out, sender_id=sender_id)
request.setResponseCode(200)
return json.dumps(response)
except Exception as e:
request.setResponseCode(500)
logger.error("Caught an exception during "
"parse: {}".format(e), exc_info=1)
return json.dumps({"error": "{}".format(e)})
答案 0 :(得分:0)
确定要在此处混合使用各种方法吗?根据{{3}},您可能想尝试:
const { app, BrowserWindow, autoUpdater } = require('electron');
const os = require("os");
app.on('ready', () => {
console.log(os.arch()); // print architecture
console.log(os.platform()); // print system platform
createBrowserWindow();
});
或
handle_message(message, message_preprocessor=None, **kwargs)
请记住要导入正确的库,因为自1.0以来已进行了重命名,以防万一。