0

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?

Ryuhei
  • 1

1 Answers1

1

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')
Alexwei
  • 11
  • 1