mishrasahil934 commited on
Commit
2890bed
·
verified ·
1 Parent(s): 9f71231

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -28
app.py CHANGED
@@ -1,7 +1,6 @@
1
  from dotenv import load_dotenv
2
  load_dotenv()
3
- import os
4
- from tempfile import NamedTemporaryFile
5
  import streamlit as st
6
  from langchain.text_splitter import RecursiveCharacterTextSplitter
7
  from langchain.document_loaders import PyPDFLoader,DirectoryLoader
@@ -68,41 +67,33 @@ def displayPDF(file):
68
  # Displaying the file
69
  st.markdown(pdf_display, unsafe_allow_html=True)
70
 
 
71
  #streamlit code
72
  st.set_page_config(layout='wide')
73
 
74
-
75
-
76
  def main():
77
- st.title('Content Summarizer')
78
-
79
- uploaded_file = st.file_uploader("Upload your PDF file", type=['pdf'])
80
-
81
- def main():
82
- st.title('Content Summarizer')
83
-
84
- uploaded_file = st.file_uploader("Upload your PDF file", type=['pdf'])
85
-
86
  if uploaded_file is not None:
87
- if st.button("Summarize"):
88
- col1, col2 = st.columns(2)
89
-
90
- # Save the uploaded file to a temporary location
91
- with NamedTemporaryFile(delete=False, suffix=".pdf") as temp_file:
92
  temp_file.write(uploaded_file.read())
93
- temp_filepath = temp_file.name
94
-
95
  with col1:
96
- st.info("Uploaded PDF File")
97
- pdf_viewer = displayPDF(temp_filepath)
98
-
 
99
  with col2:
100
  st.info("Summarization is below")
101
- summary = llm_pipleline(temp_filepath)
102
  st.success(summary)
103
- else:
104
- st.warning("Please upload a valid PDF file.")
105
-
106
 
107
  if st.button("text"):
108
  ans = input("enter your content")
@@ -122,4 +113,4 @@ def main():
122
 
123
 
124
  if __name__ == '__main__':
125
- main()
 
1
  from dotenv import load_dotenv
2
  load_dotenv()
3
+
 
4
  import streamlit as st
5
  from langchain.text_splitter import RecursiveCharacterTextSplitter
6
  from langchain.document_loaders import PyPDFLoader,DirectoryLoader
 
67
  # Displaying the file
68
  st.markdown(pdf_display, unsafe_allow_html=True)
69
 
70
+
71
  #streamlit code
72
  st.set_page_config(layout='wide')
73
 
 
 
74
  def main():
75
+
76
+ st.title('Content sumerizer')
77
+
78
+ uploaded_file = st.file_uploader("upload your pdf file", type=['pdf'])
79
+
 
 
 
 
80
  if uploaded_file is not None:
81
+ if st.button("summarize"):
82
+ col1,col2 = st.columns(2)
83
+ filepath = uploaded_file.name
84
+ with open(filepath, 'wb') as temp_file:
 
85
  temp_file.write(uploaded_file.read())
 
 
86
  with col1:
87
+ st.info("uploaded PDF File")
88
+ pdf_viewer = displayPDF(filepath)
89
+
90
+
91
  with col2:
92
  st.info("Summarization is below")
93
+ summary = llm_pipleline(filepath)
94
  st.success(summary)
95
+ else :
96
+ print("enter a valid pdf file")
 
97
 
98
  if st.button("text"):
99
  ans = input("enter your content")
 
113
 
114
 
115
  if __name__ == '__main__':
116
+ main()