File size: 4,235 Bytes
03d6be7
 
 
 
56fe6e7
03d6be7
 
7904866
03d6be7
7904866
 
56fe6e7
 
 
 
 
 
7904866
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a9a63bc
7904866
 
a9a63bc
 
 
 
 
 
 
 
717ecfa
7904866
 
 
 
 
 
 
 
 
 
56fe6e7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7904866
 
 
 
 
 
 
 
 
56fe6e7
7904866
 
 
 
 
 
 
 
 
 
b8d50a6
7904866
 
 
 
 
 
 
 
 
 
 
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
import os
import sys
from pathlib import Path
from huggingface_hub import snapshot_download
import shutil

PRIVATE_REPO = "cybercentinel/ai-red-teaming"
CACHE_DIR = Path("/tmp/sentitrust_cache")

# Download the private space
print("Loading SentiTrust AI Security Toolkit...")

# Clear cache to force fresh download of latest version
if CACHE_DIR.exists():
    print("Clearing cache to get latest updates...")
    shutil.rmtree(CACHE_DIR)

CACHE_DIR.mkdir(parents=True, exist_ok=True)

try:
    snapshot_download(
        repo_id=PRIVATE_REPO,
        repo_type="space",
        local_dir=CACHE_DIR,
        token=os.environ.get("HF_TOKEN")
    )
    
    print("Starting AI Red-Teaming Toolkit...")
    
    # Add to path and execute the downloaded app
    sys.path.insert(0, str(CACHE_DIR))
    
    # Execute the app.py file directly with proper globals
    app_path = CACHE_DIR / "app.py"
    with open(app_path) as f:
        code = f.read()
        # Provide all necessary globals including __file__
        exec_globals = {
            "__name__": "__main__",
            "__file__": str(app_path),
            "__builtins__": __builtins__
        }
        exec(code, exec_globals)
        
except Exception as e:
    # Show professional error page if loading fails
    print(f"Error loading toolkit: {e}")
    import traceback
    traceback.print_exc()
    
    import gradio as gr
    
    with gr.Blocks() as demo:
        gr.HTML("""

        <style>

            @media (max-width: 768px) {

                .error-container {

                    padding: 30px 20px !important;

                    margin: 20px 10px !important;

                }

                .error-container h1 {

                    font-size: 1.8em !important;

                }

                .error-container p {

                    font-size: 1em !important;

                }

                .error-buttons {

                    display: flex !important;

                    flex-direction: column !important;

                    gap: 12px !important;

                }

                .error-buttons a {

                    width: 100% !important;

                    margin: 0 !important;

                    padding: 14px 24px !important;

                    font-size: 1em !important;

                }

            }

        </style>

        <div class="error-container" style="background: #0a0a0a; padding: 60px 30px; border-radius: 12px; text-align: center; color: white; max-width: 800px; margin: 40px auto;">

            <h1 style="color: #dc2626; font-size: 2.5em; margin-bottom: 20px;">

                SentiTrust AI Security Toolkit

            </h1>

            <p style="color: rgba(255,255,255,0.8); font-size: 1.2em; margin-bottom: 30px;">

                The toolkit is temporarily unavailable. Please try again in a moment.

            </p>

            <p style="color: rgba(255,255,255,0.6); font-size: 0.95em; margin-bottom: 40px;">

                If the issue persists, please contact our team.

            </p>

            <div class="error-buttons" style="margin-top: 30px;">

                <a href="https://sentitrust.adogent.com" target="_blank" 

                   style="display: inline-block; background: #dc2626; color: white; padding: 16px 32px; 

                          border-radius: 8px; text-decoration: none; font-weight: 700; margin: 8px; font-size: 1.1em;">

                    Visit SentiTrust.com →

                </a>

                <a href="https://calendly.com/sentitrust/free-security-scan" target="_blank" 

                   style="display: inline-block; background: white; color: #0a0a0a; padding: 16px 32px; 

                          border-radius: 8px; text-decoration: none; font-weight: 700; margin: 8px; font-size: 1.1em;">

                    Book Free Scan →

                </a>

            </div>

            <p style="color: rgba(255,255,255,0.4); font-size: 0.85em; margin-top: 40px;">

                hello@adogent.com

            </p>

        </div>

        """)
    
    demo.launch(
        server_name="0.0.0.0",
        server_port=7860,
        share=False
    )