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

Update chains.py

Browse files
Files changed (1) hide show
  1. chains.py +6 -89
chains.py CHANGED
@@ -40,7 +40,10 @@ class Chain:
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,7 +55,7 @@ class Chain:
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
 
@@ -85,7 +88,7 @@ class Chain:
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
 
@@ -93,89 +96,3 @@ class Chain:
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
-
 
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
+ # Convert style name to lowercase for prompt clarity
45
+ email_style_lower = email_style.lower()
46
+
47
  prompt_email = PromptTemplate.from_template(
48
  """
49
  ### JOB DETAILS:
 
55
 
56
  ### INSTRUCTION:
57
  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}.
58
+ Craft a **{email_style} cold email** to {client_name} demonstrating your skills, projects, and value.
59
 
60
  Style Instruction: {style_instruction}
61
 
 
88
  "link_list": formatted_links,
89
  "username": username,
90
  "client_name": client_name,
91
+ "email_style": email_style_lower, # Fixed Issue
92
  "style_instruction": style_instructions[email_style]
93
  })
94
 
 
96
 
97
  if __name__ == "__main__":
98
  print(os.getenv("GROQ_API_KEY"))