Update app.py
Browse files
app.py
CHANGED
@@ -112,15 +112,15 @@ class AutonomousEmailAgent:
|
|
112 |
return "Error: Unable to generate response."
|
113 |
|
114 |
def format_email(self, llm_response):
|
115 |
-
#
|
116 |
paragraphs = [line.strip() for line in llm_response.split("\n") if line.strip()]
|
117 |
formatted_email = "\n\n".join(paragraphs)
|
118 |
|
119 |
-
#
|
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,11 +138,11 @@ class AutonomousEmailAgent:
|
|
138 |
f"LinkedIn: {self.linkedin}"
|
139 |
)
|
140 |
|
141 |
-
# Ensure
|
142 |
if "Best regards" in formatted_email:
|
143 |
formatted_email = formatted_email.split("Best regards")[0].strip()
|
144 |
|
145 |
-
return f"{formatted_email}
|
146 |
|
147 |
# Gradio UI setup remains unchanged
|
148 |
def gradio_ui():
|
|
|
112 |
return "Error: Unable to generate response."
|
113 |
|
114 |
def format_email(self, llm_response):
|
115 |
+
# Split the response into paragraphs for better formatting
|
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 |
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 |
|
145 |
+
return f"{formatted_email}{closing_section}\n{signature}"
|
146 |
|
147 |
# Gradio UI setup remains unchanged
|
148 |
def gradio_ui():
|