A
File size: 3,446 Bytes
068faf9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""Deploy this Socratic Space to Hugging Face.



Reads `HF_access` from the project-root `.env` (../../.env). Creates the Space

repo if it doesn't exist (PUBLIC), then uploads the local folder excluding

test artefacts and secrets.



After running this script:

  1. Visit https://huggingface.co/spaces/AE-Talk-bot/v5-AI-ethic-HOT-socratic

  2. Settings → Variables and secrets → ensure these are set:

       API_KEY              (secret)   your OpenAI key

       HF_access            (secret)   your HF write token (same one this script used)

       RUN_MODE             (variable) pilot

       AUTO_RESTART_ENABLED (variable) true

  3. Restart the Space and verify the build logs.

"""

import os
import sys
from pathlib import Path
from dotenv import load_dotenv
from huggingface_hub import HfApi

# Force UTF-8 stdout on Windows so → arrows in the post-deploy reminder
# don't crash the script after a successful upload.
try:
    sys.stdout.reconfigure(encoding="utf-8")
except Exception:
    pass

HERE = Path(__file__).resolve().parent
load_dotenv(HERE / "../../.env")

HF_TOKEN = os.environ.get("HF_access")
if not HF_TOKEN:
    print("ERROR: HF_access not found in ../../.env", file=sys.stderr)
    sys.exit(1)

REPO_ID = "AE-Talk-bot/v5-AI-ethic-HOT-socratic-frame"

api = HfApi(token=HF_TOKEN)

print(f"=== Creating Space {REPO_ID} (public, gradio) ===")
api.create_repo(
    repo_id=REPO_ID,
    repo_type="space",
    space_sdk="gradio",
    private=False,
    exist_ok=True,
)

print(f"=== Uploading {HERE} to Space ===")
api.upload_folder(
    folder_path=str(HERE),
    repo_id=REPO_ID,
    repo_type="space",
    ignore_patterns=[
        # All local archives (old prototypes, retired skills) — never deploy.
        "_archive_*",
        "_archive_*/**/*",
        "**/_archive_*",
        "**/_archive_*/**/*",
        # Raw course materials (PDFs etc.) — local-only research notes.
        "0_Raw_info/*",
        "0_Raw_info/**/*",
        # Test harnesses + artefacts — never deploy.
        "test_*.py",
        "test_*.json",
        "test_*.md",
        "test_logs/*",
        "verify_deployed.py",
        # Build artefacts
        "__pycache__/*",
        "**/__pycache__/*",
        "*.pyc",
        # Secrets (defensive — should never be in this folder anyway)
        ".env",
        # This script itself
        "deploy.py",
    ],
    commit_message="Deploy v8.3: add Look-back check to question_set generation. Manager must scan INITIAL_ARGUMENT + RECENT_TURNS + CURRENT_MSG before outputting any fresh question_set (opening or transition-due) and adjust the entry angle of candidate questions that would draw an 'as I said' pushback (redundancy) or 'I already rejected that premise' pushback. Probe target stays fixed; only entry angle moves. Two worked examples added (expected_consequences pivot, evaluation rejected-premise reformulation). Common mistakes updated.",
)

print()
print(f"=== Done ===")
print(f"Space URL: https://huggingface.co/spaces/{REPO_ID}")
print()
print("Next manual steps:")
print("  1. Open the Space URL above")
print("  2. Settings → Variables and secrets → add 3 secrets:")
print("     - API_KEY    (your OpenAI key)")
print("     - HF_access  (your HF write token, same as in .env)")
print("     - RUN_MODE   (pilot)")
print("  3. Restart the Space and check the build logs")