Update app.py
Browse files
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
|
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 |
-
#
|
116 |
-
lines = [line.strip() for line in llm_response.split("\n")]
|
117 |
-
formatted_email = "\n\n".join(
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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():
|