File size: 3,159 Bytes
4cb2665 8847fb7 7b35f58 8847fb7 c8e4d1c 7b5dd85 c8e4d1c 7b5dd85 9414722 2aff931 8c30cd3 2aff931 7b5dd85 8c30cd3 4cb2665 8847fb7 7b5dd85 4cb2665 7b5dd85 4cb2665 7b5dd85 4cb2665 7b5dd85 2aff931 8c30cd3 2aff931 8847fb7 4cb2665 7b5dd85 12be0d3 7b35f58 c8e4d1c 487a9b1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
import streamlit as st
from langchain_community.document_loaders import WebBaseLoader
from chains import Chain
from portfolio import Portfolio
from utils import clean_text
# Initialize backend services
chain = Chain()
portfolio = Portfolio()
def create_streamlit_app(llm, portfolio, clean_text):
st.set_page_config(layout="wide", page_title="Cold Email Generator", page_icon="π§")
st.title("π§ Cold Mail Generator")
# User Inputs
url_input = st.text_input("Enter a Job URL:", value="https://atliq.keka.com/careers/jobdetails/51326")
username = st.text_input("Your Name (Default: John)", value="John")
client_name = st.text_input("Recipient's Name (Default: Hiring Manager)", value="Hiring Manager")
# Dropdown to select number of emails to generate
num_emails = st.selectbox("Select Number of Emails to Generate", options=[1, 2, 3], index=0)
# Dropdown to select email style
email_style = st.selectbox("Choose Email Style", options=["Formal", "Casual", "Persuasive"], index=0)
submit_button = st.button("Generate Cold Emails")
if submit_button:
try:
st.info("π Extracting job details...")
# Load and clean job description
loader = WebBaseLoader([url_input])
page_content = loader.load().pop().page_content
cleaned_data = clean_text(page_content)
# Extract job details
jobs = llm.extract_jobs(cleaned_data)
if not jobs:
st.warning("β οΈ No job postings found. Please check the URL.")
return
# Process extracted jobs
for idx, job in enumerate(jobs, start=1):
job_title = job.get("role", "Unknown Role")
experience = job.get("experience", "Not Specified")
skills = ", ".join(job.get("skills", [])) if job.get("skills") else "Not Specified"
job_description = job.get("description", "No description available.")
# Display job details
st.subheader(f"π Job {idx}: {job_title}")
st.write(f"**Experience Required:** {experience}")
st.write(f"**Skills:** {skills}")
st.write(f"**Description:** {job_description}")
st.divider()
# Fetch relevant portfolio links
skills_list = job.get("skills", [])
portfolio_links = [link for link in portfolio.query_links(skills_list) if link]
# Generate multiple cold emails based on user selection
for i in range(num_emails):
st.subheader(f"π© Email {i+1} ({email_style} Style)")
email = llm.write_mail(job, portfolio_links, username, client_name, email_style)
if email:
st.code(email, language="markdown")
else:
st.error("β οΈ Email generation failed.")
except Exception as e:
st.error(f"β An Error Occurred: {str(e)}")
if __name__ == "__main__":
create_streamlit_app(chain, portfolio, clean_text)
|