Spaces:
Sleeping
Sleeping
Update app.py
Browse files26 unmodified lines27282930313233343536373864 unmodified lines10310410510610710810911026 unmodified linestext = pageObj.extract_text() # Extract text from the pageif text:# Split text into chunks of approximately 'chunk_size' wordswords = text.split(". ")for j in range(len(words)):# Get the chunk of text from j-chunk_size to j+chunk_sizestart = max(0, j - chunk_size)end = min(len(words), j + chunk_size + 1)chunk = ". ".join(words[start:end]) + '.'text_list.append(chunk)# Create a source identifier for each chunk and add it to the listelse:64 unmodified linesuploaded_files = st.file_uploader("Upload PDFs Here", type="pdf", accept_multiple_files=True)st.success(f"{len(uploaded_files)} document(s) loaded...")question_protocol = st.text_input("Provide instructions for how questions should be generated", "Write questions based on the text")answer_protocol = st.text_input("Provide instructions for how answers should be generated", "Write answers 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)26 unmodified lines2728293031323334353637383964 unmodified lines10410510610710810911011126 unmodified linestext = pageObj.extract_text() # Extract text from the pageif text:# Split text into chunks of approximately 'chunk_size' wordswords = text.split(".")for j in range(0, len(words), chuck_size):# Get the chunk of text from j-chunk_size to j+chunk_size# start = max(0, j - chunk_size)# end = min(len(words), j + chunk_size + 1)chunk = ".".join(words[j:j+chunk_size]) + '.'chunk = chunk.strip()text_list.append(chunk)# Create a source identifier for each chunk and add it to the listelse:64 unmodified linesuploaded_files = st.file_uploader("Upload PDFs Here", type="pdf", accept_multiple_files=True)st.success(f"{len(uploaded_files)} document(s) loaded...")question_protocol = st.text_input("Provide instructions for how questions should be generated", "Write a question based on the text")answer_protocol = st.text_input("Provide instructions for how answers should be generated", "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)
app.py+8-7