import gradio as gr from transformers import pipeline # Carrega o modelo de Resposta a Perguntas qa_model = pipeline("question-answering", model="vsvasconcelos/Phi-2_PT_QA_2_v3") # Define a função para responder às perguntas def answer_question(context, question): if context: return qa_model(question=question, context=context)['answer'] else: return qa_model(question=question)['answer'] # Cria a interface Gradio iface = gr.Interface( fn=answer_question, inputs=["text", "text"], outputs="text", title="QA Model", description="Pergunte algo e obtenha uma resposta!" ) iface.launch()