Spaces:
Runtime error
Runtime error
adding gen ai support
Browse files
app.py
CHANGED
@@ -381,7 +381,7 @@ if st.button('Generate Predictions'):
|
|
381 |
print(
|
382 |
"Sorry, Current model couldn't provide predictions on the target variable you selected.")
|
383 |
else:
|
384 |
-
st.markdown('##### Current Character Count in Your Email is: <span style="color:
|
385 |
character_cnt), unsafe_allow_html=True)
|
386 |
# st.info('The model predicts that it achieves a {} of {}%'.format(target, str(round(output_rate*100,2))))
|
387 |
if target == 'conversion_rate':
|
@@ -389,7 +389,7 @@ if st.button('Generate Predictions'):
|
|
389 |
else:
|
390 |
target_vis = 'Open_Rate'
|
391 |
|
392 |
-
st.markdown('##### The model predicts that it achieves a <span style="color:
|
393 |
target_vis, str(round(output_rate*100, 3))), unsafe_allow_html=True)
|
394 |
selected_industry_code = industry_code_dict.get(industry)
|
395 |
|
@@ -441,10 +441,10 @@ if st.button('Generate Predictions'):
|
|
441 |
if selected_variable == "Click_Through_Rate":
|
442 |
selected_variable = "Conversion_Rate"
|
443 |
|
444 |
-
st.markdown('##### To get higher, <span style="color:
|
445 |
selected_variable), unsafe_allow_html=True)
|
446 |
if len(df_reco_opt_rank) == 0:
|
447 |
-
st.markdown('##### You ve already achieved the highest, <span style="color:
|
448 |
selected_variable), unsafe_allow_html=True)
|
449 |
else:
|
450 |
#for _, row in df_reco_opt_rank.iterrows():
|
@@ -498,26 +498,25 @@ if st.button('Generate Predictions'):
|
|
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 |
preference= "charcter counts: "+str(573)+", Target Rate: "+str(37.2)
|
502 |
ai_generated_email=generate_example_email_with_context(email_body, campaign, industry, target, sorted_chars_out, preference)
|
503 |
print("ai_generated_email: ",ai_generated_email)
|
504 |
st.markdown('##### Here is the recommended Generated Email for you:')
|
505 |
st.markdown('####### {}'.format(ai_generated_email),unsafe_allow_html=True)
|
506 |
#st.write(np.array(chars))
|
507 |
-
# prefrence_variables=res=["charcter counts: "+str(x)+", Target Rate: "+str(y) for x,y in zip(chars,sel_var_values)]
|
508 |
-
# preference = st.selectbox(
|
509 |
-
# 'Please select your preferences',
|
510 |
-
# prefrence_variables,
|
511 |
-
# index=1
|
512 |
-
# )
|
513 |
-
# if(preference):
|
514 |
-
# if st.button('Generate AI Recommended Email'):
|
515 |
-
# if(preference is None):
|
516 |
-
# st.error('Please upload a email (HTML format)')
|
517 |
-
# else:
|
518 |
-
# ai_generated_email=generate_example_email_with_context(email_body, campaign, industry, target, sorted_chars_out, preference)
|
519 |
-
# st.markdown('##### Here is the recommended Generated Email for you:')
|
520 |
-
# st.markdown('####### {}:'.format(ai_generated_email),unsafe_allow_html=True)
|
521 |
|
522 |
|
523 |
chars_out = dict(zip(chars, sel_var_values))
|
|
|
381 |
print(
|
382 |
"Sorry, Current model couldn't provide predictions on the target variable you selected.")
|
383 |
else:
|
384 |
+
st.markdown('##### Current Character Count in Your Email is: <span style="color:yellow">{}</span>'.format(
|
385 |
character_cnt), unsafe_allow_html=True)
|
386 |
# st.info('The model predicts that it achieves a {} of {}%'.format(target, str(round(output_rate*100,2))))
|
387 |
if target == 'conversion_rate':
|
|
|
389 |
else:
|
390 |
target_vis = 'Open_Rate'
|
391 |
|
392 |
+
st.markdown('##### The model predicts that it achieves a <span style="color:yellow">{}</span> of <span style="color:yellow">{}</span>%'.format(
|
393 |
target_vis, str(round(output_rate*100, 3))), unsafe_allow_html=True)
|
394 |
selected_industry_code = industry_code_dict.get(industry)
|
395 |
|
|
|
441 |
if selected_variable == "Click_Through_Rate":
|
442 |
selected_variable = "Conversion_Rate"
|
443 |
|
444 |
+
st.markdown('##### To get higher, <span style="color:yellow">{}</span>, the model recommends the following options:'.format(
|
445 |
selected_variable), unsafe_allow_html=True)
|
446 |
if len(df_reco_opt_rank) == 0:
|
447 |
+
st.markdown('##### You ve already achieved the highest, <span style="color:yellow">{}</span>, with the current character count!'.format(
|
448 |
selected_variable), unsafe_allow_html=True)
|
449 |
else:
|
450 |
#for _, row in df_reco_opt_rank.iterrows():
|
|
|
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)]
|
502 |
+
preference = st.selectbox(
|
503 |
+
'Please select your preferences',
|
504 |
+
prefrence_variables,
|
505 |
+
index=1
|
506 |
+
)
|
507 |
+
if st.button('Generate AI Recommended Email'):
|
508 |
+
if(preference is None):
|
509 |
+
st.error('Please upload a email (HTML format)')
|
510 |
+
else:
|
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= "charcter 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)
|
517 |
st.markdown('##### Here is the recommended Generated Email for you:')
|
518 |
st.markdown('####### {}'.format(ai_generated_email),unsafe_allow_html=True)
|
519 |
#st.write(np.array(chars))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
520 |
|
521 |
|
522 |
chars_out = dict(zip(chars, sel_var_values))
|
utils.py
CHANGED
@@ -24,7 +24,6 @@ def chat_gpt_user_input_loop():
|
|
24 |
|
25 |
|
26 |
def generate_example_email_with_context(email_body, selected_campaign_type, selected_industry, selected_variable, chars_out, dropdown_cc):
|
27 |
-
print("I am here!")
|
28 |
if len(chars_out) == 1:
|
29 |
if str(chars_out[0][0]) in dropdown_cc:
|
30 |
generate_email_prompt = "Rewrite this email keeping relevant information (people, date, location): " + email_body + "." "Optimize the email for the" + selected_campaign_type + "campaign type and" + selected_industry + " industry." + "The email body should be around" + str(chars_out[0][0]+200) + "characters in length."
|
|
|
24 |
|
25 |
|
26 |
def generate_example_email_with_context(email_body, selected_campaign_type, selected_industry, selected_variable, chars_out, dropdown_cc):
|
|
|
27 |
if len(chars_out) == 1:
|
28 |
if str(chars_out[0][0]) in dropdown_cc:
|
29 |
generate_email_prompt = "Rewrite this email keeping relevant information (people, date, location): " + email_body + "." "Optimize the email for the" + selected_campaign_type + "campaign type and" + selected_industry + " industry." + "The email body should be around" + str(chars_out[0][0]+200) + "characters in length."
|