Spaces:
Runtime error
Runtime error
File size: 874 Bytes
fe93e28 fe88e35 fe93e28 |
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 |
import requests
import gradio as gr
import os
HF_TOKEN = os.environ.get("HF_TOKEN")
API_URL = "https://api-inference.huggingface.co/models/allenai/bidaf-elmo"
headers = {"Authorization": HF_TOKEN}
def query(question, context):
data = {
"inputs": {
"question": question,
"context": context
},
}
response = requests.post(API_URL, headers=headers, json=data)
return response.json()["outputs"]["answer"]
# Example question and context
passage = "The quick brown fox jumped over the lazy dog."
question = "Who jumps over the lazy dog?"
iface = gr.Interface(query,
title="Allen NLP Question Answering",
inputs=["text", gr.inputs.Textbox(lines=15)],
outputs=["text"],
examples=[["{}".format(passage), "{}".format(question)]])
iface.launch() |