Ctrl K
ComunidadGuías…

example.env

Rama main · réplica de lectura del repositorio original.

Archivo original ↗Preguntar a KiBot
# ============================================================
# piSynapse — Environment Configuration
# Copy this file to .env and edit before running the app:
#   cp example.env .env && nano .env
# Or run: python3 install.py  (generates .env automatically)
# ============================================================

# --- LLM Backend ---
# "litert"  — LiteRT-LM (OpenAI-compatible, recommended on ARM/Raspberry Pi)
# "ollama"  — Ollama server (x86 recommended)
LLM_BACKEND=litert

# --- LLM Server URLs ---
OLLAMA_BASE_URL=http://localhost:11434
LITERT_BASE_URL=http://localhost:9379

# --- Model ---
LLM_MODEL=gemma4-e2b
# Context window size (tokens). 8192 = current default (config.py
# DEFAULT_LLM_NUM_CTX); fits 12 GB+ RAM setups. Lower to ~6144 on 8 GB boards.
LLM_NUM_CTX=8192
# Batch size for prompt processing. Higher = faster but uses more RAM.
LLM_NUM_BATCH=256
LLM_TEMPERATURE=0.6
LLM_TOP_P=0.85
LLM_TOP_K=40
# How long to keep the model loaded after last request.
LLM_KEEP_ALIVE=4h
# Gemma4 thinking level when Think mode is enabled (litert backend).
# none = disabled, then minimal/low/medium/high/xhigh enable it.
LLM_REASONING_EFFORT=medium
# Max generated output tokens per response (litert-lm reads this via
# max_completion_tokens; its own default ~600 was truncating long answers).
LLM_MAX_OUTPUT_TOKENS=4096
LLM_TIMEOUT=600
# Hard budget (seconds) for one-shot intent/classification LLM calls — a
# stalled engine must not freeze the chat setup phase on a 20-token call.
INTENT_LLM_TIMEOUT=10
# Max idle seconds waiting for a streaming chunk before aborting.
SSE_READ_IDLE_TIMEOUT=300.0
# Max tool call iterations per request
LLM_MAX_TOOL_ITERATIONS=5

# --- Embedding ---
# Multilingual model (50+ languages), ~470 MB, auto-downloaded on first run.
# D-EMB-UPGRADE (2026-09-02): upgraded MiniLM-L12-v2 (384-dim) -> mpnet-base-v2
# (768-dim) for stronger multilingual retrieval. If you switch models, run
# `venv/bin/python reembed_all.py` to re-embed stored vectors (memories,
# conversations, corpus additions) — mismatched dimensions break cosine sim.
EMBED_MODEL=sentence-transformers/paraphrase-multilingual-mpnet-base-v2

# --- Memory ---
MEMORY_SIMILARITY_THRESHOLD=0.68
HISTORY_LIMIT=12
MEMORY_LIMIT=10
SUMMARY_BATCH_SIZE=5
SUMMARY_EARLY_TRIGGER=6
LLM_TITLE_ENRICHMENT=on

# --- Database ---
DB_PATH=assistant.db

# --- Weather ---
DEFAULT_CITY=
WEATHER_TIMEOUT=10

# --- Nextcloud (optional) ---
NEXTCLOUD_URL=
NEXTCLOUD_USER=
NEXTCLOUD_PASSWORD=
NEXTCLOUD_TIMEOUT=10

# --- Email Provider ---
# "gmail"   — Gmail with App Password
# "proton"  — ProtonMail via ProtonBridge (bridge must be running locally)
# Leave empty to disable email integration
MAIL_PROVIDER=

# --- Gmail (only if MAIL_PROVIDER=gmail) ---
GMAIL_USER=
GMAIL_APP_PASSWORD=
IMAP_HOST=imap.gmail.com
IMAP_PORT=993
SMTP_HOST=smtp.gmail.com
SMTP_PORT=465

# --- ProtonMail / ProtonBridge (only if MAIL_PROVIDER=proton) ---
PROTON_USER=
PROTON_PASSWORD=
PROTON_IMAP_HOST=localhost
PROTON_IMAP_PORT=1143
PROTON_SMTP_HOST=localhost
PROTON_SMTP_PORT=1025

# --- IMAP/SMTP Timeouts ---
IMAP_TIMEOUT=20
SMTP_TIMEOUT=20

# --- Piper TTS ---
# Available voices:
#   en_US-lessac-medium   English male
#   en_US-amy-medium      English female
#   tr_TR-dfki-medium     Turkish male
TTS_VOICE=en_US-lessac-medium
# "piper" (local, offline) or "browser" (Web Speech API)
TTS_ENGINE=piper

# --- Security ---
# Auto-generated by install.py. Generate with:
#   python -c "import secrets; print(secrets.token_urlsafe(32))"
API_KEY=
# Per-user credential encryption key (Fernet). Auto-generated by install.py:
#   python -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())"
MAIL_CREDS_KEY=
# Session cookie Secure flag: enable ONLY behind HTTPS.
SESSION_COOKIE_SECURE=off
# Open user registration ("on"/"off"). Turn off after creating accounts
# to run invite-only (admin toggles this).
REGISTRATION_OPEN=on
# Comma-separated CORS origins (leave empty for same-origin only)
CORS_ORIGINS=
# Alternate path for the .env file (rarely needed)
ENV_PATH=.env
# Trust X-Forwarded-For for client IPs when behind a reverse proxy (1/true/yes/on)
TRUST_X_FORWARDED_FOR=
# Comma-separated trusted hosts. Leave empty to auto-accept only local hostnames/IPs.
# For LAN access, list the Pi's hostname and/or IP, e.g. TRUSTED_HOSTS=raspberrypi,192.168.1.X
TRUSTED_HOSTS=
# Admin token for the LiteRT server (piserve) admin calls (optional)
PISERVE_ADMIN_TOKEN=
# Audit CSV export directory (default: <dirname of DB_PATH>/audit_exports)
AUDIT_EXPORT_DIR=
# Max upload size in MB (images, audio)
MEDIA_MAX_MB=100
# Rate limits, requests/min (raise on bigger hardware)
RATE_LIMIT_RPM=30
RATE_LIMIT_SESSION_RPM=20
RATE_LIMIT_PUBLIC_RPM=120
# Data retention in days (0 = keep forever, disabled)
#CONVERSATION_RETENTION_DAYS=0
#MEMORY_RETENTION_DAYS=0
# --- Speech-to-Text ---
# "whisper" — faster-whisper (fast, accurate, lightweight, ~75 MB)
# "gemma4"  — Gemma4 native audio (slower, captures emotion/tone)
# "browser" — Browser Web Speech API
STT_ENGINE=whisper

# --- Voice Input Behavior ---
AUTO_SEND_ON_VOICE=off
AUTO_TTS_ON_VOICE=off

# --- Intent Classification ---
# When "on", falls back to LLM call if embedding similarity is inconclusive
INTENT_LLM_FALLBACK=off
# Cosine threshold for the corpus-feeder conflict check (see config.py)
CONFLICT_COSINE=0.50

# --- Retention (days; 0 = keep forever) ---
CONVERSATION_RETENTION_DAYS=0
MEMORY_RETENTION_DAYS=0

# --- Assistant language for backend user-facing strings (tr/en) ---
UI_LANGUAGE=en

# --- Personalization ---
ASSISTANT_USER=