Spaces:
Sleeping
Sleeping
import gradio as gr | |
from transformers import pipeline | |
# criando o pipeline para a QA | |
qa = pipeline('question-answering') | |
# criando a função para a interface | |
def answer_question(contexto, pergunta): | |
resposta = qa(context=contexto, question=pergunta) | |
return resposta['answer'] | |
iface = gr.Interface( | |
fn=answer_question, | |
inputs=[ | |
gr.Textbox( | |
type="text", | |
lines=3, | |
label="Contexto"), | |
gr.Textbox( | |
type="text", | |
lines=4, | |
label="Pergunta", | |
info="Escreva o que quer saber...") | |
], | |
outputs=gr.Textbox(type="text", label="Resposta") | |
) | |
iface.launch() |