cybercentinel's picture
Upload 3 files
03d6be7 verified
raw
history blame
887 Bytes
import os
import sys
from pathlib import Path
from huggingface_hub import snapshot_download
import importlib.util
PRIVATE_REPO = "cybercentinel/ai-red-teaming"
CACHE = Path("cache")
def load_toolkit():
try:
print("Loading...")
CACHE.mkdir(exist_ok=True)
snapshot_download(
repo_id=PRIVATE_REPO,
repo_type="space",
local_dir=CACHE,
token=os.environ.get("HF_TOKEN")
)
sys.path.insert(0, str(CACHE))
spec = importlib.util.spec_from_file_location("app", CACHE / "app.py")
app = importlib.util.module_from_spec(spec)
spec.loader.exec_module(app)
except Exception as e:
import gradio as gr
with gr.Blocks() as demo:
gr.Markdown(f"Error: {e}")
demo.launch()
if __name__ == "__main__":
load_toolkit()