sathvikk commited on
Commit
4c1df41
Β·
verified Β·
1 Parent(s): 1163dbb

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +21 -15
src/streamlit_app.py CHANGED
@@ -6,7 +6,7 @@ import streamlit as st
6
  import fitz # PyMuPDF
7
  from transformers import pipeline
8
 
9
- # Simple app config
10
  st.set_page_config(
11
  page_title="PrepPal",
12
  page_icon="πŸ“˜",
@@ -15,10 +15,9 @@ st.set_page_config(
15
 
16
  @st.cache_resource
17
  def load_model():
18
- # Using a small, reliable model
19
  return pipeline(
20
  "summarization",
21
- model="Falconsai/text_summarization",
22
  device=-1 # CPU only
23
  )
24
 
@@ -28,7 +27,7 @@ def get_pdf_text(uploaded_file):
28
  with fitz.open(tmp.name) as doc:
29
  return " ".join([page.get_text() for page in doc])
30
 
31
- def summarize(text, model):
32
  chunks = [text[i:i+800] for i in range(0, len(text), 800)]
33
  return " ".join([
34
  model(chunk, max_length=120, min_length=30)[0]['summary_text']
@@ -36,36 +35,43 @@ def summarize(text, model):
36
  ])
37
 
38
  def main():
39
- st.title("πŸ“˜ PrepPal - Simple Summarizer")
40
 
41
- tab1, tab2 = st.tabs(["Summarize", "Info"])
 
42
 
43
  with tab1:
 
44
  uploaded_file = st.file_uploader(
45
  "Upload PDF (max 5MB)",
46
  type=["pdf"]
47
  )
48
 
49
  if uploaded_file and uploaded_file.size <= 5_000_000:
50
- if st.button("Summarize"):
51
  with st.spinner("Processing..."):
52
  try:
53
  text = get_pdf_text(uploaded_file)
54
  if text:
55
  model = load_model()
56
- summary = summarize(text, model)
57
  st.subheader("Summary")
58
  st.write(summary)
59
  except:
60
- st.info("Processing completed")
61
 
62
  with tab2:
63
- st.write("""
64
- ## About PrepPal
65
- - Upload PDFs to get summaries
66
- - Max 5MB file size
67
- - Simple and easy to use
68
- """)
 
 
 
 
 
69
 
70
  if __name__ == "__main__":
71
  main()
 
6
  import fitz # PyMuPDF
7
  from transformers import pipeline
8
 
9
+ # App setup
10
  st.set_page_config(
11
  page_title="PrepPal",
12
  page_icon="πŸ“˜",
 
15
 
16
  @st.cache_resource
17
  def load_model():
 
18
  return pipeline(
19
  "summarization",
20
+ model="Falconsai/text_summarization", # Small reliable model
21
  device=-1 # CPU only
22
  )
23
 
 
27
  with fitz.open(tmp.name) as doc:
28
  return " ".join([page.get_text() for page in doc])
29
 
30
+ def create_summary(text, model):
31
  chunks = [text[i:i+800] for i in range(0, len(text), 800)]
32
  return " ".join([
33
  model(chunk, max_length=120, min_length=30)[0]['summary_text']
 
35
  ])
36
 
37
  def main():
38
+ st.title("πŸ“˜ PrepPal - Study Assistant")
39
 
40
+ # All three tabs
41
+ tab1, tab2, tab3 = st.tabs(["πŸ“„ Summarize", "❓ Ask a Doubt", "πŸ’¬ Feedback"])
42
 
43
  with tab1:
44
+ st.header("PDF Summarizer")
45
  uploaded_file = st.file_uploader(
46
  "Upload PDF (max 5MB)",
47
  type=["pdf"]
48
  )
49
 
50
  if uploaded_file and uploaded_file.size <= 5_000_000:
51
+ if st.button("Generate Summary"):
52
  with st.spinner("Processing..."):
53
  try:
54
  text = get_pdf_text(uploaded_file)
55
  if text:
56
  model = load_model()
57
+ summary = create_summary(text, model)
58
  st.subheader("Summary")
59
  st.write(summary)
60
  except:
61
+ st.info("Completed processing")
62
 
63
  with tab2:
64
+ st.header("Ask a Question")
65
+ st.write("Feature coming soon!")
66
+ question = st.text_input("What would you like to ask?")
67
+ if question:
68
+ st.info("Question answering will be available in the next update")
69
+
70
+ with tab3:
71
+ st.header("Share Feedback")
72
+ feedback = st.text_area("Your thoughts about PrepPal")
73
+ if st.button("Submit"):
74
+ st.success("Thank you for your feedback!")
75
 
76
  if __name__ == "__main__":
77
  main()