Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I am new in python please provide me a code for using the chatbot I finish the training and I want to use it in discord how to use the training model? #46

Open
bag7dad opened this issue Dec 4, 2019 · 6 comments

Comments

@bag7dad
Copy link

bag7dad commented Dec 4, 2019

No description provided.

@bag7dad
Copy link
Author

bag7dad commented Dec 4, 2019

I don't need discord bot code I just want the method for using Your script I have knowledge in other languages programing

@carlitoselmago
Copy link

carlitoselmago commented Dec 4, 2020

@medozeus here's a code you can addapt, mine is a simple terminal chatbot interface

import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
from main import * # import the main python file with model from the example
import time


load_weights = tl.files.load_npz(name='saved/model.npz')
tl.files.assign_weights(load_weights, model_)


def respond(input):
    sentence = inference(input, 3)
    response=' '.join(sentence)
    return response

while True:
    userInput=input("user# ")
    time.sleep(0.5)
    print("bot# ",respond(userInput))

@Radioactivebun0
Copy link

@carlitoselmago I copied and pasted your code into a file named "chatbot.py" with model.npz in a folder named "saved". chatbot.py and "main.py" are in the same folder.
When I run your code, I get this error:

C:\Users\tjpet\Downloads\seq2seq-chatbot-master\seq2seq-chatbot-master>py chatbot.py
Traceback (most recent call last):
  File "chatbot.py", line 8, in <module>
    tl.files.assign_weights(load_weights, model_)
NameError: name 'model_' is not defined

@carlitoselmago
Copy link

carlitoselmago commented Dec 5, 2020

@Radioactivebun0 that because there's some problem importing main.py file. try to add an empty file called

__init__.py

in the folder where both main.py and chatbot.py are located.

@jessedoka
Copy link

@carlitoselmago I ran into the same error and I have created a __init__.py but I am still falling into this error.

@jessedoka
Copy link

I figured it out!
I figured was that model_ and inference() is defined in main.py, but that only when __name__ == "__main__" so it did not exist when I ran my file e.g chatbot.py so I took the following outside the if __name__ == "__main__": ; data pre-processing, parameters, and other variables including the inference function.
I am not sure if this harms any of the code in main.py though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants