Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import pandas as pd | |
| import traceback | |
| import backend | |
| st.set_page_config(page_title="Cold Email Generator", layout="wide",initial_sidebar_state='collapsed') | |
| def main(): | |
| try: | |
| # ------------------------------------- Custom CSS ------------------------------------------------------------- | |
| st.markdown( | |
| """ | |
| <style> | |
| .css-1d391kg { /* Adjust this class based on your Streamlit version */ | |
| padding-left: 10px; | |
| padding-right: 10px; | |
| } | |
| </style> | |
| """, | |
| unsafe_allow_html=True | |
| ) | |
| # -------------------------------------------------------------------------------------------------- | |
| st.header("Cold Email Generator") | |
| split_screen_col1, split_screen_col2 = st.columns(2) | |
| # Input fields | |
| with split_screen_col1: | |
| industry_col, recipient_col = st.columns(2) | |
| with industry_col: | |
| industry = st.text_input("Industry") | |
| with recipient_col: | |
| recipient_role = st.text_input("Recipient Name") | |
| details_col1, details_col2 = st.columns(2) | |
| with details_col1: | |
| details_type = st.radio("Select Details Type", ["Personal Details", "Company Details"]) | |
| with details_col2: | |
| name = st.text_input("Senders Name") | |
| designation = "" | |
| company_name = "" | |
| if details_type == "Personal Details": | |
| designation = st.text_input("Designation/Role") | |
| else: | |
| company_name = st.text_input("Company Name") | |
| designation = st.text_input("Designation/Role") | |
| tone = st.selectbox("Tone", ["Formal", "Casual", "Friendly", "Professional"]) | |
| context = st.text_area("Context") | |
| is_generate_clicked = st.button("Generate Email") | |
| with split_screen_col2: | |
| if is_generate_clicked : | |
| generated_email = backend.collect_context_for_email(industry,recipient_role, tone, context, details_type, name, designation, company_name) | |
| st.session_state.edited_email = st.text_area("Generated Email", value = generated_email, height=300, disabled=False) | |
| st.session_state.is_generate_clicked = True | |
| else: | |
| st.text_area("Generated Email", height=300, disabled=True) | |
| # Edit and Send button | |
| if st.button("Completed Editing"): | |
| st.session_state.is_cmp_editing_clicked = True | |
| st.markdown("---") | |
| if st.session_state.get("is_cmp_editing_clicked") and st.session_state.get("is_generate_clicked") : | |
| st.subheader("Chat to refine your email") | |
| email_col1, email_col2 = st.columns(2) | |
| with email_col1: | |
| sender_email = st.text_input("Sender's Email") | |
| with email_col2: | |
| receiver_email = st.text_input("Receiver's Email") | |
| subject = st.text_input("Subject") | |
| st.text_area("Generated Email", value=st.session_state.edited_email, height=300, disabled=False) | |
| is_send_clicked = "" | |
| if st.session_state.get("is_cmp_editing_clicked") : | |
| is_send_clicked = st.button("Send Email") | |
| if is_send_clicked: | |
| st.subheader("All done, real-time email sending will be implemented in part2 😊 ") | |
| except Exception as err: | |
| traceback.print_exc() | |
| print(err) | |
| if __name__ == "__main__": | |
| main() | |