Skip to content

Installation Guide ​

This page covers three installation paths: Windows from source (developer / recommended), Windows one-click installer (end users), and Docker Relay (for deploying the broker relay only). Familiars is a Windows-first application; this guide focuses on Windows. macOS support is limited — see the macOS section at the end.


1. Prerequisites ​

DependencyMinimum VersionNotes
Python3.10+Backend bridge and all AI models run in this process
Node.js18+Electron frontend rendering + Vite dev server
npm9+Comes with Node.js
GitAnyClone the repository
CUDA Toolkit12.6 (recommended)Required for local GPU inference; API-only mode (mode0) works without GPU
NVIDIA Driver≥535Pairs with CUDA 12.6; check with nvidia-smi
Visual C++ Redistributable2015–2022Required by some Python packages (hnswlib, insightface)

GPU Tiers ​

On startup, the bridge reads GPU VRAM via nvidia-smi and assigns one of four tiers (source: src/base/gpu_tier.py):

TierVRAM ThresholdBehavior
mode0No discrete GPU / <1 GBAPI-only: all local models fall back to cloud LLM; no decider, no local rewriter
tier41–5 GB (default FAMILIARS_TIER4_MAX_MB=5000)4-bit quantized + sequential model loading (rewriter evicted before reranker loads); decider/memorizer queued
tier65–7.5 GB (default FAMILIARS_TIER6_MAX_MB=7500)rewriter+embedder+reranker co-loaded; voice calls (audio-only) allowed; decider/memorizer bf16
tier8≥7.5 GBFull: all models loaded simultaneously at highest precision

Cache file: workspace/gpu_tier.json. Override via environment variables:

  • FAMILIARS_GPU_TIER=tier6 — Manually pin a tier (for testing lower-tier fallback on a high-end GPU)
  • FAMILIARS_TIER4_MAX_MB=5000 — Adjust tier4 upper bound (MiB)
  • FAMILIARS_TIER6_MAX_MB=7500 — Adjust tier6 upper bound (MiB)
  • FAMILIARS_GPU_TIER_FORCE_REDETECT=1 — Force re-detection, ignore cache

Apple Silicon has no nvidia-smi and defaults to mode0 (API-only). To force local inference, set FAMILIARS_GPU_TIER=tier4 (MPS backend), but performance and stability are not guaranteed.


2.1 Clone the Repository ​

bash
git clone <repo-url> familiars
cd familiars

2.2 Python Virtual Environment ​

bash
# Create virtual environment
python -m venv .venv

# Activate (PowerShell)
.venv\Scripts\Activate.ps1

# Activate (CMD)
.venv\Scripts\activate.bat

# Activate (Git Bash / WSL)
source .venv/bin/activate

2.3 Install Python Dependencies ​

Critical: PyTorch must be installed from the official index with CUDA 12.6 support. Otherwise pip install torch pulls the CPU-only wheel from PyPI, making local QLoRA inference 10× slower.

bash
# Windows (CUDA 12.6)
pip install -r requirements.txt --index-url https://download.pytorch.org/whl/cu126

# macOS (CPU / MPS)
pip install -r requirements.txt --index-url https://download.pytorch.org/whl/cpu

Slow network? Add a mirror: -i https://pypi.tuna.tsinghua.edu.cn/simple (PyTorch index URL stays the same; the mirror only accelerates PyPI-side packages).

Key Dependencies in requirements.txt ​

PackageVersionPurpose
torch2.9.0+cu126PyTorch core (CUDA 12.6)
torchvision0.24.0+cu126Vision models
torchaudio2.9.0+cu126Audio processing
transformers4.57.3HuggingFace model loading
sentence_transformers5.2.2Embedding models
FlagEmbedding1.4.0RAG reranking
fastapi0.136.1HTTP API framework
hypercorn[h2]≥0.16.0HTTP/2 server
onnxruntime1.28.0ONNX inference (background removal, etc.)
openai2.36.0LLM API client
httpx0.28.1Async HTTP client
apscheduler3.11.2Scheduled task dispatch
faster-whisper≥1.0.0Speech recognition (ASR)
playwright1.59.0Browser automation
pydantic-settings≥2.5.0Environment variable validation
python-dotenv≥1.0.0.env loading
cryptography45.0.5Sensitive data encryption
paddleocr3.5.0OCR text recognition
insightface0.7.3Face detection (digital human)
mediapipe0.10.35Face / gesture tracking

Platform-locked packages (handled automatically by requirements.txt):

  • Windows only: uiautomation, wcferry (WeChat RPC), pycaw, comtypes, wmi, pywin32
  • macOS only: AppKit, Quartz (pyobjc)

2.4 Install Playwright Browsers ​

bash
playwright install chromium

2.5 Configure .env ​

Copy .env.example to .env (or create it at the repo root) and fill in the required fields:

Required Environment Variables ​

VariableTypeDescriptionExample
BASE_URLstringOpenAI-compatible API endpointhttps://api.familiars.cn/v1
API_KEYstringLLM provider API keysk-xxxxx
DEFAULT_MODELstringDefault dialogue model namegpt-4o

MANAGER_MODEL defaults to gpt-4o, used by the manager (agent 0) for executive summaries and persona evolution. Typically a stronger model.

Optional Model Configuration ​

VariableDefaultDescription
MANAGER_MODELgpt-4oManager-specific model
MINI_MODELQwen2.5-1.5BLocal lightweight model (decider, etc.)
FAST_MODELempty (falls back to DEFAULT_MODEL)Low-latency cloud fast model (draft parsing, quick classification)
EMBEDDING_MODELBAAI/bge-m3Embedding model (sentence-transformers name or HuggingFace path)
RERANKER_MODELBAAI/bge-reranker-v2-m3Reranker model

Runtime Tuning ​

VariableDefaultDescription
MAX_TURNS50Maximum tool-call turns per conversation
TIMEOUT300HTTP request timeout (seconds)
DIALOGUE_EXPIRE_TIME3600Idle dialogue expiry time (seconds)
SLIDE_WINDOW_SIZE5Sliding window context size
TOP_K5RAG retrieval result count

FAMILIARS_* Environment Variables ​

VariableDefaultDescription
FAMILIARS_TIER4_MAX_MB5000GPU tier4 VRAM upper bound (MiB)
FAMILIARS_TIER6_MAX_MB7500GPU tier6 VRAM upper bound (MiB)
FAMILIARS_GPU_TIERauto-detectedForce a GPU tier (mode0/tier4/tier6/tier8)
FAMILIARS_GPU_TIER_FORCE_REDETECT0Set 1 to force GPU re-detection
FAMILIARS_APPROVAL_DISABLED0Set 1 to disable all tool approvals (use with caution, dev only)
FAMILIARS_DB_PATHworkspace/familiars.dbSQLite database path (use :memory: for tests)
FAMILIARS_HTTP_INSECURE0Set 1 to fall back to HTTP + uvicorn (no HTTPS/2 + hypercorn)
FAMILIARS_BROKER_ADVERTISE_URLemptyBroker federation public/LAN base URL
FAMILIARS_BROKER_BIND127.0.0.1Bridge HTTP bind address (0.0.0.0 exposes to other machines)
FAMILIARS_FRAMEWORK_DOCS_TOPK—Framework docs RAG retrieval count

RAG Tuning ​

VariableDefaultDescription
RAG_DENSE_TOPK20Dense recall candidate count
RAG_CHUNK_SIZE800Chunk target size (characters)
RAG_RERANK_MIN_SCORE0.0Rerank minimum score threshold (0 = keep all)
RAG_RRF_K60Reciprocal Rank Fusion constant
RAG_MULTIQUERY_N1Local rewriter query variant count (1 = single query)

Circuit Breaker ​

VariableDefaultDescription
CB_FAILURE_THRESHOLD5Failures before tripping the breaker
CB_RECOVERY_SECONDS30.0Recovery attempt interval (seconds)
LLM_MAX_RETRIES3Maximum retries per LLM call
LLM_GATE_DISABLEDfalseSet true to disable concurrency gating (unlimited)

Third-Party Services (Optional) ​

VariableDescription
HUGGING_FACE_API_KEYHuggingFace API key
UPDATE_URLOTA update feed base URL (empty = disabled)
UPDATE_CHECK_INTERVAL_HOURSUpdate check interval (default 24 hours)

2.6 Electron Frontend ​

bash
cd electron
npm install

Key frontend dependencies (electron/package.json):

PackageVersionPurpose
vue^3.5.41Frontend framework
electron^30.0.0Desktop shell
pinia^2.1.7State management
@vue-flow/core^1.48.2Graph visualization (recipe/flow editor)
axios^1.7.0HTTP client
markdown-it^14.3.0Markdown rendering
highlight.js^11.11.1Code highlighting
mermaid^11.16.0Flowchart rendering
katex^0.17.0Math formula rendering
onnxruntime-web^1.26.0Browser-side ONNX inference
@ricky0123/vad-web^0.0.30Voice Activity Detection (VAD)
electron-updater^6.8.9OTA auto-updates

3. Launch ​

bash
cd electron
npm run electron:dev

This will:

  1. Start the Vite dev server (http://localhost:5173)
  2. Wait for Vite to be ready, then open the Electron window
  3. Electron auto-spawns the Python bridge subprocess (.venv/Scripts/python -m src.bridge.run)
  4. Bridge serves at: https://127.0.0.1:18711 (hypercorn + HTTP/2 + self-signed cert auto-generated at workspace/.bridge.crt)

Option B: Bridge Only (Backend Tests / No GUI) ​

bash
.venv/Scripts/python -m src.bridge.run

⚠️ Do NOT use uvicorn src.bridge.app:app --reload — it drops HTTP/2 support, and the reload mechanism race-initializes CUDA on a worker thread, which crashes on Windows WDDM.

Option C: CLI-Driven (Requires Running Bridge) ​

bash
python main.py agents list --pretty
python main.py chat stream --prompt "Hello" --agent-id 1
python main.py todos create --title "Buy milk" --deadline 2026-07-05T18:00

CLI authentication uses the X-Bridge-Token header, auto-read from workspace/.bridge_token. Override with --token or the BRIDGE_TOKEN environment variable.


4. Windows One-Click Installer (End Users) ​

How the installer is built (developer perspective):

  1. Enter electron/ and run npm run electron:build (Vite bundles the renderer + electron-builder produces a Windows NSIS installer).
  2. The installer bundles Python-side dependencies into extraResources; first launch auto-generates workspace/ and .env.
  3. User double-clicks to install → first launch prompts for LLM API endpoint (BASE_URL / API_KEY / model name).

Installer configuration (electron/package.json → build.nsis):

  • oneClick: false — Not one-click; allows directory selection
  • createDesktopShortcut: true — Creates desktop shortcut
  • createStartMenuShortcut: true — Creates Start Menu shortcut
  • Update feed: https://api.familiars.cn/_app-updates/ (electron-updater generic provider)

5. Docker Relay (Broker/Relay Deployment Only) ​

To self-host the Broker relay:

bash
cd deploy/relay/app
cp .env.example .env   # Fill in DOMAIN / CLOUDFLARE_API_TOKEN etc.
docker compose up -d

Architecture chain: Cloudflare → Caddy:443 (DNS-01 TLS) → relay:18712.

See deploy/relay/app/README.md for details.


6. macOS Notes ​

This repository is Python + Electron Windows-first. Some files have macOS branches but with lagging functionality:

FilemacOS Status
src/models/assistant.pyHas macOS branch
src/utils/autorun.pyHas macOS branch (launchd)
src/base/auth/device.pymacOS has real implementation (Keychain); Windows has hostname-only fingerprint
src/utils/daily_tools.pymacOS imports AppKit/Quartz (conditional import)

For macOS, install PyTorch with the CPU index:

bash
pip install -r requirements.txt --index-url https://download.pytorch.org/whl/cpu

7. Common Installation Errors & Solutions ​

ProblemCause / Fix
pip install reports Could not find a version that satisfies the requirement torch==2.9.0+cu126Missing --index-url https://download.pytorch.org/whl/cu126; PyPI doesn't have +cu126 suffix wheels
AttributeError: _ARRAY_API not foundonnxruntime too old (<1.28), incompatible with NumPy 2.x; ensure onnxruntime==1.28.0 in requirements.txt
pip install is very slowAdd a mirror: -i https://pypi.tuna.tsinghua.edu.cn/simple (PyTorch index URL stays the same)
Startup complains about untrusted self-signed certElectron auto-trusts workspace/.bridge.crt; for CLI / browser, trust it once manually
Port 18711 is occupiedBridge auto-calls pickFreePort() for a new port and writes it to workspace/.bridge.port; CLI reads that file automatically
ModuleNotFoundError: No module named 'pydantic_settings'pydantic-settings>=2.5.0 not installed; same for python-dotenv>=1.0.0
nvcc not found / CUDA compilation failsInstall CUDA Toolkit 12.6 + matching NVIDIA driver; or use pre-built wheels
uiautomation install fails (macOS)requirements.txt already locks it with sys_platform == "win32"; macOS should not attempt to install it
First launch is very slow (1-2 min)Normal — the bridge needs to prewarm embedder (bge-m3), rewriter, rembg, etc.; first launch also downloads them
Dual bridge instance conflictElectron has a single-instance lock (app.requestSingleInstanceLock()); a second launch auto-focuses the existing window instead of starting a new instance
torch is using CPU versionCheck pip show torch — the Version field should contain +cu126; otherwise reinstall
lunardate not foundLunar date conversion library, included in requirements.txt; if missing, pip install lunardate==0.3.0

8. File Structure After First Launch ​

After first launch, the workspace/ directory is auto-generated:

workspace/
├── .bridge_token          # Bridge auth token (CLI reads automatically)
├── .bridge.port           # Bridge actual port (non-default when 18711 is occupied)
├── .bridge.crt            # Self-signed HTTPS certificate
├── .bridge.key            # Self-signed HTTPS private key
├── .bridge.log            # Bridge runtime log
├── .bridges.json          # Bridge instance info (PID + port)
├── familiars.db           # SQLite main database
├── gpu_tier.json          # GPU tier cache
├── SECRET.json            # Encrypted sensitive data (tokens, etc.)
├── .paths_aliases.json    # Path migration alias records
├── AGENTS.md              # Project-level agent rules
├── USER.md                # User profile (rolled up by memory writer)
├── IDENTITY.md            # Identity definition
├── agents/
│   └── agent_<id>/        # Each agent's dedicated directory
│       ├── dialogue_<n>/  # Dialogue tree data
│       └── reports/       # Daily / weekly / monthly / annual reports
├── manager/
│   ├── entries/           # Desktop shell icon assets
│   └── flows/             # Installed flow templates
└── rewriter/
    └── prompt.md          # Query rewriting prompt

Next: Quick Start →

Familiars · 多 Agent AI 桌面应用