siddhartharya commited on
Commit
83c06a2
·
verified ·
1 Parent(s): d837646

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -14
app.py CHANGED
@@ -69,7 +69,7 @@ class AutonomousEmailAgent:
69
  - Candidate's Skills: {', '.join(self.skills)}
70
  - Candidate's Experiences: {', '.join([exp['title'] for exp in self.experiences])}
71
 
72
- Generate the email using this structure and make it compelling and tailored to the company and role.
73
  """
74
 
75
  return self.send_request_to_llm(reasoning_prompt)
@@ -112,19 +112,30 @@ class AutonomousEmailAgent:
112
  return "Error: Unable to generate response."
113
 
114
  def format_email(self, llm_response):
115
- # Remove unnecessary tabs and spaces and format consistently
116
- lines = [line.strip() for line in llm_response.split("\n")]
117
- formatted_email = "\n\n".join([line for line in lines if line])
118
-
119
- signature = f"""
120
- Best regards,
121
- {self.user_name}
122
- Email: {self.email}
123
- Phone: {self.phone}
124
- LinkedIn: {self.linkedin}
125
- """
126
-
127
- return f"{formatted_email}\n\n{signature.strip()}"
 
 
 
 
 
 
 
 
 
 
 
128
 
129
  # Gradio UI setup remains unchanged
130
  def gradio_ui():
 
69
  - Candidate's Skills: {', '.join(self.skills)}
70
  - Candidate's Experiences: {', '.join([exp['title'] for exp in self.experiences])}
71
 
72
+ Generate the email using this structure and ensure it is within {self.word_limit} words.
73
  """
74
 
75
  return self.send_request_to_llm(reasoning_prompt)
 
112
  return "Error: Unable to generate response."
113
 
114
  def format_email(self, llm_response):
115
+ # Clean and format the email
116
+ lines = [line.strip() for line in llm_response.split("\n") if line.strip()]
117
+ formatted_email = "\n\n".join(lines)
118
+
119
+ # Truncate the email if it exceeds the word limit
120
+ word_count = len(formatted_email.split())
121
+ if word_count > self.word_limit:
122
+ truncated_email = " ".join(formatted_email.split()[:self.word_limit])
123
+ formatted_email = truncated_email + "..."
124
+
125
+ # Prepare the signature
126
+ signature = (
127
+ f"Best regards,\n"
128
+ f"{self.user_name}\n"
129
+ f"Email: {self.email}\n"
130
+ f"Phone: {self.phone}\n"
131
+ f"LinkedIn: {self.linkedin}"
132
+ )
133
+
134
+ # Ensure only one "Best regards" section
135
+ if "Best regards" in formatted_email:
136
+ formatted_email = formatted_email.split("Best regards")[0].strip()
137
+
138
+ return f"{formatted_email}\n\n{signature}"
139
 
140
  # Gradio UI setup remains unchanged
141
  def gradio_ui():