adinarayana commited on
Commit
276fdaf
·
verified ·
1 Parent(s): cdb6df3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -8
app.py CHANGED
@@ -25,7 +25,7 @@ def preprocess_text(element):
25
 
26
  def get_openai_response(text, min_length=100, max_length=100, model="gpt-3.5-turbo-instruct"):
27
  summarizer = pipeline("summarization", model=model)
28
- return summarizer(text, min_length = min_length, max_length = max_length)
29
 
30
  ## Streamlit app
31
 
@@ -34,8 +34,8 @@ st.header("PDF Summarizer")
34
 
35
  # User options
36
  st.subheader("Settings")
37
- min_summary_length = st.slider("Summary Length", min_value=50, max_value=500, value=100)
38
- max_summary_length = st.slider("Summary Length", min_value=50, max_value=500, value=100)
39
  summarization_model = st.selectbox("Summarization Model", ["gpt-3.5-turbo-instruct", "t5-small", "facebook/bart-large-cnn"])
40
 
41
  # File upload and processing
@@ -49,10 +49,9 @@ if uploaded_file is not None:
49
  if text:
50
  submit = st.button("Generate Summary")
51
  if submit:
52
- st.spinner("Summarizing...")
53
- response = get_openai_response(text, min_length=min_summary_length, max_length=max_summary_length, model=summarization_model)
54
- st.subheader("Summary")
55
- st.write(response[0]["summary_text"])
56
  else:
57
  st.error("No text found in the PDF.")
58
-
 
25
 
26
  def get_openai_response(text, min_length=100, max_length=100, model="gpt-3.5-turbo-instruct"):
27
  summarizer = pipeline("summarization", model=model)
28
+ return summarizer(text, min_length=min_length, max_length=max_length)
29
 
30
  ## Streamlit app
31
 
 
34
 
35
  # User options
36
  st.subheader("Settings")
37
+ min_summary_length = st.slider("Minimum Summary Length", min_value=50, max_value=500, value=100)
38
+ max_summary_length = st.slider("Maximum Summary Length", min_value=50, max_value=500, value=100)
39
  summarization_model = st.selectbox("Summarization Model", ["gpt-3.5-turbo-instruct", "t5-small", "facebook/bart-large-cnn"])
40
 
41
  # File upload and processing
 
49
  if text:
50
  submit = st.button("Generate Summary")
51
  if submit:
52
+ with st.spinner("Summarizing..."):
53
+ response = get_openai_response(text, min_length=min_summary_length, max_length=max_summary_length, model=summarization_model)
54
+ st.subheader("Summary")
55
+ st.write(response[0]["summary_text"])
56
  else:
57
  st.error("No text found in the PDF.")