Spaces:
Sleeping
Sleeping
File size: 595 Bytes
93a2217 5f6d4f4 e3db2f8 93a2217 207c16a 5292931 5f6d4f4 bf5c1c9 93a2217 c36c2b7 93a2217 207c16a 1bf6c59 93a2217 22cf642 5f6d4f4 9920987 93a2217 9920987 f0ed1e5 93a2217 5e6c5aa |
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 |
from flask import Flask, request, render_template, jsonify
from models import gpt2 as chatbot
app = Flask("AI API")
print("Loading model")
chatbot.load()
@app.get("/")
def read_root():
return render_template("index.html")
@app.route("/test")
def test_route():
return "This is a test route."
@app.route("/api")
def receive_data():
data = request.get_json()
print("Prompt:", data["prompt"])
generated_text = chatbot.generate(data["prompt"])
print("Response:", generated_text)
return jsonify({ "answer": generated_text })
app.run(host="0.0.0.0", port=7860, debug=False) |