Update app.py
Browse files
app.py
CHANGED
|
@@ -60,7 +60,7 @@ class EmailAgent:
|
|
| 60 |
def fetch_company_info(self):
|
| 61 |
if not self.company_name:
|
| 62 |
print("Action: No company name provided, using default company info.")
|
| 63 |
-
self.company_info = "A leading company in its field
|
| 64 |
else:
|
| 65 |
print(f"Action: Fetching company info for {self.company_name}.")
|
| 66 |
headers = {"Authorization": f"Bearer {proxycurl_api_key}"}
|
|
@@ -71,7 +71,7 @@ class EmailAgent:
|
|
| 71 |
self.company_info = data.get("description", "No detailed company info available.")
|
| 72 |
else:
|
| 73 |
print(f"Error: Unable to fetch company info for {self.company_name}. Using default info.")
|
| 74 |
-
self.company_info = "A leading company in its field
|
| 75 |
|
| 76 |
# Action: Scrape the company's website for role-specific information or use defaults
|
| 77 |
def scrape_role_from_website(self):
|
|
@@ -103,7 +103,7 @@ class EmailAgent:
|
|
| 103 |
# Action: Use default logic for role description if no role is available
|
| 104 |
def use_default_role_description(self):
|
| 105 |
print(f"Action: Using default logic for the role of {self.role}.")
|
| 106 |
-
self.role_description = f"The role of {self.role} at {self.company_name} involves
|
| 107 |
|
| 108 |
# Reflection: Check if we have enough data to generate the email
|
| 109 |
def reflect_on_data(self):
|
|
@@ -115,17 +115,20 @@ class EmailAgent:
|
|
| 115 |
# Final Action: Generate the email using Groq Cloud LLM based on gathered data
|
| 116 |
def generate_email(self):
|
| 117 |
print("Action: Generating the email with the gathered information.")
|
|
|
|
|
|
|
| 118 |
prompt = f"""
|
| 119 |
Write a professional email applying for the {self.role} position at {self.company_name}.
|
| 120 |
-
The candidate’s bio is: {self.bio}.
|
| 121 |
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
|
|
|
| 125 |
|
| 126 |
-
|
| 127 |
-
The role involves: {self.role_description}.
|
| 128 |
|
|
|
|
|
|
|
| 129 |
End the email with this signature:
|
| 130 |
Best regards,
|
| 131 |
{self.user_name}
|
|
@@ -137,7 +140,10 @@ class EmailAgent:
|
|
| 137 |
"""
|
| 138 |
|
| 139 |
url = "https://api.groq.com/openai/v1/chat/completions"
|
| 140 |
-
headers = {
|
|
|
|
|
|
|
|
|
|
| 141 |
|
| 142 |
data = {
|
| 143 |
"messages": [{"role": "user", "content": prompt}],
|
|
@@ -174,7 +180,7 @@ def gradio_ui():
|
|
| 174 |
email_input = gr.Textbox(label="Your Email Address", placeholder="Enter your email address")
|
| 175 |
phone_input = gr.Textbox(label="Your Phone Number", placeholder="Enter your phone number")
|
| 176 |
linkedin_input = gr.Textbox(label="Your LinkedIn URL", placeholder="Enter your LinkedIn profile URL")
|
| 177 |
-
word_limit_slider = gr.Slider(minimum=50, maximum=300, step=10, label="Email Word Limit", value=150)
|
| 178 |
|
| 179 |
# Output field
|
| 180 |
email_output = gr.Textbox(label="Generated Email", placeholder="Your generated email will appear here", lines=10)
|
|
|
|
| 60 |
def fetch_company_info(self):
|
| 61 |
if not self.company_name:
|
| 62 |
print("Action: No company name provided, using default company info.")
|
| 63 |
+
self.company_info = "A leading company in its field."
|
| 64 |
else:
|
| 65 |
print(f"Action: Fetching company info for {self.company_name}.")
|
| 66 |
headers = {"Authorization": f"Bearer {proxycurl_api_key}"}
|
|
|
|
| 71 |
self.company_info = data.get("description", "No detailed company info available.")
|
| 72 |
else:
|
| 73 |
print(f"Error: Unable to fetch company info for {self.company_name}. Using default info.")
|
| 74 |
+
self.company_info = "A leading company in its field."
|
| 75 |
|
| 76 |
# Action: Scrape the company's website for role-specific information or use defaults
|
| 77 |
def scrape_role_from_website(self):
|
|
|
|
| 103 |
# Action: Use default logic for role description if no role is available
|
| 104 |
def use_default_role_description(self):
|
| 105 |
print(f"Action: Using default logic for the role of {self.role}.")
|
| 106 |
+
self.role_description = f"The role of {self.role} at {self.company_name} involves leadership and management."
|
| 107 |
|
| 108 |
# Reflection: Check if we have enough data to generate the email
|
| 109 |
def reflect_on_data(self):
|
|
|
|
| 115 |
# Final Action: Generate the email using Groq Cloud LLM based on gathered data
|
| 116 |
def generate_email(self):
|
| 117 |
print("Action: Generating the email with the gathered information.")
|
| 118 |
+
|
| 119 |
+
# Updated and fully dynamic LLM prompt
|
| 120 |
prompt = f"""
|
| 121 |
Write a professional email applying for the {self.role} position at {self.company_name}.
|
|
|
|
| 122 |
|
| 123 |
+
Use the following information:
|
| 124 |
+
- The candidate’s LinkedIn bio: {self.bio}.
|
| 125 |
+
- The candidate’s most relevant skills: {', '.join(self.skills)}.
|
| 126 |
+
- The candidate’s professional experience: {', '.join([exp['title'] for exp in self.experiences])}.
|
| 127 |
|
| 128 |
+
Please research the company's public information. If no company-specific information is available, use general knowledge about the company's industry.
|
|
|
|
| 129 |
|
| 130 |
+
Tailor the email dynamically to the role of **{self.role}** at {self.company_name}, aligning the candidate's skills and experiences with the expected responsibilities of the role and the company’s operations.
|
| 131 |
+
|
| 132 |
End the email with this signature:
|
| 133 |
Best regards,
|
| 134 |
{self.user_name}
|
|
|
|
| 140 |
"""
|
| 141 |
|
| 142 |
url = "https://api.groq.com/openai/v1/chat/completions"
|
| 143 |
+
headers = {
|
| 144 |
+
"Authorization": f"Bearer {groq_api_key}",
|
| 145 |
+
"Content-Type": "application/json",
|
| 146 |
+
}
|
| 147 |
|
| 148 |
data = {
|
| 149 |
"messages": [{"role": "user", "content": prompt}],
|
|
|
|
| 180 |
email_input = gr.Textbox(label="Your Email Address", placeholder="Enter your email address")
|
| 181 |
phone_input = gr.Textbox(label="Your Phone Number", placeholder="Enter your phone number")
|
| 182 |
linkedin_input = gr.Textbox(label="Your LinkedIn URL", placeholder="Enter your LinkedIn profile URL")
|
| 183 |
+
word_limit_slider = gr.Slider(minimum=50, maximum=300, step=10, label="Email Word Limit", value=150)
|
| 184 |
|
| 185 |
# Output field
|
| 186 |
email_output = gr.Textbox(label="Generated Email", placeholder="Your generated email will appear here", lines=10)
|