Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,18 +7,21 @@ app = Flask(__name__)
|
|
| 7 |
@app.route("/ask", methods=["POST"])
|
| 8 |
def ask_question():
|
| 9 |
try:
|
| 10 |
-
|
|
|
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
print(">>> JSON:", request.get_json())
|
| 15 |
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
except Exception as e:
|
| 18 |
-
print("
|
| 19 |
return jsonify({"error": str(e)}), 500
|
| 20 |
|
| 21 |
-
|
| 22 |
@app.route("/", methods=["GET"])
|
| 23 |
def index():
|
| 24 |
return "Flan5 Memorease Docker Space is running!", 200
|
|
|
|
| 7 |
@app.route("/ask", methods=["POST"])
|
| 8 |
def ask_question():
|
| 9 |
try:
|
| 10 |
+
input_text = request.json.get("text")
|
| 11 |
+
print("INPUT:", input_text)
|
| 12 |
|
| 13 |
+
if not input_text:
|
| 14 |
+
return jsonify({"error": "Missing 'text'"}), 400
|
|
|
|
| 15 |
|
| 16 |
+
client = Client("memorease/memorease-flan-t5")
|
| 17 |
+
result = client.predict(input_text, api_name="/predict")
|
| 18 |
+
|
| 19 |
+
print("RESULT:", result)
|
| 20 |
+
return jsonify({"question": result})
|
| 21 |
except Exception as e:
|
| 22 |
+
print("SERVER ERROR:", str(e))
|
| 23 |
return jsonify({"error": str(e)}), 500
|
| 24 |
|
|
|
|
| 25 |
@app.route("/", methods=["GET"])
|
| 26 |
def index():
|
| 27 |
return "Flan5 Memorease Docker Space is running!", 200
|