from flask import Flask, request, render_template, jsonify from models import hermes app = Flask("AI API") @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", methods=["POST"]) def receive_data(): data = request.get_json() print("Prompt:", data["prompt"]) messages = [] if data["system"]: messages.append({"role": "system", "content": data["system"] }) messages.append( { "role": "user", "content": data["prompt"] } ) generated_text = hermes.generate(messages) print("Response:", generated_text) return jsonify({ "answer": generated_text }) app.run(host="0.0.0.0", port=7860, debug=False)