adinarayana commited on
Commit
cdb6df3
·
verified ·
1 Parent(s): 3858f1c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -23,9 +23,9 @@ def preprocess_text(element):
23
  else:
24
  return ""
25
 
26
- def get_openai_response(text, length=100, model="gpt-3.5-turbo-instruct"):
27
  summarizer = pipeline("summarization", model=model)
28
- return summarizer(text, min_length = length)
29
 
30
  ## Streamlit app
31
 
@@ -34,7 +34,8 @@ st.header("PDF Summarizer")
34
 
35
  # User options
36
  st.subheader("Settings")
37
- summary_length = st.slider("Summary Length", min_value=50, max_value=500, value=100)
 
38
  summarization_model = st.selectbox("Summarization Model", ["gpt-3.5-turbo-instruct", "t5-small", "facebook/bart-large-cnn"])
39
 
40
  # File upload and processing
@@ -49,7 +50,7 @@ if uploaded_file is not None:
49
  submit = st.button("Generate Summary")
50
  if submit:
51
  st.spinner("Summarizing...")
52
- response = get_openai_response(text, length=summary_length, model=summarization_model)
53
  st.subheader("Summary")
54
  st.write(response[0]["summary_text"])
55
  else:
 
23
  else:
24
  return ""
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("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
 
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: