Spaces:
Sleeping
Sleeping
Update app.py
Browse files186 unmodified lines18718818919019119219319419519619719819920020119019119221 unmodified lines214215216229217218219220221234235222223224238239225226227228186 unmodified lines st.write("You can upload more than one PDF at a time, but don't do too many at once.") uploaded_files = st.file_uploader("", type="pdf", accept_multiple_files=True) st.divider()
st.write("2. Provide instructions for how questions should be generated.") with st.expander("Explain"): st.write("You can upload more than one PDF at a time, but don't do too many at once.") question_protocol = st.text_input("", "Write a question based on the text")
st.write("3. Provide instructions for how answers should be generated") with st.expander("Explain"): st.write("You can upload more than one PDF at a time, but don't do too many at once.") answer_protocol = st.text_input("", "Write an answer based on the text") sentence_chunks = st.number_input("Number sentences per Q/A pair", value=2, step=1, min_value=1, max_value=3) openai_api_key = st.text_input("Enter your OpenAI API key", type="password") 21 unmodified lines st.rerun() with st.spinner("Loading, please be patient with us ... 🙏"): textify_output = read_and_textify_advanced(uploaded_files, sentence_chunks) textify_output = read_and_textify_advanced(uploaded_files, 1) df = pd.DataFrame(textify_output) df.columns = ['context'] if question_protocol == "": question_protocol = "Write questions based on the text" question_protocol = "Write questions based on the text" df['questions'] = df.apply(lambda row: get_questions(row['context'], question_protocol), axis=1) if answer_protocol == "": answer_protocol = "Write answers based on the text" answer_protocol = "Write answers based on the text" df['answers'] = df.apply(lambda row: get_answers(row, answer_protocol), axis=1) df = df.drop('context', axis=1)app.py+3-17