alok94 commited on
Commit
5b05b5f
1 Parent(s): 057e6bf
Files changed (4) hide show
  1. .env +1 -0
  2. app.py +36 -0
  3. requirements.txt +7 -0
  4. test.py +1 -0
.env ADDED
@@ -0,0 +1 @@
 
 
1
+ OPENAI_API_KEY=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
app.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from PyPDF2 import PdfReader
3
+ from streamlit_extras.add_vertical_space import add_vertical_space
4
+ from langchain.text_splitter import RecursiveCharacterTextSplitter
5
+ from langchain.embeddings.openai import OpenAIEmbeddings
6
+ from langchain.vectorstores import faiss
7
+
8
+ with st.sidebar:
9
+ st.title("File Research using LLM")
10
+ st.markdown(''' Upload your file and ask questions and do Research''')
11
+ add_vertical_space(5)
12
+ pdf=st.file_uploader('Upload your file (PDF)', type='pdf')
13
+ if pdf is not None:
14
+ pdf_reader=PdfReader(pdf)
15
+ text=""
16
+ for page in pdf_reader.pages:
17
+ text+=page.extract_text()
18
+ text_splitter=RecursiveCharacterTextSplitter(
19
+ chunk_size=1000,
20
+ chunk_overlap=200,
21
+ length_function=len
22
+ )
23
+ chunks=text_splitter.split_text(text)
24
+ embeddings=OpenAIEmbeddings()
25
+ vectorstore=faiss.FAISS.from_texts(chunks, embedding=embeddings)
26
+
27
+
28
+
29
+ st.write(chunks)
30
+ st.write('Made by ALOK')
31
+
32
+ def main():
33
+ st.header('Talk to your file')
34
+
35
+ if __name__=='__main__':
36
+ main()
requirements.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ python==3.11.5
2
+ langchain
3
+ PyPDF2
4
+ streamlit
5
+ python-dotenv
6
+ faiss-cpu
7
+ streamlit-extras
test.py ADDED
@@ -0,0 +1 @@
 
 
1
+ print("hi")