Spaces:
Sleeping

script / visualize_local_setup.py
Lara Monteagudo Tubau
v5: tab-based UI, metacog screener, lexicon editor, SSRL tagging
a9de05b
Raw History Blame Contribute Delete
9.23 kB
#!/usr/bin/env python3
"""
visualize_local_setup.py β€” Generate a visual diagram of local vs cloud execution
"""
diagram = """
╔══════════════════════════════════════════════════════════════════════════════╗
β•‘ CollabCode Execution Modes (May 2026) β•‘
╠══════════════════════════════════════════════════════════════════════════════╣
β•‘ β•‘
β•‘ LOCAL MODE (No API Keys Needed) β•‘
β•‘ ═════════════════════════════════ β•‘
β•‘ β•‘
β•‘ Gradio App β•‘
β•‘ (localhost:7860) β•‘
β•‘ β”‚ β•‘
β•‘ β”œβ”€β†’ Load Transcript β•‘
β•‘ β”‚ (TXT/VTT/JSON) β•‘
β•‘ β”‚ β•‘
β•‘ └─→ Parse β†’ [321 turns] β•‘
β•‘ β”‚ β•‘
β•‘ └─→ Agent 0 (Section Detection) βœ“ LOCAL βœ“ β•‘
β•‘ β”‚ β•‘
β•‘ β”œβ”€ Keyword matching β•‘
β•‘ β”œβ”€ Boundary scoring β•‘
β•‘ └─ Phase labeling β•‘
β•‘ β”‚ β•‘
β•‘ └─→ [11 Sections] βœ“ 0.002 seconds βœ“ β•‘
β•‘ β”‚ β•‘
β•‘ └─ BLOCKED: Agent 1a (⚠️ needs HF API) β•‘
β•‘ Agent 1b (⚠️ needs HF API) β•‘
β•‘ Agent 2 (⚠️ needs HF API) β•‘
β•‘ β•‘
β•‘ ────────────────────────────────────────────────────────────────────────── β•‘
β•‘ β•‘
β•‘ CLOUD MODE (HuggingFace Inference API) β•‘
β•‘ ═════════════════════════════════════ β•‘
β•‘ β•‘
β•‘ [321 turns] ──────────────────→ Qwen/Qwen2.5-72B-Instruct β•‘
β•‘ (api-inference.huggingface.co) β•‘
β•‘ β•‘
β•‘ Requires: β•‘
β•‘ β€’ HF_TOKEN environment variable β•‘
β•‘ β€’ Prepaid inference API credits ($$$) β•‘
β•‘ β€’ Internet connectivity β•‘
β•‘ β€’ HuggingFace account in good standing β•‘
β•‘ β•‘
β•‘ Latency: 2–10 seconds per call β•‘
β•‘ Cost: $0.01–0.10 per transcription segment β•‘
β•‘ β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
PERFORMANCE COMPARISON
═════════════════════════════════════════════════════════════════════════════
Metric Local Heuristic Remote LLM (Qwen) Advantage
─────────────────────────────────────────────────────────────────────────────
Execution Speed 0.002 sec 2–10 sec 1,000–5,000x
Cost per Call $0.00 $0.01–0.10 Infinite
API Keys Required No βœ“ Yes (HF_TOKEN) Local
Accuracy ~85% (rules) ~95% (LLM) Remote
Customizable Via code Via prompt Local
Scalability Unlimited Rate-limited Local
Offline Capability Yes βœ“ No Local
Section Quality Good Excellent Remote
─────────────────────────────────────────────────────────────────────────────
QUICK START
═════════════════════════════════════════════════════════════════════════════
1. Enable local mode:
$ export LOCAL_SECTIONING=1
2. Run app:
$ bash run_local.sh
3. Open in browser:
β†’ http://localhost:7860
4. Upload/select transcript from Drive
5. Click "Confirm & Code"
6. View sections (instantly, no API calls!)
FILES YOU NEED
═════════════════════════════════════════════════════════════════════════════
.env.local ← Environment configuration
run_local.sh ← Startup script
test_local_sectioning.sh ← Quick test
LOCAL_EXECUTION.md ← Full setup guide
LOCAL_SETUP_REPORT.md ← This summary
agent0_sectioner.py ← Heuristic implementation
CONFIGURATION (.env.local)
═════════════════════════════════════════════════════════════════════════════
LOCAL_SECTIONING=1 # Enable local fallback
HF_TOKEN= # Empty = no API calls
DEBUG=1 # Verbose logging
TESTING
═════════════════════════════════════════════════════════════════════════════
$ bash test_local_sectioning.sh
Output:
βœ“ Parsed 321 turns
βœ“ Created 11 sections in 0.002 seconds
βœ“ Speed: 191,000 turns/second
βœ“ No API calls made
STATE AFTER THIS UPDATE
═════════════════════════════════════════════════════════════════════════════
Agent 0: βœ… LOCAL (heuristic) + βœ… REMOTE (fallback with API)
Agent 1a: ⚠️ REMOTE ONLY (needs HF token)
Agent 1b: ⚠️ REMOTE ONLY (needs HF token)
Agent 2: ⚠️ REMOTE ONLY (needs HF token)
β†’ User can run Sections page locally without any API credits
β†’ Full pipeline requires HuggingFace Inference API
FUTURE WORK (Optional)
═════════════════════════════════════════════════════════════════════════════
To fully localize the app:
1. Agent 1a (Boundary Detection)
Use: Silence detection + pause analysis from transcript timing
2. Agent 1b (Dimension Coding)
Use: Keyword matching against dimension definitions
3. Agent 2 (Rule Learning)
Use: Frequency analysis + decision tree extraction
See agent0_sectioner.py for pattern examples.
"""
print(diagram)