lavanyalr/resume_screening_app
0
1#!/usr/bin/env python32"""3Debug script to test the resume screening pipeline step by step.4This will help identify where the JSON parsing issue is occurring.5"""6 7import os8import json9from dotenv import load_dotenv10 11# Load environment variables12load_dotenv()13 14def test_api_key():15 """Test if API key is properly configured."""16 api_key = os.getenv("OPENAI_API_KEY")17 if not api_key or api_key == "YOUR_ACTUAL_API_KEY_HERE":18 print("❌ API key not configured properly")19 print("Please set OPENAI_API_KEY in your .env file")20 return False21 else:22 print("✅ API key configured")23 return True24 25def test_imports():26 """Test if all imports work correctly."""27 try:28 from app.backend.agents.resume_extractor_agent import analyze_resume29 from app.backend.agents.jd_extractor_agent import analyze_jd30 from app.backend.agents.candidate_evaluation_agent import evaluate_candidate31 from app.backend.parsepdf import parse_pdf32 print("✅ All imports successful")33 return True34 except ImportError as e:35 print(f"❌ Import error: {e}")36 return False37 38def test_json_parsing():39 """Test JSON parsing with sample data."""40 sample_json = '{"test": "value", "number": 123}'41 try:42 parsed = json.loads(sample_json)43 print("✅ JSON parsing works correctly")44 return True45 except json.JSONDecodeError as e:46 print(f"❌ JSON parsing error: {e}")47 return False48 49def main():50 print("🔍 Debugging Resume Screening Application")51 print("=" * 50)52 53 # Test API key54 if not test_api_key():55 return56 57 # Test imports58 if not test_imports():59 return60 61 # Test JSON parsing62 if not test_json_parsing():63 return64 65 print("\n✅ All basic tests passed!")66 print("\nIf you're still getting JSON errors, the issue is likely:")67 print("1. Empty response from OpenAI API")68 print("2. Malformed JSON in the response")69 print("3. API key issues causing empty responses")70 print("\nCheck the server logs for detailed debugging information.")71 72if __name__ == "__main__":73 main()74 