File size: 646 Bytes
fb83134
 
f11cd81
fb83134
f11cd81
fb83134
 
f11cd81
fb83134
 
 
 
 
 
 
 
f11cd81
fb83134
 
 
f11cd81
 
fb83134
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from transformers import pipeline
from flask import Flask, request, jsonify

app = Flask(__name__)

# Load chatbot model
chatbot = pipeline("text-generation", model="microsoft/DialoGPT-medium")

@app.route("/chat", methods=["POST"])
def chat():
    user_input = request.json.get("message")
    if not user_input:
        return jsonify({"error": "No message provided"}), 400
    
    response = chatbot(user_input, max_length=100)[0]["generated_text"]
    return jsonify({"response": response})

@app.route("/", methods=["GET"])
def home():
    return "BIT-GPT 0.2.8 is running!"

if __name__ == "__main__":
    app.run(host="0.0.0.0", port=7860)