Manikanta3776 commited on
Commit
487a9b1
·
verified ·
1 Parent(s): 4cb2665

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -15
app.py CHANGED
@@ -8,32 +8,34 @@ from utils import clean_text
8
  chain = Chain()
9
  portfolio = Portfolio()
10
 
11
- def create_streamlit_app():
12
  st.set_page_config(layout="wide", page_title="Cold Email Generator", page_icon="📧")
13
- st.title("📧 Cold Email Generator")
14
 
15
- # Input fields
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("Extract Job Details")
21
 
22
  if submit_button:
23
  try:
 
 
24
  # Load and clean job description
25
  loader = WebBaseLoader([url_input])
26
  page_content = loader.load().pop().page_content
27
  cleaned_data = clean_text(page_content)
28
 
29
  # Extract job details
30
- jobs = chain.extract_jobs(cleaned_data)
31
 
32
  if not jobs:
33
  st.warning("⚠️ No jobs found on the page. Please check the URL.")
34
  return
35
 
36
- # Display extracted job details
37
  for idx, job in enumerate(jobs, start=1):
38
  st.subheader(f"Job {idx}: {job.get('role', 'Unknown Role')}")
39
  st.write(f"**Experience Required:** {job.get('experience', 'Not Specified')}")
@@ -41,20 +43,29 @@ def create_streamlit_app():
41
  st.write(f"**Description:** {job.get('description', 'No description available')}")
42
  st.divider()
43
 
44
- # Email generation button
45
- if st.button("Generate Cold Email"):
46
- for job in jobs:
47
- # Get relevant portfolio links based on job skills
48
- skills = job.get("skills", [])
49
- links = portfolio.query_links(skills)
 
 
 
 
 
 
 
50
 
51
- # Generate cold email
52
- email = chain.write_mail(job, links, username, client_name)
53
  st.code(email, language="markdown")
 
 
54
 
55
  except Exception as e:
56
  st.error(f"❌ An Error Occurred: {str(e)}")
57
 
58
 
59
  if __name__ == "__main__":
60
- create_streamlit_app()
 
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')}")
 
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
+ # Debugging: Print fetched data
51
+ st.write(f"**Debug:** Skills: {skills}")
52
+ st.write(f"**Debug:** Portfolio Links: {links}")
53
+
54
+ # Generate cold email
55
+ email = llm.write_mail(job, links, username, client_name)
56
+
57
+ # Debugging: Print raw email output
58
+ st.write(f"**Debug:** Generated Email: {email}")
59
 
60
+ # Display email
61
+ if email:
62
  st.code(email, language="markdown")
63
+ else:
64
+ st.error("⚠️ Failed to generate an email.")
65
 
66
  except Exception as e:
67
  st.error(f"❌ An Error Occurred: {str(e)}")
68
 
69
 
70
  if __name__ == "__main__":
71
+ create_streamlit_app(chain, portfolio, clean_text)