Spaces:
Running
Running
from flask import Flask, request, render_template, jsonify | |
from models import gpt2 as chatbot | |
app = Flask("AI API") | |
print("Loading model") | |
chatbot.load() | |
def read_root(): | |
return render_template("index.html") | |
def test_route(): | |
return "This is a test route." | |
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) |