Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,25 +1,25 @@
|
|
| 1 |
-
from flask import Flask, render_template, request, jsonify
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
app = Flask(__name__)
|
| 5 |
-
|
| 6 |
-
# Store chat history
|
| 7 |
-
chat_history = []
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
@app.route('/')
|
| 11 |
-
def index():
|
| 12 |
-
return render_template('index.html', chat_history=chat_history)
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
@app.route('/send_message', methods=['POST'])
|
| 16 |
-
def send_message():
|
| 17 |
-
user_message = request.form['message']
|
| 18 |
-
# Here you can process the user message and generate a response
|
| 19 |
-
bot_response =
|
| 20 |
-
chat_history.append({'user': user_message, 'bot': bot_response})
|
| 21 |
-
return jsonify(chat_history=chat_history)
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
if __name__ == '__main__':
|
| 25 |
-
app.run(debug=True)
|
|
|
|
| 1 |
+
from flask import Flask, render_template, request, jsonify
|
| 2 |
+
from getans import get_response
|
| 3 |
+
|
| 4 |
+
app = Flask(__name__)
|
| 5 |
+
|
| 6 |
+
# Store chat history
|
| 7 |
+
chat_history = []
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
@app.route('/')
|
| 11 |
+
def index():
|
| 12 |
+
return render_template('index.html', chat_history=chat_history)
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
@app.route('/send_message', methods=['POST'])
|
| 16 |
+
def send_message():
|
| 17 |
+
user_message = request.form['message']
|
| 18 |
+
# Here you can process the user message and generate a response
|
| 19 |
+
bot_response = get_response(user_message, max_new_tokens=100).toString()
|
| 20 |
+
chat_history.append({'user': user_message, 'bot': bot_response})
|
| 21 |
+
return jsonify(chat_history=chat_history)
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
if __name__ == '__main__':
|
| 25 |
+
app.run(debug=True)
|