-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathquick_test.py
More file actions
158 lines (133 loc) · 6.59 KB
/
quick_test.py
File metadata and controls
158 lines (133 loc) · 6.59 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
152
153
154
155
156
157
158
#!/usr/bin/env python3
import requests
import json
from datetime import datetime
class QuickAPITest:
def __init__(self, base_url="https://careershift-app.preview.emergentagent.com/api"):
self.base_url = base_url
self.token = None
def register_fresh_user(self):
"""Register a fresh user to avoid usage limits"""
timestamp = datetime.now().strftime('%H%M%S')
user_data = {
"name": f"Test User {timestamp}",
"email": f"test{timestamp}@example.com",
"password": "TestPass123!"
}
response = requests.post(f"{self.base_url}/auth/register", json=user_data, timeout=30)
if response.status_code == 200:
data = response.json()
self.token = data.get('access_token')
print(f"✅ Registered fresh user: {user_data['email']}")
return True
else:
print(f"❌ Registration failed: {response.status_code} - {response.text}")
return False
def test_critical_features(self):
"""Test the critical features mentioned in review request"""
if not self.token:
print("❌ No auth token available")
return False
headers = {'Authorization': f'Bearer {self.token}', 'Content-Type': 'application/json'}
print("\n🎯 Testing Critical AI Features:")
# 1. CV Generation (Superior Hybrid Resume)
print("\n1️⃣ CV Generation (Superior Hybrid Resume)")
cv_request = {
"resume_text": """John Doe
Senior Software Engineer with 5 years experience
Experience:
• Senior Software Engineer at TechCorp (2020-2024)
- Built ML pipelines using Python and TensorFlow
- Developed REST APIs with FastAPI and Django
- Worked with AWS cloud services including EC2, S3, and Lambda
- Led a team of 3 developers on machine learning projects
Education:
Bachelor's degree in Computer Science from State University
Skills: Python, JavaScript, React, SQL, Docker, Kubernetes, Machine Learning, TensorFlow, PyTorch, AWS, FastAPI, Django""",
"target_role_id": "ml_engineer",
"region": "us"
}
try:
response = requests.post(f"{self.base_url}/cv/generate", json=cv_request, headers=headers, timeout=60)
if response.status_code == 200:
data = response.json()
print(f" ✅ CV Generated - ID: {data.get('cv_id', 'N/A')}")
print(f" ✅ Target Role: {data.get('target_role', 'N/A')}")
print(f" ✅ Versions: {len(data.get('versions', []))}")
else:
print(f" ❌ CV Generation failed: {response.status_code} - {response.text[:200]}")
except Exception as e:
print(f" ❌ CV Generation error: {str(e)}")
# 2. Resume Scanner
print("\n2️⃣ Resume Scanner (ATS Analysis)")
scan_request = {
"resume_text": """Sarah Johnson
Senior Software Engineer
Experience:
• Senior Software Engineer at Microsoft (2020-2024)
- Led development of cloud-based ML solutions using Python and Azure
- Built scalable APIs serving 1M+ requests daily using FastAPI
- Implemented CI/CD pipelines reducing deployment time by 60%
Skills: Python, JavaScript, React, TensorFlow, PyTorch, AWS, Azure, Docker, Kubernetes, Machine Learning""",
"target_role_id": "ai_ml_engineer"
}
try:
response = requests.post(f"{self.base_url}/resume/scan", json=scan_request, headers=headers, timeout=60)
if response.status_code == 200:
data = response.json()
print(f" ✅ Resume Scanned - ATS Score: {data.get('ats_score', 0)}/100")
print(f" ✅ Human Appeal: {data.get('human_appeal_score', 0)}/100")
print(f" ✅ Overall Grade: {data.get('overall_grade', 'N/A')}")
else:
print(f" ❌ Resume Scanner failed: {response.status_code} - {response.text[:200]}")
except Exception as e:
print(f" ❌ Resume Scanner error: {str(e)}")
# 3. Interview Prep (Haiku for questions)
print("\n3️⃣ Interview Prep (Question Generation with Haiku)")
question_request = {
"role_id": "ml_engineer",
"categories": ["technical", "behavioral"],
"count": 5
}
try:
response = requests.post(f"{self.base_url}/interview-prep/generate", json=question_request, headers=headers, timeout=30)
if response.status_code == 200:
data = response.json()
questions = data.get('questions', [])
print(f" ✅ Questions Generated: {len(questions)}")
print(f" ✅ Category Breakdown: {data.get('category_breakdown', {})}")
else:
print(f" ❌ Question Generation failed: {response.status_code} - {response.text[:200]}")
except Exception as e:
print(f" ❌ Question Generation error: {str(e)}")
# 4. Interview Feedback (Sonnet)
print("\n4️⃣ Interview Feedback (Sonnet)")
feedback_request = {
"question": "Explain the bias-variance tradeoff in machine learning",
"answer": "The bias-variance tradeoff is about balancing model complexity. High bias means underfitting, high variance means overfitting. We use techniques like cross-validation to find the right balance.",
"role_id": "ml_engineer",
"category": "technical"
}
try:
response = requests.post(f"{self.base_url}/interview-prep/feedback", json=feedback_request, headers=headers, timeout=30)
if response.status_code == 200:
data = response.json()
print(f" ✅ Feedback Generated - Score: {data.get('score', 0)}/100")
print(f" ✅ Strengths: {len(data.get('strengths', []))}")
print(f" ✅ Improvements: {len(data.get('improvements', []))}")
else:
print(f" ❌ Interview Feedback failed: {response.status_code} - {response.text[:200]}")
except Exception as e:
print(f" ❌ Interview Feedback error: {str(e)}")
print("\n✅ Critical feature testing completed!")
return True
def main():
tester = QuickAPITest()
print("🚀 Quick Test of Critical AI Features After Model Fix")
print("=" * 60)
if tester.register_fresh_user():
tester.test_critical_features()
else:
print("❌ Could not register fresh user for testing")
if __name__ == "__main__":
main()