Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,6 +12,9 @@ def main():
|
|
| 12 |
|
| 13 |
# Text input for OpenAI API key
|
| 14 |
openai_api_key = st.sidebar.text_input("Enter your OpenAI API key", type="password")
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
if uploaded_file is not None and openai_api_key:
|
| 17 |
# Save the uploaded PDF to a temporary file
|
|
@@ -19,11 +22,13 @@ def main():
|
|
| 19 |
temp_pdf.write(uploaded_file.read())
|
| 20 |
temp_pdf_path = temp_pdf.name
|
| 21 |
|
| 22 |
-
#
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
|
|
|
|
|
|
| 27 |
|
| 28 |
# Display the resulting DataFrame
|
| 29 |
st.subheader("Generated Question-Answer Pairs")
|
|
|
|
| 12 |
|
| 13 |
# Text input for OpenAI API key
|
| 14 |
openai_api_key = st.sidebar.text_input("Enter your OpenAI API key", type="password")
|
| 15 |
+
|
| 16 |
+
# Embed YouTube video in the sidebar
|
| 17 |
+
st.sidebar.video("https://youtu.be/XLExhyangWw?si=hW9IdcQV2Sr-xDf_")
|
| 18 |
|
| 19 |
if uploaded_file is not None and openai_api_key:
|
| 20 |
# Save the uploaded PDF to a temporary file
|
|
|
|
| 22 |
temp_pdf.write(uploaded_file.read())
|
| 23 |
temp_pdf_path = temp_pdf.name
|
| 24 |
|
| 25 |
+
# Show a spinner while processing the PDF
|
| 26 |
+
with st.spinner('Processing the PDF and generating questions and answers...'):
|
| 27 |
+
# Process the PDF and generate the questions and answers
|
| 28 |
+
generator = PDFQnAGenerator(temp_pdf_path, openai_api_key)
|
| 29 |
+
generator.process_scraped_content()
|
| 30 |
+
generator.generate_questions_answers()
|
| 31 |
+
df = generator.convert_to_dataframe()
|
| 32 |
|
| 33 |
# Display the resulting DataFrame
|
| 34 |
st.subheader("Generated Question-Answer Pairs")
|