Spaces:
Sleeping
Sleeping
Update app.py
Browse files113 unmodified lines114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149113 unmodified linessubmit = st.button("Submit")if submit:try:client = OpenAI(api_key=openai_api_key)try:client.Model.list()except:st.error("OpenAI API key is invalid")if uploaded_files: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)csv = df.to_csv(index=False).encode('utf-8')st.download_button(label="Download Q/A pairs as CSV",data=csv,file_name='questions_answers.csv',mime='text/csv',)else:st.error("Please upload at least 1 PDF")113 unmodified lines114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148113 unmodified linessubmit = st.button("Submit")if submit:client = OpenAI(api_key=openai_api_key)try:client.Model.list()except:st.error("OpenAI API key is invalid")if uploaded_files: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)csv = df.to_csv(index=False).encode('utf-8')st.download_button(label="Download Q/A pairs as CSV",data=csv,file_name='questions_answers.csv',mime='text/csv',)else:st.error("Please upload at least 1 PDF")
app.py+31-32