File size: 668 Bytes
3fdeead
 
 
 
 
 
 
ebcd6e2
 
3fdeead
 
 
 
 
0e79fc2
 
01540d3
0e79fc2
 
 
01540d3
0e79fc2
179b57b
0ba3c28
ebcd6e2
3fdeead
 
 
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
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()