Raykarr commited on
Commit
18c7cc7
Β·
1 Parent(s): 850463f

First model version

Browse files
README.md CHANGED
@@ -1,10 +1,10 @@
1
  ---
2
- title: Cold Email
3
- emoji: 🌍
4
- colorFrom: purple
5
  colorTo: red
6
  sdk: streamlit
7
- sdk_version: 1.39.0
8
  app_file: app.py
9
  pinned: false
10
  ---
 
1
  ---
2
+ title: Cold Email Part One
3
+ emoji: 🐠
4
+ colorFrom: red
5
  colorTo: red
6
  sdk: streamlit
7
+ sdk_version: 1.38.0
8
  app_file: app.py
9
  pinned: false
10
  ---
app.py ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import streamlit as st
3
+ import pandas as pd
4
+ import traceback
5
+ import backend
6
+
7
+
8
+ st.set_page_config(page_title="Cold Email Generator", layout="wide",initial_sidebar_state='collapsed')
9
+
10
+
11
+ def main():
12
+ try:
13
+ # ------------------------------------- Custom CSS -------------------------------------------------------------
14
+ st.markdown(
15
+ """
16
+ <style>
17
+ .css-1d391kg { /* Adjust this class based on your Streamlit version */
18
+ padding-left: 10px;
19
+ padding-right: 10px;
20
+ }
21
+ </style>
22
+ """,
23
+ unsafe_allow_html=True
24
+ )
25
+ # --------------------------------------------------------------------------------------------------
26
+
27
+
28
+ st.header("Cold Email Generator")
29
+
30
+ split_screen_col1, split_screen_col2 = st.columns(2)
31
+ # Input fields
32
+ with split_screen_col1:
33
+ industry_col, recipient_col = st.columns(2)
34
+ with industry_col:
35
+ industry = st.text_input("Industry")
36
+ with recipient_col:
37
+ recipient_role = st.text_input("Recipient Name")
38
+
39
+ details_col1, details_col2 = st.columns(2)
40
+ with details_col1:
41
+ details_type = st.radio("Select Details Type", ["Personal Details", "Company Details"])
42
+
43
+ with details_col2:
44
+ name = st.text_input("Senders Name")
45
+ designation = ""
46
+ company_name = ""
47
+
48
+ if details_type == "Personal Details":
49
+ designation = st.text_input("Designation/Role")
50
+ else:
51
+ company_name = st.text_input("Company Name")
52
+ designation = st.text_input("Designation/Role")
53
+
54
+
55
+ tone = st.selectbox("Tone", ["Formal", "Casual", "Friendly", "Professional"])
56
+ context = st.text_area("Context")
57
+
58
+ is_generate_clicked = st.button("Generate Email")
59
+
60
+ with split_screen_col2:
61
+
62
+ if is_generate_clicked :
63
+
64
+ generated_email = backend.collect_context_for_email(industry,recipient_role, tone, context, details_type, name, designation, company_name)
65
+ st.session_state.edited_email = st.text_area("Generated Email", value = generated_email, height=300, disabled=False)
66
+ st.session_state.is_generate_clicked = True
67
+ else:
68
+ st.text_area("Generated Email", height=300, disabled=True)
69
+
70
+ # Edit and Send button
71
+
72
+ if st.button("Completed Editing"):
73
+ st.session_state.is_cmp_editing_clicked = True
74
+
75
+ st.markdown("---")
76
+
77
+ if st.session_state.get("is_cmp_editing_clicked") and st.session_state.get("is_generate_clicked") :
78
+ st.subheader("Chat to refine your email")
79
+
80
+
81
+ email_col1, email_col2 = st.columns(2)
82
+ with email_col1:
83
+ sender_email = st.text_input("Sender's Email")
84
+ with email_col2:
85
+ receiver_email = st.text_input("Receiver's Email")
86
+
87
+ subject = st.text_input("Subject")
88
+ st.text_area("Generated Email", value=st.session_state.edited_email, height=300, disabled=False)
89
+
90
+ is_send_clicked = ""
91
+ if st.session_state.get("is_cmp_editing_clicked") :
92
+ is_send_clicked = st.button("Send Email")
93
+
94
+ if is_send_clicked:
95
+ st.subheader("All done, real-time email sending will be implemented in part2 😊 ")
96
+
97
+
98
+ except Exception as err:
99
+ traceback.print_exc()
100
+ print(err)
101
+
102
+ if __name__ == "__main__":
103
+ main()
backend.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import llm
3
+ import traceback
4
+
5
+ def collect_context_for_email(industry, rec_name, tone, context, details_type, name, designation, company_name =""):
6
+
7
+ try:
8
+
9
+ print("number of calls")
10
+ user_input = {
11
+ "industry": industry,
12
+ "recipient_name": rec_name,
13
+ "tone": tone,
14
+ "context": context,
15
+ "details_type": details_type,
16
+ "name": name,
17
+ "designation": designation,
18
+ "company_name": company_name
19
+ }
20
+
21
+ llm_output = llm.chat_with_groq(user_input)
22
+
23
+ return llm_output
24
+ except Exception as err:
25
+ traceback.print_exc()
26
+ print(err)
27
+
llm.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Default
2
+ import os
3
+ from groq import Groq
4
+ import traceback
5
+
6
+ client = Groq(
7
+ # This is the default and can be omitted
8
+ api_key=os.environ.get("GROQ_API_KEY"),
9
+ )
10
+
11
+ def chat_with_groq(user_input, additional_info=None):
12
+
13
+ try:
14
+
15
+ template_prompt = f"""
16
+
17
+ You are a professional email writer who specialises in writing cold email.
18
+ Generate a cold email to {user_input['recipient_name']} based on the following information:
19
+
20
+ Industry: {user_input['industry']}
21
+ Tone: {user_input['tone']}
22
+ Context: {user_input['context']}
23
+ Senders Name: {user_input['name']}
24
+ Designation: {user_input['designation']}
25
+
26
+ Incorporate all information and write a compelling email.
27
+
28
+ """
29
+
30
+ # test purposes:
31
+ # return template_prompt
32
+ chat_completion = client.chat.completions.create(
33
+ messages=[
34
+ {
35
+ "role": "system",
36
+ "content": "You are an expert email writer specializing in cold emails.",
37
+ },
38
+ {
39
+ "role": "user",
40
+ "content": template_prompt,
41
+ }
42
+ ],
43
+ model="mixtral-8x7b-32768",
44
+ )
45
+
46
+ generated_email = chat_completion.choices[0].message.content
47
+ return generated_email
48
+
49
+
50
+ except Exception as err:
51
+ traceback.print_exc()
52
+ print(err)
53
+
54
+
55
+
pages/1_❀️_Chat_Page.py ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import traceback
4
+ import llm
5
+
6
+ st.header("To be implemented in part 2")
7
+
8
+
pages/2_πŸ—’_Templates_Page.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import traceback
4
+ import llm
5
+
6
+ st.header("To be implemented in part 2")
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ streamlit
2
+ pandas
3
+ groq
4
+ python-dotenv