Spaces:
Sleeping
Sleeping
File size: 1,141 Bytes
5b05b5f 8a9262e 5b05b5f 8a9262e 5b05b5f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
import streamlit as st
from PyPDF2 import PdfReader
from streamlit_extras.add_vertical_space import add_vertical_space
from langchain.text_splitter import RecursiveCharacterTextSplitter
#from langchain.embeddings.openai import OpenAIEmbeddings
from langchain.vectorstores import faiss
with st.sidebar:
st.title("File Research using LLM")
st.markdown(''' Upload your file and ask questions and do Research''')
add_vertical_space(5)
pdf=st.file_uploader('Upload your file (PDF)', type='pdf')
if pdf is not None:
pdf_reader=PdfReader(pdf)
text=""
for page in pdf_reader.pages:
text+=page.extract_text()
text_splitter=RecursiveCharacterTextSplitter(
chunk_size=1000,
chunk_overlap=200,
length_function=len
)
chunks=text_splitter.split_text(text)
#embeddings=OpenAIEmbeddings()
#vectorstore=faiss.FAISS.from_texts(chunks, embedding=embeddings)
st.write(chunks)
st.write('Made by ALOK')
def main():
st.header('Talk to your file')
if __name__=='__main__':
main() |