Manikanta3776 commited on
Commit
c8e4d1c
Β·
verified Β·
1 Parent(s): bc1d5a6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +68 -40
app.py CHANGED
@@ -8,62 +8,90 @@ from utils import clean_text
8
  chain = Chain()
9
  portfolio = Portfolio()
10
 
11
- def create_streamlit_app(llm, portfolio, clean_text):
12
- st.set_page_config(layout="wide", page_title="Cold Email Generator", page_icon="πŸ“§")
13
- st.title("πŸ“§ Cold Mail Generator")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
- # User Input
16
- url_input = st.text_input("Enter a Job URL:", value="https://jobs.nike.com/job/R-33460")
17
- username = st.text_input("Your Name (Default: Computer Engineering Student)", value="Computer Engineering Student")
18
- client_name = st.text_input("Recipient's Name (Default: Hiring Manager)", value="Hiring Manager")
19
 
20
- submit_button = st.button("Generate Cold Email")
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  if submit_button:
23
  try:
24
- st.info("πŸ”„ Extracting job details...")
25
-
26
- # Load and clean job description
27
  loader = WebBaseLoader([url_input])
28
- page_content = loader.load().pop().page_content
29
- cleaned_data = clean_text(page_content)
30
-
31
- # Extract job details
32
- jobs = llm.extract_jobs(cleaned_data)
33
 
34
  if not jobs:
35
- st.warning("⚠️ No jobs found on the page. Please check the URL.")
36
  return
37
 
38
- # Process extracted jobs
39
- for idx, job in enumerate(jobs, start=1):
40
- st.subheader(f"Job {idx}: {job.get('role', 'Unknown Role')}")
41
- st.write(f"**Experience Required:** {job.get('experience', 'Not Specified')}")
42
- st.write(f"**Skills:** {', '.join(job.get('skills', [])) if job.get('skills') else 'Not Specified'}")
43
- st.write(f"**Description:** {job.get('description', 'No description available')}")
44
- st.divider()
45
-
46
- # Get relevant portfolio links based on job skills
47
- skills = job.get("skills", [])
48
  links = portfolio.query_links(skills)
 
49
 
50
- # Generate cold email
51
- email = llm.write_mail(job, links, username, client_name)
52
-
53
- # Debugging: Print raw email output
54
- st.write(f"Generated Email: {email}")
55
-
56
- # Display email
57
- if email:
58
- st.code(email, language="markdown")
59
- else:
60
- st.error("⚠️ Failed to generate an email.")
61
 
62
  except Exception as e:
63
- st.error(f"❌ An Error Occurred: {str(e)}")
64
 
65
 
66
- if __name__ == "__main__":
67
 
 
 
68
  create_streamlit_app(chain, portfolio, clean_text)
69
 
 
8
  chain = Chain()
9
  portfolio = Portfolio()
10
 
11
+ # def create_streamlit_app(llm, portfolio, clean_text):
12
+ # st.set_page_config(layout="wide", page_title="Cold Email Generator", page_icon="πŸ“§")
13
+ # st.title("πŸ“§ Cold Mail Generator")
14
+
15
+ # # User Input
16
+ # url_input = st.text_input("Enter a Job URL:", value="https://jobs.nike.com/job/R-33460")
17
+ # username = st.text_input("Your Name (Default: Computer Engineering Student)", value="Computer Engineering Student")
18
+ # client_name = st.text_input("Recipient's Name (Default: Hiring Manager)", value="Hiring Manager")
19
+
20
+ # submit_button = st.button("Generate Cold Email")
21
+
22
+ # if submit_button:
23
+ # try:
24
+ # st.info("πŸ”„ Extracting job details...")
25
+
26
+ # # Load and clean job description
27
+ # loader = WebBaseLoader([url_input])
28
+ # page_content = loader.load().pop().page_content
29
+ # cleaned_data = clean_text(page_content)
30
+
31
+ # # Extract job details
32
+ # jobs = llm.extract_jobs(cleaned_data)
33
+
34
+ # if not jobs:
35
+ # st.warning("⚠️ No jobs found on the page. Please check the URL.")
36
+ # return
37
+
38
+ # # Process extracted jobs
39
+ # for idx, job in enumerate(jobs, start=1):
40
+ # st.subheader(f"Job {idx}: {job.get('role', 'Unknown Role')}")
41
+ # st.write(f"**Experience Required:** {job.get('experience', 'Not Specified')}")
42
+ # st.write(f"**Skills:** {', '.join(job.get('skills', [])) if job.get('skills') else 'Not Specified'}")
43
+ # st.write(f"**Description:** {job.get('description', 'No description available')}")
44
+ # st.divider()
45
+
46
+ # # Get relevant portfolio links based on job skills
47
+ # skills = job.get("skills", [])
48
+ # links = portfolio.query_links(skills)
49
+
50
+ # # Generate cold email
51
+ # email = llm.write_mail(job, links, username, client_name)
52
 
53
+ # # Debugging: Print raw email output
54
+ # st.write(f"Generated Email: {email}")
 
 
55
 
56
+ # # Display email
57
+ # if email:
58
+ # st.code(email, language="markdown")
59
+ # else:
60
+ # st.error("⚠️ Failed to generate an email.")
61
+
62
+ # except Exception as e:
63
+ # st.error(f"❌ An Error Occurred: {str(e)}")
64
+
65
+ def create_streamlit_app(llm, portfolio, clean_text):
66
+ st.title("πŸ“§ Cold Mail Generator")
67
+ url_input = st.text_input("Enter a URL:", value="https://jobs.nike.com/job/R-33460")
68
+ submit_button = st.button("Submit")
69
 
70
  if submit_button:
71
  try:
 
 
 
72
  loader = WebBaseLoader([url_input])
73
+ data = clean_text(loader.load().pop().page_content)
74
+ portfolio.load_portfolio()
75
+ jobs = llm.extract_jobs(data)
 
 
76
 
77
  if not jobs:
78
+ st.error("❌ No job postings found on the page.")
79
  return
80
 
81
+ for job in jobs:
82
+ skills = job.get('skills', [])
 
 
 
 
 
 
 
 
83
  links = portfolio.query_links(skills)
84
+ email = llm.write_mail(job, links)
85
 
86
+ st.subheader(f"πŸ“© Cold Email for {job.get('role', 'Job')}")
87
+ st.code(email, language='markdown')
 
 
 
 
 
 
 
 
 
88
 
89
  except Exception as e:
90
+ st.error(f"An Error Occurred: {e}")
91
 
92
 
 
93
 
94
+ if __name__ == "__main__":
95
+ st.set_page_config(layout="wide", page_title="Cold Email Generator", page_icon="πŸ“§")
96
  create_streamlit_app(chain, portfolio, clean_text)
97