import streamlit as st from transformers import pipeline result = False run_button = False reiniciar = False reset_button = False pipe = pipeline("question-answering", model="pierreguillou/bert-large-cased-squad-v1.1-portuguese") st.title("Modelo para perguntas e respostas") st.markdown("##### Deve ser informado um contexto e a pergunta referente a ele. É esperado que o modelo indique a posição no contexto onde a resposta é encontrada.") contexto = st.text_area("Digite aqui o contexto", height=150,) questao = st.text_input("Digite aqui a pergunta") if ((len(contexto)>0) & (len(questao)>0)): run_button = st.button("Gerar resposta") if run_button: result = pipe(question=questao, context=contexto) if result: st.write(result) reiniciar = True else: pass if reiniciar: reset_button = st.button("Reiniciar") if reset_button: result = False run_button = False reiniciar = False contexto = st.text_area("Digite aqui o contexto", height=150,) questao = st.text_input("Digite aqui a pergunta") st.sidebar.header("About") st.sidebar.subheader("Essa aplicação foi desenvolvida por Alexandre Vaz")