cd14 commited on
Commit
7dab346
·
1 Parent(s): 0028dd2

adding Genrative AI email genearion support

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -326,7 +326,11 @@ def get_files_from_aws(bucket, prefix):
326
  # st.info([industry,campaign,target,char_reco_preference])
327
 
328
  act=st.button('Generate Predictions')
329
- if act:
 
 
 
 
330
  start_time = time.time()
331
  if uploaded_file is None:
332
  st.error('Please upload a email (HTML format)')
@@ -495,7 +499,7 @@ if act:
495
 
496
  st.plotly_chart(fig, use_container_width=True)
497
 
498
- st.write("\n")
499
  chars_out = dict(zip(chars, sel_var_values))
500
  sorted_chars_out = sorted(chars_out.items(), key=lambda x: x[1], reverse=True)
501
  prefrence_variables=res=["charcter counts: "+str(x)+", Target Rate: "+str(y) for x,y in zip(chars,sel_var_values)]
@@ -511,6 +515,7 @@ if act:
511
  ai_generated_email=generate_example_email_with_context(email_body, campaign, industry, target, sorted_chars_out, preference)
512
  st.markdown('##### Here is the recommended Generated Email for you:')
513
  st.markdown('####### {}:'.format(ai_generated_email),unsafe_allow_html=True)
 
514
  # preference= "character counts: "+str(573)+", Target Rate: "+str(37.2)
515
  # ai_generated_email=generate_example_email_with_context(email_body, campaign, industry, target, sorted_chars_out, preference)
516
  # print("ai_generated_email: ",ai_generated_email)
 
326
  # st.info([industry,campaign,target,char_reco_preference])
327
 
328
  act=st.button('Generate Predictions')
329
+ if st.session_state.get('button') != True:
330
+ st.session_state['button'] = act
331
+
332
+ # if act:
333
+ if st.session_state.get('button') == True:
334
  start_time = time.time()
335
  if uploaded_file is None:
336
  st.error('Please upload a email (HTML format)')
 
499
 
500
  st.plotly_chart(fig, use_container_width=True)
501
 
502
+ # st.write("\n")
503
  chars_out = dict(zip(chars, sel_var_values))
504
  sorted_chars_out = sorted(chars_out.items(), key=lambda x: x[1], reverse=True)
505
  prefrence_variables=res=["charcter counts: "+str(x)+", Target Rate: "+str(y) for x,y in zip(chars,sel_var_values)]
 
515
  ai_generated_email=generate_example_email_with_context(email_body, campaign, industry, target, sorted_chars_out, preference)
516
  st.markdown('##### Here is the recommended Generated Email for you:')
517
  st.markdown('####### {}:'.format(ai_generated_email),unsafe_allow_html=True)
518
+ st.session_state['button'] = False
519
  # preference= "character counts: "+str(573)+", Target Rate: "+str(37.2)
520
  # ai_generated_email=generate_example_email_with_context(email_body, campaign, industry, target, sorted_chars_out, preference)
521
  # print("ai_generated_email: ",ai_generated_email)