Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
qa = pipeline("question-answering", model="distilbert-base-uncased-distilled-squad")
|
| 5 |
+
|
| 6 |
+
def responder(contexto, pregunta):
|
| 7 |
+
respuesta = qa(question=pregunta, context=contexto)
|
| 8 |
+
return respuesta["answer"]
|
| 9 |
+
|
| 10 |
+
app = gr.Interface(
|
| 11 |
+
fn=responder,
|
| 12 |
+
inputs=[gr.Textbox(label="Contexto"), gr.Textbox(label="Pregunta")],
|
| 13 |
+
outputs="text"
|
| 14 |
+
)
|
| 15 |
+
|
| 16 |
+
app.launch()
|