Spaces:
Sleeping
Sleeping
Update app.py
Browse files186 unmodified lines18718818919019119219319419519619719819920020120220320421 unmodified lines226227228229230231232233234235236237238239240241242186 unmodified linesst.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 linesst.rerun()with st.spinner("Loading, please be patient with us ... ๐"):textify_output = read_and_textify_advanced(uploaded_files, sentence_chunks)df = pd.DataFrame(textify_output)df.columns = ['context']if question_protocol == "":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"df['answers'] = df.apply(lambda row: get_answers(row, answer_protocol), axis=1)df = df.drop('context', axis=1)186 unmodified lines18718818919019119221 unmodified lines214215216217218219220221222223224225226227228186 unmodified linesst.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()openai_api_key = st.text_input("Enter your OpenAI API key", type="password")21 unmodified linesst.rerun()with st.spinner("Loading, please be patient with us ... ๐"):textify_output = read_and_textify_advanced(uploaded_files, 1)df = pd.DataFrame(textify_output)df.columns = ['context']question_protocol = "Write questions based on the text"df['questions'] = df.apply(lambda row: get_questions(row['context'], question_protocol), axis=1)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