Spaces:
Sleeping
Sleeping
| #!/usr/bin/env python3 | |
| """Setup script for Job Automation Agent""" | |
| import subprocess | |
| import sys | |
| import os | |
| def run(cmd, desc): | |
| print(f" β {desc}...") | |
| result = subprocess.run(cmd, shell=True, capture_output=True, text=True) | |
| if result.returncode != 0: | |
| print(f" [WARN] {result.stderr.strip()[:200]}") | |
| else: | |
| print(f" [OK]") | |
| return result.returncode == 0 | |
| def main(): | |
| print("\nβββββββββββββββββββββββββββββββββββββββββ") | |
| print("β Job Automation Agent β Setup β") | |
| print("βββββββββββββββββββββββββββββββββββββββββ\n") | |
| # Create directories | |
| dirs = [ | |
| "data/resume", | |
| "data/output/reports", | |
| "data/output/resumes", | |
| ] | |
| for d in dirs: | |
| os.makedirs(d, exist_ok=True) | |
| print(" [OK] Directories created") | |
| # Install dependencies | |
| run(f"{sys.executable} -m pip install --upgrade pip", "Upgrading pip") | |
| run(f"{sys.executable} -m pip install -r requirements.txt", "Installing dependencies") | |
| # Validate API key | |
| print("\n β Validating GLM 5.1 API connection...") | |
| try: | |
| from dotenv import load_dotenv | |
| load_dotenv() | |
| from openai import OpenAI | |
| key = os.getenv("NVIDIA_API_KEY") | |
| if not key or "your-key" in key: | |
| print(" [WARN] NVIDIA_API_KEY not set in .env file") | |
| else: | |
| client = OpenAI(base_url="https://integrate.api.nvidia.com/v1", api_key=key) | |
| resp = client.chat.completions.create( | |
| model="z-ai/glm-5.1", | |
| messages=[{"role": "user", "content": "Say OK"}], | |
| max_tokens=10, | |
| ) | |
| print(f" [OK] API connected β response: {resp.choices[0].message.content}") | |
| except Exception as e: | |
| print(f" [WARN] API test failed: {e}") | |
| # Check resume | |
| resume_path = "data/resume/resume.pdf" | |
| if os.path.exists(resume_path): | |
| print(f"\n [OK] Resume found at {resume_path}") | |
| else: | |
| print(f"\n [!] IMPORTANT: Place your PDF resume at:") | |
| print(f" {os.path.abspath(resume_path)}") | |
| print("\nβββββββββββββββββββββββββββββββββββββββββ") | |
| print("β Setup Complete! β") | |
| print("β β") | |
| print("β Next steps: β") | |
| print("β 1. Copy resume to data/resume/ β") | |
| print("β resume.pdf β") | |
| print("β 2. Edit config.py (optional) β") | |
| print("β 3. Run: python main.py β") | |
| print("βββββββββββββββββββββββββββββββββββββββββ\n") | |
| if __name__ == "__main__": | |
| main() | |