我正在用Python和JavaScript制作一个聊天机器人程序。我使用eel为chatbot创建UI,但python代码中公开的函数不能用于JavaScript代码
Python代码
@eel.expose
def responsedMessage(message):
word = tokenize(message)
if not word == '@':
reply = load_w2v(word)
else:
reply = ''
response = make_sentence(reply)
return response
JavaScript
async function btnFunc(){
if(!inputText.value) return false;
output(inputText.value,'me');
const response = await eel.responsedMessage(inputText.value);
output(response,'robot');
}
错误
chatbot_js.html:60 Uncaught (in promise) TypeError: eel.responsedMessage is not a function
at btnFunc (chatbot_js.html:60)
at HTMLInputElement.onclick (chatbot_js.html:16)
为什么会发生这种错误
您应该将eel.start('main.html')放在python脚本的末尾
相关问题 更多 >
编程相关推荐