-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwhere_are_messages.py
More file actions
151 lines (124 loc) · 6.55 KB
/
Copy pathwhere_are_messages.py
File metadata and controls
151 lines (124 loc) · 6.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/usr/bin/env python3
"""
Quick demonstration of where outreach messages are saved in the LinkedIn Sourcing Agent
"""
import requests
import pandas as pd
import json
from datetime import datetime
print("🎯 LinkedIn Sourcing Agent - Outreach Message Storage Demo")
print("=" * 65)
# Test API to generate candidates with outreach messages
print("\n1️⃣ Generating candidates with outreach messages via API...")
response = requests.post("http://localhost:8000/source-candidates", json={
"query": "Python Developer",
"location": "San Francisco",
"limit": 2,
"job_description": "We need a Python developer with Flask/Django experience for our fintech startup.",
"export_excel": True
})
if response.status_code == 200:
data = response.json()
print(f"✅ Generated {data['candidates_found']} candidates")
# Show message in API response
print(f"\n2️⃣ Outreach message in API response:")
candidate = data['top_candidates'][0]
message = candidate.get('outreach_message', 'No message found')
print(f" Candidate: {candidate['name']}")
print(f" Message Preview: '{message[:80]}...'")
# Find the latest Excel file
import os
excel_dir = "outputs/excel_exports"
excel_files = [f for f in os.listdir(excel_dir) if f.endswith('.xlsx') and not f.startswith('~$')]
if excel_files:
latest_file = max(excel_files, key=lambda f: os.path.getmtime(os.path.join(excel_dir, f)))
excel_path = os.path.join(excel_dir, latest_file)
print(f"\n3️⃣ Checking Excel file: {latest_file}")
try:
# Check if Generated_Messages sheet exists and has content
df = pd.read_excel(excel_path, sheet_name='Generated_Messages')
if not df.empty and not df['Message_Content'].isna().all():
print("✅ Outreach messages found in Excel:")
for idx, row in df.iterrows():
if pd.notna(row['Message_Content']) and row['Message_Content'] != 'No outreach message available':
print(f" 📧 {row['Name']}: '{row['Message_Content'][:60]}...'")
print(f" Type: {row['Message_Type']}, Length: {row['Character_Count']} chars")
break
else:
print("⚠️ No outreach messages found in Excel Generated_Messages sheet")
print(" This might be because:")
print(" - CLI was used instead of API")
print(" - Messages weren't generated due to missing API keys")
except Exception as e:
print(f"❌ Error reading Excel file: {e}")
print(f"\n🎯 SUMMARY - Outreach Messages Are Saved In:")
print(f" 📊 Excel Files: outputs/excel_exports/*.xlsx → 'Generated_Messages' sheet")
print(f" 📱 API Response: JSON field 'outreach_message' for each candidate")
print(f" 📝 JSON Files: outputs/json_data/*.json (API calls only)")
else:
print(f"❌ API Error: {response.status_code}")
print("Make sure the API server is running: python api_server.py")
print(f"\n💡 Pro Tip: Use the API (/source-candidates) for outreach generation!")
print(f" CLI searches don't generate outreach messages (they're for quick candidate discovery)")
#!/usr/bin/env python3
"""
Quick demonstration of where outreach messages are saved in the LinkedIn Sourcing Agent
"""
import requests
import pandas as pd
import json
from datetime import datetime
print("🎯 LinkedIn Sourcing Agent - Outreach Message Storage Demo")
print("=" * 65)
# Test API to generate candidates with outreach messages
print("\n1️⃣ Generating candidates with outreach messages via API...")
response = requests.post("http://localhost:8000/source-candidates", json={
"query": "Python Developer",
"location": "San Francisco",
"limit": 2,
"job_description": "We need a Python developer with Flask/Django experience for our fintech startup.",
"export_excel": True
})
if response.status_code == 200:
data = response.json()
print(f"✅ Generated {data['candidates_found']} candidates")
# Show message in API response
print(f"\n2️⃣ Outreach message in API response:")
candidate = data['top_candidates'][0]
message = candidate.get('outreach_message', 'No message found')
print(f" Candidate: {candidate['name']}")
print(f" Message Preview: '{message[:80]}...'")
# Find the latest Excel file
import os
excel_dir = "outputs/excel_exports"
excel_files = [f for f in os.listdir(excel_dir) if f.endswith('.xlsx') and not f.startswith('~$')]
if excel_files:
latest_file = max(excel_files, key=lambda f: os.path.getmtime(os.path.join(excel_dir, f)))
excel_path = os.path.join(excel_dir, latest_file)
print(f"\n3️⃣ Checking Excel file: {latest_file}")
try:
# Check if Generated_Messages sheet exists and has content
df = pd.read_excel(excel_path, sheet_name='Generated_Messages')
if not df.empty and not df['Message_Content'].isna().all():
print("✅ Outreach messages found in Excel:")
for idx, row in df.iterrows():
if pd.notna(row['Message_Content']) and row['Message_Content'] != 'No outreach message available':
print(f" 📧 {row['Name']}: '{row['Message_Content'][:60]}...'")
print(f" Type: {row['Message_Type']}, Length: {row['Character_Count']} chars")
break
else:
print("⚠️ No outreach messages found in Excel Generated_Messages sheet")
print(" This might be because:")
print(" - CLI was used instead of API")
print(" - Messages weren't generated due to missing API keys")
except Exception as e:
print(f"❌ Error reading Excel file: {e}")
print(f"\n🎯 SUMMARY - Outreach Messages Are Saved In:")
print(f" 📊 Excel Files: outputs/excel_exports/*.xlsx → 'Generated_Messages' sheet")
print(f" 📱 API Response: JSON field 'outreach_message' for each candidate")
print(f" 📝 JSON Files: outputs/json_data/*.json (API calls only)")
else:
print(f"❌ API Error: {response.status_code}")
print("Make sure the API server is running: python api_server.py")
print(f"\n💡 Pro Tip: Use the API (/source-candidates) for outreach generation!")
print(f" CLI searches don't generate outreach messages (they're for quick candidate discovery)")