File size: 677 Bytes
f75296e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from flask import Flask, render_template, request, jsonify
from getans import get_response

app = Flask(__name__)

# Store chat history
chat_history = []


@app.route('/')
def index():
    return render_template('index.html', chat_history=chat_history)


@app.route('/send_message', methods=['POST'])
def send_message():
    user_message = request.form['message']
    # Here you can process the user message and generate a response
    bot_response = get_response(user_message, max_new_tokens=100).toString()
    chat_history.append({'user': user_message, 'bot': bot_response})
    return jsonify(chat_history=chat_history)


if __name__ == '__main__':
    app.run(debug=True)