siddhartharya
commited on
Commit
•
ab5ba21
1
Parent(s):
0707373
Update app.py
Browse files
app.py
CHANGED
@@ -22,39 +22,53 @@ class EmailAgent:
|
|
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("
|
26 |
if not self.company_name:
|
27 |
-
print("
|
28 |
|
29 |
# Action: Fetch LinkedIn data via Proxycurl
|
30 |
def fetch_linkedin_data(self):
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
response = requests.get(url, headers=headers)
|
37 |
-
if response.status_code == 200:
|
38 |
-
data = response.json()
|
39 |
-
self.bio = data.get("summary", "No bio available")
|
40 |
-
self.skills = data.get("skills", [])
|
41 |
-
self.experiences = data.get("experiences", [])
|
42 |
else:
|
43 |
-
print("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
|
45 |
# Action: Fetch company information via Proxycurl
|
46 |
def fetch_company_info(self):
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
}
|
51 |
-
url = f"https://nubela.co/proxycurl/api/v2/linkedin/company?company_name={self.company_name}"
|
52 |
-
response = requests.get(url, headers=headers)
|
53 |
-
if response.status_code == 200:
|
54 |
-
data = response.json()
|
55 |
-
self.company_info = data.get("description", "No detailed company info available.")
|
56 |
else:
|
57 |
-
print(f"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
|
59 |
# Action: Fetch role description
|
60 |
def fetch_role_description(self):
|
@@ -64,9 +78,9 @@ class EmailAgent:
|
|
64 |
# Reflection: Check if the data is sufficient to generate an email
|
65 |
def reflect_on_data(self):
|
66 |
print("Reflection: Do I have enough data to generate the email?")
|
|
|
67 |
if not self.bio or not self.skills or not self.company_info:
|
68 |
-
print("
|
69 |
-
return False
|
70 |
return True
|
71 |
|
72 |
# Action: Generate the email using Groq Cloud LLM
|
|
|
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):
|
31 |
+
if not self.linkedin_url:
|
32 |
+
print("Action: No LinkedIn URL provided, using default bio.")
|
33 |
+
self.bio = "A professional with diverse experience."
|
34 |
+
self.skills = ["Adaptable", "Hardworking"]
|
35 |
+
self.experiences = ["Worked across various industries"]
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
else:
|
37 |
+
print("Action: Fetching LinkedIn data from Proxycurl.")
|
38 |
+
headers = {
|
39 |
+
"Authorization": f"Bearer {proxycurl_api_key}",
|
40 |
+
}
|
41 |
+
url = f"https://nubela.co/proxycurl/api/v2/linkedin?url={self.linkedin_url}"
|
42 |
+
response = requests.get(url, headers=headers)
|
43 |
+
if response.status_code == 200:
|
44 |
+
data = response.json()
|
45 |
+
self.bio = data.get("summary", "No bio available")
|
46 |
+
self.skills = data.get("skills", [])
|
47 |
+
self.experiences = data.get("experiences", [])
|
48 |
+
else:
|
49 |
+
print("Error: Unable to fetch LinkedIn profile. Using default bio.")
|
50 |
+
self.bio = "A professional with diverse experience."
|
51 |
+
self.skills = ["Adaptable", "Hardworking"]
|
52 |
+
self.experiences = ["Worked across various industries"]
|
53 |
|
54 |
# Action: Fetch company information via Proxycurl
|
55 |
def fetch_company_info(self):
|
56 |
+
if not self.company_name:
|
57 |
+
print("Action: No company name provided, using default company info.")
|
58 |
+
self.company_info = "A leading company in its field, offering innovative solutions."
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
else:
|
60 |
+
print(f"Action: Fetching company info for {self.company_name}.")
|
61 |
+
headers = {
|
62 |
+
"Authorization": f"Bearer {proxycurl_api_key}",
|
63 |
+
}
|
64 |
+
url = f"https://nubela.co/proxycurl/api/v2/linkedin/company?company_name={self.company_name}"
|
65 |
+
response = requests.get(url, headers=headers)
|
66 |
+
if response.status_code == 200:
|
67 |
+
data = response.json()
|
68 |
+
self.company_info = data.get("description", "No detailed company info available.")
|
69 |
+
else:
|
70 |
+
print(f"Error: Unable to fetch company info for {self.company_name}. Using default info.")
|
71 |
+
self.company_info = "A leading company in its field, offering innovative solutions."
|
72 |
|
73 |
# Action: Fetch role description
|
74 |
def fetch_role_description(self):
|
|
|
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
|