Spaces:
Runtime error
Runtime error
from flask import Flask, render_template, request | |
app = Flask(__name__) | |
API_URL2 = "https://api-inference.huggingface.co/models/valhalla/longformer-base-4096-finetuned-squadv1" | |
headers2 = {"Authorization": "Bearer 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"} | |
def query2(payload): | |
response = requests.post(API_URL2, headers=headers2, json=payload) | |
return response.json() | |
def home(): | |
answer = "" | |
if request.method == "POST": | |
question = request.form["question"] | |
context = request.form["context"] | |
output2 = query2({ | |
"inputs": { | |
"question": question, | |
"context": context | |
}, | |
}) | |
answer = output2["answer"] | |
return render_template("index.html", answer=answer) | |
if __name__ == "__main__": | |
app.run(debug=True) | |