I'm in the process of making a chatbot program with Python and JavaScript. I use eel to make the UI for chatbot, but exposed function from python code can't be used in JavaScript Code.
Python Code
@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');
}
Error
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)
Why is this error happened?
you should put the eel.start('main.html') at the end of your python script
@eel.expose
def responsedMessage(message):
word = tokenize(message)
if not word == '@':
reply = load_w2v(word)
else:
reply = ''
response = make_sentence(reply)
return response
eel.start('main.html')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.