Spaces:
Sleeping
Sleeping
Update app.py
Browse files26 unmodified lines27282930313031323334353334353637383964 unmodified lines10410510610610710710810911011126 unmodified lines text = pageObj.extract_text() # Extract text from the page if text: # Split text into chunks of approximately 'chunk_size' words words = text.split(". ") for j in range(len(words)): words = 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[start:end]) + '.' # 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 list else: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")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