forked from slippersheepig/chatgpt-html
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
32 lines (25 loc) · 737 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import json
from revChatGPT.V1 import Chatbot
from flask import Flask, request, render_template
server = Flask(__name__)
# get config
with open("config.json", "r") as f: config = json.load(f)
# init chatbot
chatbot = Chatbot(config)
def generate_response(prompt):
try:
for data in chatbot.ask(prompt):
response = data["message"]
return response
except Exception as e:
return e
@server.route("/")
def home():
chatbot.reset_chat()
return render_template("chat.html")
@server.route("/get")
def get_bot_response():
user_text = request.args.get('msg')
return str(generate_response(user_text))
if __name__ == '__main__':
server.run(debug=False, host='0.0.0.0', port=8088)