🎯 IQKiller Pro
AI-Powered Interview Preparation with PDF Upload
📄 Direct PDF Upload • 🤖 LLM Processing • 🔗 URL Analysis • 💼 Comprehensive Prep
#!/usr/bin/env python3 import gradio as gr import os import re import tempfile from pathlib import Path # PDF processing imports try: import PyPDF2 import pdfplumber PDF_SUPPORT = True except ImportError: PDF_SUPPORT = False # LLM integration imports try: import openai LLM_SUPPORT = True except ImportError: LLM_SUPPORT = False # Basic configuration OPENAI_API_KEY = os.getenv("OPENAI_API_KEY") ANTHROPIC_API_KEY = os.getenv("ANTHROPIC_API_KEY") SERPAPI_KEY = os.getenv("SERPAPI_KEY") FIRECRAWL_API_KEY = os.getenv("FIRECRAWL_API_KEY") def extract_text_from_pdf(pdf_file_path: str) -> str: """Extract text from PDF using multiple methods""" if not PDF_SUPPORT: return "❌ PDF support not available. Please install: pip install PyPDF2 pdfplumber" extracted_text = "" try: # Method 1: Try pdfplumber first (better for complex layouts) with pdfplumber.open(pdf_file_path) as pdf: text_parts = [] for page in pdf.pages: page_text = page.extract_text() if page_text: text_parts.append(page_text) extracted_text = "\n".join(text_parts) if extracted_text and len(extracted_text.strip()) > 50: return f"✅ PDF processed successfully with pdfplumber ({len(extracted_text)} characters)\n\n{extracted_text}" except Exception as e: print(f"Pdfplumber failed: {e}") try: # Method 2: Fallback to PyPDF2 with open(pdf_file_path, 'rb') as file: pdf_reader = PyPDF2.PdfReader(file) text_parts = [] for page in pdf_reader.pages: page_text = page.extract_text() if page_text: text_parts.append(page_text) extracted_text = "\n".join(text_parts) if extracted_text and len(extracted_text.strip()) > 50: return f"✅ PDF processed successfully with PyPDF2 ({len(extracted_text)} characters)\n\n{extracted_text}" except Exception as e: print(f"PyPDF2 failed: {e}") return "❌ Failed to extract text from PDF. The file might be image-based or corrupted." def enhance_resume_with_llm(raw_text: str) -> str: """Use LLM to enhance and structure the extracted resume text""" if not LLM_SUPPORT or not OPENAI_API_KEY: return raw_text try: client = openai.OpenAI(api_key=OPENAI_API_KEY) prompt = f""" You are an expert resume parser and career advisor. Please analyze and enhance this resume text by: 1. Cleaning up formatting issues and text extraction errors 2. Organizing information into clear sections 3. Highlighting key skills, technologies, and experience 4. Identifying years of experience and seniority level 5. Extracting technical and soft skills 6. Summarizing key achievements and projects Original resume text: {raw_text} Please return a well-structured, clean version that emphasizes the candidate's strengths and qualifications: """ response = client.chat.completions.create( model="gpt-4o-mini", messages=[ {"role": "system", "content": "You are an expert resume parser and career advisor. Format resumes clearly and highlight key qualifications."}, {"role": "user", "content": prompt} ], max_tokens=1500, temperature=0.3 ) enhanced_text = response.choices[0].message.content return f"🤖 LLM Enhanced Resume:\n\n{enhanced_text}\n\n---\n\nOriginal Text:\n{raw_text}" except Exception as e: print(f"LLM enhancement failed: {e}") return f"⚠️ LLM enhancement unavailable, using original text:\n\n{raw_text}" def process_pdf_upload(pdf_file) -> str: """Process uploaded PDF file and return enhanced text""" if pdf_file is None: return "❌ No PDF file uploaded." try: # Handle the uploaded file if hasattr(pdf_file, 'name'): file_path = pdf_file.name else: file_path = pdf_file # Extract text from PDF extracted_text = extract_text_from_pdf(file_path) if extracted_text.startswith("❌"): return extracted_text # Enhance with LLM if available enhanced_text = enhance_resume_with_llm(extracted_text) return enhanced_text except Exception as e: return f"❌ Error processing PDF: {str(e)}" def is_url(text: str) -> bool: """Check if text contains a URL""" url_pattern = r'https?://[^\s<>"{}|\\^`\[\]]+' return bool(re.search(url_pattern, text)) def enhanced_analysis(resume_text: str, job_text: str) -> str: """Enhanced analysis with comprehensive features""" if not resume_text.strip(): return "❌ Please provide your resume text or upload a PDF file." if not job_text.strip(): return "❌ Please provide a job description or URL." # Enhanced analysis resume_words = resume_text.lower().split() job_words = job_text.lower().split() # Detect if it's a URL is_job_url = is_url(job_text) url_message = "" if is_job_url: url_message = f"""
{advice}
🔒 Zero data retention • 🛡️ Enterprise security • ⚡ Instant analysis
AI-Powered Interview Preparation with PDF Upload
📄 Direct PDF Upload • 🤖 LLM Processing • 🔗 URL Analysis • 💼 Comprehensive Prep
Upload a PDF file OR paste text below
🔒 Zero data retention • 🛡️ Enterprise security • 🎯 Professional interview preparation