Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,23 +0,0 @@
|
|
| 1 |
-
from transformers import pipeline
|
| 2 |
-
from flask import Flask, request, jsonify
|
| 3 |
-
|
| 4 |
-
app = Flask(__name__)
|
| 5 |
-
|
| 6 |
-
# Load chatbot model
|
| 7 |
-
chatbot = pipeline("text-generation", model="microsoft/DialoGPT-medium")
|
| 8 |
-
|
| 9 |
-
@app.route("/chat", methods=["POST"])
|
| 10 |
-
def chat():
|
| 11 |
-
user_input = request.json.get("message")
|
| 12 |
-
if not user_input:
|
| 13 |
-
return jsonify({"error": "No message provided"}), 400
|
| 14 |
-
|
| 15 |
-
response = chatbot(user_input, max_length=100)[0]["generated_text"]
|
| 16 |
-
return jsonify({"response": response})
|
| 17 |
-
|
| 18 |
-
@app.route("/", methods=["GET"])
|
| 19 |
-
def home():
|
| 20 |
-
return "BIT-GPT 0.2.8 is running!"
|
| 21 |
-
|
| 22 |
-
if __name__ == "__main__":
|
| 23 |
-
app.run(host="0.0.0.0", port=7860)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|