Skip to content

About

Real-time stealth AI copilot for lab defenses & technical interviews (Windows, PyQt5, WASAPI, Gemini Live API)

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation


LabHelper (LabDefense Copilot) is an invisible, real-time AI prompter and study copilot for Windows, built for online lab defenses, technical interviews, exams, and live Q&A sessions over Zoom, Google Meet, Discord, and Microsoft Teams.

It captures audio directly from your system output (WASAPI Loopback) and/or microphone, pairs it with your indexed source code and lab report, and streams concise, natural spoken answers into a screen-share-invisible HUD overlay.


Key Features

  1. Stealth HUD Overlay (WDA_EXCLUDEFROMCAPTURE)

    • Uses the native Windows SetWindowDisplayAffinity(WDA_EXCLUDEFROMCAPTURE) API so the floating overlay is visible to you on your monitor, while completely invisible in Zoom, Google Meet, Discord, Teams, or OBS screen sharing.
    • Customizable opacity, window size, and font scaling, plus one-click copy for generated code blocks.
    • Built-in line-reference verification (AnswerParser) checks file:line citations against your loaded context and automatically hides hallucinated references.
  2. Three Specialized Assistant Modes

    • Defense (Lab Prompter): Generates natural, spoken-word answers grounded in your actual lab code and report using a two-tier structure (Say Now for an immediate 1-sentence start, Add More for technical follow-up details, and Reference for verified file:line pointers).
    • Dub (Zero-File Live Prompter): Instant spoken answers for interviews, colloquiums, or oral exams without needing any loaded project files.
    • Chat (AI Mentor): General-purpose programming, math, debugging, and code-review assistant.
  3. Real-Time Audio Pipeline & Gemini Live API

    • WASAPI Loopback + Microphone: Captures the instructor's voice directly from your speakers/headphones (no virtual audio cables required) with adaptive Voice Activity Detection (VAD).
    • Optional Gemini Live WebSocket Mode: Supports real-time streaming transcription and native Live sessions (gemini-3.5-transcribe-live, gemini-3.8-live, gemini-3.8-live-extended-thinking) with automatic session_resumption.
  4. Smart Multi-Model Router (ModelRouter + ModelStats)

    • Parallel hedged fallback across Gemini 3.5, 3.6, 3.8, and Gemini 4 models (gemini-3.5-flash-lite, gemini-3.1-flash-lite, gemini-3.6-flash, gemini-3.8-flash, gemini-4-hydrogen, gemini-4-argon, gemini-4-carbon).
    • Tracks real-world EWMA latency and decayed failure rates per model in model_stats.json, automatically ranking healthy models and applying cooldowns on rate limits or overloads.
  5. Context Indexing & Pre-Defense Tools

    • Automatically indexes source code (.py, .c, .cpp, .cs, .java, .js, .ts, .go, .rs, .ipynb, etc.) with exact 1:1 IDE line numbers, alongside reports (.md, .txt, .docx, .pdf).
    • Supports Saved Lab Profiles (lab_profiles) for instant switching between subjects/labs.
    • Includes Screen Capture Q&A (Ctrl+Shift+S), Clipboard Q&A (Ctrl+Shift+V), plus one-click generators for likely instructor questions, project summary, and code review.
  6. Secure Credential Storage

    • Stores your GEMINI_API_KEY in Windows Credential Manager via keyring (falling back to .env, never plaintext in config.json), guided by a FirstRunWizard.

Architecture

flowchart LR
    A["WASAPI Loopback / Mic"] --> B["AudioCapture (Adaptive VAD)"]
    S["Screen / Clipboard / Text"] --> E["AIAssistant"]
    C["Lab Code + Report (PDF/DOCX/MD)"] --> D["ContextLoader"]
    B -->|"Audio WAV"| E
    B -->|"PCM Stream"| L["LiveSessionManager (WebSocket)"]
    D -->|"Indexed Context"| E
    L -->|"Transcript / Live Answer"| E
    E --> R["ModelRouter (Hedged Fallback + ModelStats)"]
    R --> P["AnswerParser (Two-Tier + Line Verification)"]
    P --> H["StealthHUD (WDA_EXCLUDEFROMCAPTURE)"]
Loading

Quick Start

Prerequisites

  • Windows 10 / 11 (required for WASAPI Loopback and WDA_EXCLUDEFROMCAPTURE)
  • Python 3.12+
  • A Google Gemini API Key

Installation

git clone https://github.com/Basiliksys/LabHelper.git
cd LabHelper

python -m venv .venv
.venv\Scripts\activate

pip install -r requirements.txt
python run.py

First-Run Setup

  1. On first launch, FirstRunWizard prompts for your Gemini API Key (saved securely in Windows Credential Manager).
  2. Open Settings (⚙) to select your Lab Source Directory and optional Report File (.md, .txt, .docx, .pdf), or save them as a reusable Lab Profile.
  3. Choose your preferred Mode (Defense, Dub, or Chat), Audio Source (PC + Mic, PC only, Mic only), and optionally toggle Live Mode.

Global Hotkeys

Hotkey Action
Ctrl + Shift + H Show / hide the Stealth HUD overlay
Ctrl + Shift + C Clear displayed answers and conversation history
Ctrl + Shift + L Pause / resume audio listening
Ctrl + Shift + Space Force immediate answer from the current speech buffer
Ctrl + Shift + Q Focus the manual text question input
Ctrl + Shift + V Ask a question directly from clipboard text
Ctrl + Shift + S Capture screen and analyze visible code, errors, or tasks

All hotkeys can be customized in config.json (see config.example.json).


Project Structure

LabHelper/
├── assets/
│   └── banner.svg                # Dark-mode GitHub banner
├── labdefense/
│   ├── __init__.py
│   ├── ai_assistant.py           # High-level AI facade, history & cancellation
│   ├── answer_parser.py          # Two-tier parser & file:line verification
│   ├── audio_capture.py          # WASAPI Loopback + Mic capture with adaptive VAD
│   ├── config.py                 # Config loader, keyring storage, lab profiles
│   ├── context_loader.py         # Deterministic code indexer & PDF/DOCX/MD reader
│   ├── first_run.py              # First-run API key & setup wizard
│   ├── live_client.py            # Gemini Live API WebSocket session manager
│   ├── main.py                   # Application orchestrator & global hotkeys
│   ├── model_router.py           # Hedged fallback, cooldowns & error classification
│   ├── model_stats.py            # EWMA latency & failure rate tracker
│   ├── prompts.py                # System instructions for Defense / Dub / Chat
│   └── stealth_hud.py            # PyQt5 Stealth HUD with WDA_EXCLUDEFROMCAPTURE
├── tests/
│   ├── conftest.py
│   ├── test_answer_parser.py
│   ├── test_audio_pipeline.py
│   ├── test_config.py
│   ├── test_context_loader.py
│   ├── test_fallback.py
│   ├── test_hud.py
│   ├── test_live_mode.py
│   ├── test_model_stats.py
│   └── test_modes.py
├── .github/
│   ├── workflows/tests.yml       # Windows CI running pytest
│   ├── ISSUE_TEMPLATE/
│   └── PULL_REQUEST_TEMPLATE.md
├── config.example.json           # Sample non-secret configuration
├── requirements.txt
├── run.py                        # Application entry point
└── LICENSE                       # MIT License

Running Tests

pytest -q

Tests run headless in CI on windows-latest using QT_QPA_PLATFORM=offscreen.


License

This project is licensed under the MIT License — see LICENSE for details.

About

Real-time stealth AI copilot for lab defenses & technical interviews (Windows, PyQt5, WASAPI, Gemini Live API)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages