Update app.py
Browse files
app.py
CHANGED
|
@@ -7,11 +7,15 @@ proxycurl_api_key = os.getenv("PROXYCURL_API_KEY") # Proxycurl API key
|
|
| 7 |
groq_api_key = os.getenv("GROQ_CLOUD_API_KEY") # Groq Cloud API key
|
| 8 |
|
| 9 |
class EmailAgent:
|
| 10 |
-
def __init__(self, linkedin_url, company_name, role, word_limit):
|
| 11 |
self.linkedin_url = linkedin_url
|
| 12 |
self.company_name = company_name
|
| 13 |
self.role = role
|
| 14 |
self.word_limit = word_limit
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
self.bio = None
|
| 16 |
self.skills = []
|
| 17 |
self.experiences = []
|
|
@@ -21,10 +25,6 @@ class EmailAgent:
|
|
| 21 |
# Reason: Decide what information is needed
|
| 22 |
def reason_about_data(self):
|
| 23 |
print("Reasoning: I need LinkedIn data, company info, and role description.")
|
| 24 |
-
if not self.linkedin_url:
|
| 25 |
-
print("Warning: LinkedIn URL missing. Will proceed with default bio.")
|
| 26 |
-
if not self.company_name:
|
| 27 |
-
print("Warning: Company name missing. Will proceed with default company info.")
|
| 28 |
|
| 29 |
# Action: Fetch LinkedIn data via Proxycurl
|
| 30 |
def fetch_linkedin_data(self):
|
|
@@ -73,14 +73,12 @@ class EmailAgent:
|
|
| 73 |
# Action: Fetch role description
|
| 74 |
def fetch_role_description(self):
|
| 75 |
print(f"Action: Fetching role description for {self.role}.")
|
| 76 |
-
self.role_description = f"The role of {self.role} at {self.company_name} involves
|
| 77 |
|
| 78 |
# Reflection: Check if the data is sufficient to generate an email
|
| 79 |
def reflect_on_data(self):
|
| 80 |
print("Reflection: Do I have enough data to generate the email?")
|
| 81 |
# Allow the email to be generated with default values if data is missing
|
| 82 |
-
if not self.bio or not self.skills or not self.company_info:
|
| 83 |
-
print("Warning: Some critical information is missing. Proceeding with default values.")
|
| 84 |
return True
|
| 85 |
|
| 86 |
# Action: Generate the email using Groq Cloud LLM
|
|
@@ -89,11 +87,21 @@ class EmailAgent:
|
|
| 89 |
prompt = f"""
|
| 90 |
Write a professional email applying for the {self.role} position at {self.company_name}.
|
| 91 |
The candidate’s bio is: {self.bio}.
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
The email should not exceed {self.word_limit} words.
|
| 98 |
"""
|
| 99 |
|
|
@@ -141,8 +149,8 @@ def gradio_ui():
|
|
| 141 |
email_output = gr.Textbox(label="Generated Email", placeholder="Your generated email will appear here", lines=10)
|
| 142 |
|
| 143 |
# Function to create and run the email agent
|
| 144 |
-
def create_email(name, company_name, role, email, phone,
|
| 145 |
-
agent = EmailAgent(
|
| 146 |
return agent.run()
|
| 147 |
|
| 148 |
# Gradio interface
|
|
|
|
| 7 |
groq_api_key = os.getenv("GROQ_CLOUD_API_KEY") # Groq Cloud API key
|
| 8 |
|
| 9 |
class EmailAgent:
|
| 10 |
+
def __init__(self, linkedin_url, company_name, role, word_limit, user_name, email, phone, linkedin):
|
| 11 |
self.linkedin_url = linkedin_url
|
| 12 |
self.company_name = company_name
|
| 13 |
self.role = role
|
| 14 |
self.word_limit = word_limit
|
| 15 |
+
self.user_name = user_name
|
| 16 |
+
self.email = email
|
| 17 |
+
self.phone = phone
|
| 18 |
+
self.linkedin = linkedin
|
| 19 |
self.bio = None
|
| 20 |
self.skills = []
|
| 21 |
self.experiences = []
|
|
|
|
| 25 |
# Reason: Decide what information is needed
|
| 26 |
def reason_about_data(self):
|
| 27 |
print("Reasoning: I need LinkedIn data, company info, and role description.")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
# Action: Fetch LinkedIn data via Proxycurl
|
| 30 |
def fetch_linkedin_data(self):
|
|
|
|
| 73 |
# Action: Fetch role description
|
| 74 |
def fetch_role_description(self):
|
| 75 |
print(f"Action: Fetching role description for {self.role}.")
|
| 76 |
+
self.role_description = f"The role of {self.role} at {self.company_name} involves mentoring AI and technology students to develop their skills and progress their careers."
|
| 77 |
|
| 78 |
# Reflection: Check if the data is sufficient to generate an email
|
| 79 |
def reflect_on_data(self):
|
| 80 |
print("Reflection: Do I have enough data to generate the email?")
|
| 81 |
# Allow the email to be generated with default values if data is missing
|
|
|
|
|
|
|
| 82 |
return True
|
| 83 |
|
| 84 |
# Action: Generate the email using Groq Cloud LLM
|
|
|
|
| 87 |
prompt = f"""
|
| 88 |
Write a professional email applying for the {self.role} position at {self.company_name}.
|
| 89 |
The candidate’s bio is: {self.bio}.
|
| 90 |
+
|
| 91 |
+
Focus on relevant skills and experiences from LinkedIn, such as {', '.join(self.skills)},
|
| 92 |
+
that directly align with the role of {self.role}.
|
| 93 |
+
Highlight only the skills and experiences that relate to mentoring, AI, technology, and leadership.
|
| 94 |
+
|
| 95 |
+
The company info is: {self.company_info}.
|
| 96 |
+
The role involves: {self.role_description}.
|
| 97 |
+
|
| 98 |
+
End the email with this signature:
|
| 99 |
+
Best regards,
|
| 100 |
+
{self.user_name}
|
| 101 |
+
Email: {self.email}
|
| 102 |
+
Phone: {self.phone}
|
| 103 |
+
LinkedIn: {self.linkedin}
|
| 104 |
+
|
| 105 |
The email should not exceed {self.word_limit} words.
|
| 106 |
"""
|
| 107 |
|
|
|
|
| 149 |
email_output = gr.Textbox(label="Generated Email", placeholder="Your generated email will appear here", lines=10)
|
| 150 |
|
| 151 |
# Function to create and run the email agent
|
| 152 |
+
def create_email(name, company_name, role, email, phone, linkedin_url, word_limit):
|
| 153 |
+
agent = EmailAgent(linkedin_url, company_name, role, word_limit, name, email, phone, linkedin_url)
|
| 154 |
return agent.run()
|
| 155 |
|
| 156 |
# Gradio interface
|