minor bug fixes
Browse files- ChitChat/__init__.py +1 -1
- ChitChat/common/utils.py +4 -3
- ChitChat/config.py +4 -1
- ChitChat/resources/routes.py +11 -9
- instance/site.db +0 -0
ChitChat/__init__.py
CHANGED
|
@@ -9,7 +9,7 @@ bcrypt = Bcrypt()
|
|
| 9 |
def create_app(config_class = Config):
|
| 10 |
app = Flask(__name__)
|
| 11 |
CORS(app)
|
| 12 |
-
app.config.from_object(
|
| 13 |
db.init_app(app)
|
| 14 |
bcrypt.init_app(app)
|
| 15 |
|
|
|
|
| 9 |
def create_app(config_class = Config):
|
| 10 |
app = Flask(__name__)
|
| 11 |
CORS(app)
|
| 12 |
+
app.config.from_object(config_class)
|
| 13 |
db.init_app(app)
|
| 14 |
bcrypt.init_app(app)
|
| 15 |
|
ChitChat/common/utils.py
CHANGED
|
@@ -1,9 +1,10 @@
|
|
| 1 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 2 |
from transformers import T5Tokenizer, T5ForConditionalGeneration
|
| 3 |
import torch
|
| 4 |
-
from flask import current_app
|
| 5 |
from ChitChat import db
|
| 6 |
-
|
|
|
|
| 7 |
|
| 8 |
small_model_name = 'Th3BossC/DialoGPT-medium-AICLUB_NITC'
|
| 9 |
default_model = 'microsoft/DialoGPT-medium'
|
|
@@ -68,4 +69,4 @@ def complexChat(userInput):
|
|
| 68 |
top_k = 150,
|
| 69 |
top_p = 0.92,
|
| 70 |
repetition_penalty = 2.1)
|
| 71 |
-
return large_tokenizer.decode(outputs[0], skip_special_tokens = True)
|
|
|
|
| 1 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 2 |
from transformers import T5Tokenizer, T5ForConditionalGeneration
|
| 3 |
import torch
|
| 4 |
+
from flask import current_app, session
|
| 5 |
from ChitChat import db
|
| 6 |
+
import numpy as np
|
| 7 |
+
import pandas as pd
|
| 8 |
|
| 9 |
small_model_name = 'Th3BossC/DialoGPT-medium-AICLUB_NITC'
|
| 10 |
default_model = 'microsoft/DialoGPT-medium'
|
|
|
|
| 69 |
top_k = 150,
|
| 70 |
top_p = 0.92,
|
| 71 |
repetition_penalty = 2.1)
|
| 72 |
+
return large_tokenizer.decode(outputs[0], skip_special_tokens = True)
|
ChitChat/config.py
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
|
|
|
|
|
| 1 |
class Config:
|
| 2 |
SECRET_KEY = '7a2b25ca707a5be465f9a8894f528999'
|
| 3 |
SQLALCHEMY_DATABASE_URI = 'sqlite:///site.db'
|
| 4 |
-
SAVE_FOLDER = 'ChitChat/common/files/'
|
|
|
|
|
|
| 1 |
+
from datetime import timedelta
|
| 2 |
+
|
| 3 |
class Config:
|
| 4 |
SECRET_KEY = '7a2b25ca707a5be465f9a8894f528999'
|
| 5 |
SQLALCHEMY_DATABASE_URI = 'sqlite:///site.db'
|
| 6 |
+
SAVE_FOLDER = 'ChitChat/common/files/'
|
| 7 |
+
# PERMENANT_SESSION_LIFETIME = timedelta(minutes = 180)
|
ChitChat/resources/routes.py
CHANGED
|
@@ -1,25 +1,32 @@
|
|
| 1 |
-
from flask import Blueprint, request,
|
| 2 |
from flask_restful import Api, Resource
|
| 3 |
from ChitChat.models import User
|
| 4 |
from ChitChat import bcrypt, db
|
| 5 |
from ChitChat.common.utils import conversation, complexChat
|
| 6 |
-
|
| 7 |
resources = Blueprint('resources', __name__)
|
| 8 |
api = Api(resources)
|
| 9 |
|
| 10 |
|
| 11 |
class UserLogin(Resource):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
def post(self):
|
| 13 |
userInfo = request.json
|
| 14 |
user = User.query.filter_by(username = userInfo['username']).first()
|
| 15 |
|
|
|
|
|
|
|
|
|
|
| 16 |
if user is None:
|
| 17 |
return {'status' : "Account doesn't exist", 'user_id' : None}
|
| 18 |
elif bcrypt.check_password_hash(pw_hash = user.password, password = userInfo['password']):
|
| 19 |
return {'status' : "login successful", 'user_id' : str(user.id)}
|
| 20 |
else:
|
| 21 |
return {'status' : "Invalid password", 'user_id' : None}
|
| 22 |
-
api.add_resource(UserLogin, '/login
|
| 23 |
|
| 24 |
class RegisterUser(Resource):
|
| 25 |
def post(self):
|
|
@@ -37,7 +44,7 @@ class RegisterUser(Resource):
|
|
| 37 |
db.session.add(newUser)
|
| 38 |
db.session.commit()
|
| 39 |
return {'status' : 'User created successfully'}
|
| 40 |
-
api.add_resource(RegisterUser, '/register
|
| 41 |
|
| 42 |
|
| 43 |
class ChatBot(Resource):
|
|
@@ -58,8 +65,3 @@ class ComplexChatBot(Resource):
|
|
| 58 |
reply = complexChat(userInput)
|
| 59 |
return {'reply' : reply}
|
| 60 |
api.add_resource(ComplexChatBot, '/chat/smartbot/')
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
|
|
|
| 1 |
+
from flask import Blueprint, request, session
|
| 2 |
from flask_restful import Api, Resource
|
| 3 |
from ChitChat.models import User
|
| 4 |
from ChitChat import bcrypt, db
|
| 5 |
from ChitChat.common.utils import conversation, complexChat
|
| 6 |
+
import secrets
|
| 7 |
resources = Blueprint('resources', __name__)
|
| 8 |
api = Api(resources)
|
| 9 |
|
| 10 |
|
| 11 |
class UserLogin(Resource):
|
| 12 |
+
def get(self):
|
| 13 |
+
user_id = request.args.get('user_id')
|
| 14 |
+
return {'username' : User.query.get(int(user_id)).username}
|
| 15 |
+
|
| 16 |
def post(self):
|
| 17 |
userInfo = request.json
|
| 18 |
user = User.query.filter_by(username = userInfo['username']).first()
|
| 19 |
|
| 20 |
+
if user is None:
|
| 21 |
+
user = User.query.filter_by(email = userInfo['username']).first()
|
| 22 |
+
|
| 23 |
if user is None:
|
| 24 |
return {'status' : "Account doesn't exist", 'user_id' : None}
|
| 25 |
elif bcrypt.check_password_hash(pw_hash = user.password, password = userInfo['password']):
|
| 26 |
return {'status' : "login successful", 'user_id' : str(user.id)}
|
| 27 |
else:
|
| 28 |
return {'status' : "Invalid password", 'user_id' : None}
|
| 29 |
+
api.add_resource(UserLogin, '/login')
|
| 30 |
|
| 31 |
class RegisterUser(Resource):
|
| 32 |
def post(self):
|
|
|
|
| 44 |
db.session.add(newUser)
|
| 45 |
db.session.commit()
|
| 46 |
return {'status' : 'User created successfully'}
|
| 47 |
+
api.add_resource(RegisterUser, '/register')
|
| 48 |
|
| 49 |
|
| 50 |
class ChatBot(Resource):
|
|
|
|
| 65 |
reply = complexChat(userInput)
|
| 66 |
return {'reply' : reply}
|
| 67 |
api.add_resource(ComplexChatBot, '/chat/smartbot/')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
instance/site.db
CHANGED
|
Binary files a/instance/site.db and b/instance/site.db differ
|
|
|