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?

1 Answer 1

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')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.