Manikanta3776 commited on
Commit
77d0e37
·
verified ·
1 Parent(s): 8c30cd3

Update chains.py

Browse files
Files changed (1) hide show
  1. chains.py +104 -6
chains.py CHANGED
@@ -18,7 +18,7 @@ class Chain:
18
  {page_data}
19
  ### INSTRUCTION:
20
  The scraped text is from the career's page of a website.
21
- Your job is to extract the job postings and return them in JSON format containing the following keys: `role`, `experience`, `skills` and `description`.
22
  Only return the valid JSON.
23
  ### VALID JSON (NO PREAMBLE):
24
  """
@@ -32,7 +32,15 @@ class Chain:
32
  raise OutputParserException("Context too big. Unable to parse jobs.")
33
  return res if isinstance(res, list) else [res]
34
 
35
- def write_mail(self, job, links, username="Thamani", client_name="Hiring Manager"):
 
 
 
 
 
 
 
 
36
  prompt_email = PromptTemplate.from_template(
37
  """
38
  ### JOB DETAILS:
@@ -44,9 +52,12 @@ class Chain:
44
 
45
  ### INSTRUCTION:
46
  You are {username}, a motivated MCA graduate with strong technical and analytical skills, seeking an opportunity to contribute to {company_name} as a {job_title}.
47
- Craft a **compelling and professional** cold email to {client_name}, demonstrating how your academic background, technical expertise, and problem-solving abilities align with the role’s requirements.
48
- Effectively highlight your **skills, relevant projects, certifications, or portfolio links**: {link_list}, showcasing how you can add value to the company.
49
- Ensure the email is **concise, persuasive, and professionally structured**, making a strong impression on the hiring manager.
 
 
 
50
  ### EMAIL (NO PREAMBLE):
51
  """
52
  )
@@ -73,11 +84,98 @@ class Chain:
73
  "job_description": job_description,
74
  "link_list": formatted_links,
75
  "username": username,
76
- "client_name": client_name
 
 
77
  })
78
 
79
  return res.content
80
 
81
  if __name__ == "__main__":
82
  print(os.getenv("GROQ_API_KEY"))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
 
 
18
  {page_data}
19
  ### INSTRUCTION:
20
  The scraped text is from the career's page of a website.
21
+ Your job is to extract the job postings and return them in JSON format containing the following keys: `role`, `experience`, `skills`, and `description`.
22
  Only return the valid JSON.
23
  ### VALID JSON (NO PREAMBLE):
24
  """
 
32
  raise OutputParserException("Context too big. Unable to parse jobs.")
33
  return res if isinstance(res, list) else [res]
34
 
35
+ def write_mail(self, job, links, username="Thamani", client_name="Hiring Manager", email_style="Formal"):
36
+ """Generates cold emails based on the selected style."""
37
+
38
+ style_instructions = {
39
+ "Formal": "Maintain a professional and polished tone. Focus on achievements and qualifications.",
40
+ "Casual": "Use a friendly, engaging tone. Keep it light while still showcasing strengths.",
41
+ "Persuasive": "Be compelling and assertive. Highlight why you are the perfect fit with strong language."
42
+ }
43
+
44
  prompt_email = PromptTemplate.from_template(
45
  """
46
  ### JOB DETAILS:
 
52
 
53
  ### INSTRUCTION:
54
  You are {username}, a motivated MCA graduate with strong technical and analytical skills, seeking an opportunity to contribute to {company_name} as a {job_title}.
55
+ Craft a **{email_style.lower()} cold email** to {client_name} demonstrating your skills, projects, and value.
56
+
57
+ Style Instruction: {style_instruction}
58
+
59
+ Highlight relevant projects, certifications, or portfolio links: {link_list}.
60
+
61
  ### EMAIL (NO PREAMBLE):
62
  """
63
  )
 
84
  "job_description": job_description,
85
  "link_list": formatted_links,
86
  "username": username,
87
+ "client_name": client_name,
88
+ "email_style": email_style,
89
+ "style_instruction": style_instructions[email_style]
90
  })
91
 
92
  return res.content
93
 
94
  if __name__ == "__main__":
95
  print(os.getenv("GROQ_API_KEY"))
96
+
97
+
98
+
99
+ # import os
100
+ # from langchain_groq import ChatGroq
101
+ # from langchain_core.prompts import PromptTemplate
102
+ # from langchain_core.output_parsers import JsonOutputParser
103
+ # from langchain_core.exceptions import OutputParserException
104
+ # from dotenv import load_dotenv
105
+
106
+ # load_dotenv()
107
+
108
+ # class Chain:
109
+ # def __init__(self):
110
+ # self.llm = ChatGroq(temperature=0, groq_api_key=os.getenv("GROQ_API_KEY"), model_name="llama-3.3-70b-versatile")
111
+
112
+ # def extract_jobs(self, cleaned_text):
113
+ # prompt_extract = PromptTemplate.from_template(
114
+ # """
115
+ # ### SCRAPED TEXT FROM WEBSITE:
116
+ # {page_data}
117
+ # ### INSTRUCTION:
118
+ # The scraped text is from the career's page of a website.
119
+ # Your job is to extract the job postings and return them in JSON format containing the following keys: `role`, `experience`, `skills` and `description`.
120
+ # Only return the valid JSON.
121
+ # ### VALID JSON (NO PREAMBLE):
122
+ # """
123
+ # )
124
+ # chain_extract = prompt_extract | self.llm
125
+ # res = chain_extract.invoke(input={"page_data": cleaned_text})
126
+ # try:
127
+ # json_parser = JsonOutputParser()
128
+ # res = json_parser.parse(res.content)
129
+ # except OutputParserException:
130
+ # raise OutputParserException("Context too big. Unable to parse jobs.")
131
+ # return res if isinstance(res, list) else [res]
132
+
133
+ # def write_mail(self, job, links, username="Thamani", client_name="Hiring Manager"):
134
+ # prompt_email = PromptTemplate.from_template(
135
+ # """
136
+ # ### JOB DETAILS:
137
+ # - Role: {job_title}
138
+ # - Company: {company_name}
139
+ # - Experience Required: {experience}
140
+ # - Skills: {skills}
141
+ # - Description: {job_description}
142
+
143
+ # ### INSTRUCTION:
144
+ # You are {username}, a motivated MCA graduate with strong technical and analytical skills, seeking an opportunity to contribute to {company_name} as a {job_title}.
145
+ # Craft a **compelling and professional** cold email to {client_name}, demonstrating how your academic background, technical expertise, and problem-solving abilities align with the role’s requirements.
146
+ # Effectively highlight your **skills, relevant projects, certifications, or portfolio links**: {link_list}, showcasing how you can add value to the company.
147
+ # Ensure the email is **concise, persuasive, and professionally structured**, making a strong impression on the hiring manager.
148
+ # ### EMAIL (NO PREAMBLE):
149
+ # """
150
+ # )
151
+
152
+ # chain_email = prompt_email | self.llm
153
+
154
+ # # Extract job details, handling missing fields
155
+ # job_title = job.get("role", "the position")
156
+ # company_name = job.get("company", "the company")
157
+ # experience = job.get("experience", "not specified")
158
+ # skills = ", ".join(job.get("skills", [])) or "not mentioned"
159
+ # job_description = job.get("description", "No description provided.")
160
+
161
+ # # Filter out empty links
162
+ # valid_links = [link for link in links if link]
163
+ # formatted_links = "\n".join(f"- {link}" for link in valid_links) if valid_links else "No portfolio links provided."
164
+
165
+ # # Generate email
166
+ # res = chain_email.invoke({
167
+ # "job_title": job_title,
168
+ # "company_name": company_name,
169
+ # "experience": experience,
170
+ # "skills": skills,
171
+ # "job_description": job_description,
172
+ # "link_list": formatted_links,
173
+ # "username": username,
174
+ # "client_name": client_name
175
+ # })
176
+
177
+ # return res.content
178
+
179
+ # if __name__ == "__main__":
180
+ # print(os.getenv("GROQ_API_KEY"))
181