siddhartharya commited on
Commit
cc8da7b
·
verified ·
1 Parent(s): 656c777

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
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 ensure it is within {self.word_limit} words.
73
  """
74
 
75
  return self.send_request_to_llm(reasoning_prompt)
@@ -116,11 +116,13 @@ class AutonomousEmailAgent:
116
  paragraphs = [line.strip() for line in llm_response.split("\n") if line.strip()]
117
  formatted_email = "\n\n".join(paragraphs)
118
 
119
- # Enforce word limit without breaking the structure
120
  words = formatted_email.split()
121
  if len(words) > self.word_limit:
122
  truncated_email = " ".join(words[:self.word_limit])
123
- formatted_email = truncated_email + "..."
 
 
124
 
125
  # Add the closing section with a call to action
126
  closing_section = (
@@ -138,7 +140,7 @@ class AutonomousEmailAgent:
138
  f"LinkedIn: {self.linkedin}"
139
  )
140
 
141
- # Ensure the signature and closing are not duplicated and formatted neatly
142
  if "Best regards" in formatted_email:
143
  formatted_email = formatted_email.split("Best regards")[0].strip()
144
 
 
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, but complete the email logically.
73
  """
74
 
75
  return self.send_request_to_llm(reasoning_prompt)
 
116
  paragraphs = [line.strip() for line in llm_response.split("\n") if line.strip()]
117
  formatted_email = "\n\n".join(paragraphs)
118
 
119
+ # Ensure the email stays within the word limit and retains logical coherence
120
  words = formatted_email.split()
121
  if len(words) > self.word_limit:
122
  truncated_email = " ".join(words[:self.word_limit])
123
+ if not truncated_email.endswith((".", "!", "?")):
124
+ truncated_email += "..."
125
+ formatted_email = truncated_email
126
 
127
  # Add the closing section with a call to action
128
  closing_section = (
 
140
  f"LinkedIn: {self.linkedin}"
141
  )
142
 
143
+ # Ensure only one "Best regards" section and remove any duplicate signatures
144
  if "Best regards" in formatted_email:
145
  formatted_email = formatted_email.split("Best regards")[0].strip()
146