Spaces:
Runtime error
Runtime error
File size: 858 Bytes
0e7f1ae f782c07 0e7f1ae c74775f 61febee 0e7f1ae |
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 29 |
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()
@app.route("/", methods=["GET", "POST"])
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)
|