ak2603 commited on
Commit
7aab5de
·
1 Parent(s): e2011c3
Files changed (1) hide show
  1. app.py +33 -36
app.py CHANGED
@@ -108,43 +108,40 @@ with col2:
108
  else:
109
  try:
110
  selected_model = models[model_choice]
111
-
112
- if selected_model is None:
113
- st.error("Selected model is not implemented yet")
114
- else:
115
- with st.spinner("Generating summary..."):
116
- if model_choice == "mt5-small":
117
- result = selected_model(
118
- email_input,
119
- max_length=150,
120
- do_sample=True,
121
- repetition_penalty=1.5
122
- )[0]['summary_text']
123
- elif model_choice == "Llama 3.2":
124
- model_obj, tokenizer = selected_model
125
- result = generate_llama_summary(
126
- email_input,
127
- model_obj,
128
- tokenizer,
129
- PROMPT_TEMPLATE
130
- )
131
-
132
- # Display results
133
- st.success("**Generated Summary:**")
134
- st.write(result)
135
-
136
- # Show reference summary if example is selected
137
- if example_choice in EXAMPLES:
138
- st.success("**Reference Summary:**")
139
- st.write(EXAMPLES[example_choice]["reference"])
140
-
141
- # Add export options
142
- st.download_button(
143
- label="Download Summary",
144
- data=result,
145
- file_name="email_summary.txt",
146
- mime="text/plain"
147
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148
 
149
  except Exception as e:
150
  st.error(f"Error generating summary: {str(e)}")
 
108
  else:
109
  try:
110
  selected_model = models[model_choice]
111
+
112
+ with st.spinner("Generating summary..."):
113
+ if model_choice == "mt5-small":
114
+ result = selected_model(
115
+ email_input,
116
+ max_length=150,
117
+ do_sample=True,
118
+ repetition_penalty=1.5
119
+ )[0]['summary_text']
120
+ elif model_choice == "Llama 3.2":
121
+ model_obj, tokenizer = selected_model
122
+ result = generate_llama_summary(
123
+ email_input,
124
+ model_obj,
125
+ tokenizer,
126
+ PROMPT_TEMPLATE
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127
  )
128
+
129
+ # Display results
130
+ st.success("**Generated Summary:**")
131
+ st.write(result)
132
+
133
+ # Show reference summary if example is selected
134
+ if example_choice in EXAMPLES:
135
+ st.success("**Reference Summary:**")
136
+ st.write(EXAMPLES[example_choice]["reference"])
137
+
138
+ # Add export options
139
+ st.download_button(
140
+ label="Download Summary",
141
+ data=result,
142
+ file_name="email_summary.txt",
143
+ mime="text/plain"
144
+ )
145
 
146
  except Exception as e:
147
  st.error(f"Error generating summary: {str(e)}")