File size: 3,003 Bytes
7ff6662
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/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()