# 4DPocket Configuration
# Copy this to .env and fill in your values
# WARNING: Never commit .env to git - it contains secrets

# ─── Database ────────────────────────────────────────────────────
# SQLite (default, zero-config)
FDP_DATABASE__URL=sqlite:///./data/4dpocket.db
# PostgreSQL (production/Docker)
# FDP_DATABASE__URL=postgresql://4dp:4dp@localhost:5432/4dpocket

# ─── Authentication ──────────────────────────────────────────────
FDP_AUTH__MODE=single  # "single" (no login) or "multi" (JWT auth)
# FDP_AUTH__SECRET_KEY=  # auto-generated and persisted if not set
# FDP_AUTH__TOKEN_EXPIRE_MINUTES=10080  # 7 days

# ─── Search ──────────────────────────────────────────────────────
FDP_SEARCH__BACKEND=sqlite  # "sqlite" (FTS5) or "meilisearch"
# FDP_SEARCH__MEILI_URL=http://localhost:7700
# FDP_SEARCH__MEILI_MASTER_KEY=masterkey123
FDP_SEARCH__VECTOR_BACKEND=auto  # "auto" (chroma for SQLite, pgvector for Postgres), "chroma", "pgvector"
FDP_SEARCH__CHUNK_SIZE_TOKENS=512
FDP_SEARCH__CHUNK_OVERLAP_TOKENS=64
# FDP_SEARCH__MAX_CHUNKS_PER_ITEM=200

# ─── Reranker (optional, improves search quality) ──────────────
FDP_RERANK__ENABLED=false
# FDP_RERANK__MODEL=cross-encoder/ms-marco-MiniLM-L-6-v2
# FDP_RERANK__CANDIDATE_POOL=50
# FDP_RERANK__TOP_K=20

# ─── Enrichment ─────────────────────────────────────────────────
FDP_ENRICHMENT__EXTRACT_ENTITIES=false  # Enable entity extraction for concept graph
# FDP_ENRICHMENT__MAX_ENTITIES_PER_CHUNK=20
# FDP_ENRICHMENT__MAX_RELATIONS_PER_CHUNK=15

# Entity synthesis — LLM-authored structured wiki per entity (Karpathy pattern)
# FDP_ENRICHMENT__SYNTHESIS_ENABLED=true
# FDP_ENRICHMENT__SYNTHESIS_MIN_ITEM_COUNT=3       # Skip entities mentioned in < N items
# FDP_ENRICHMENT__SYNTHESIS_THRESHOLD=3            # Regen when (item_count - synthesis_item_count) >= N
# FDP_ENRICHMENT__SYNTHESIS_MIN_INTERVAL_HOURS=24  # Throttle per-entity regeneration
# FDP_ENRICHMENT__SYNTHESIS_MAX_CONTEXT_ITEMS=20   # Cap evidence fed to LLM per regen

# ─── AI Chat Provider ───────────────────────────────────────────
# Supported: "ollama" (local), "groq" (cloud), "nvidia" (cloud), "custom" (any OpenAI-compatible)
FDP_AI__CHAT_PROVIDER=ollama

# Ollama (default - local, free)
FDP_AI__OLLAMA_URL=http://localhost:11434
FDP_AI__OLLAMA_MODEL=llama3.2

# Groq (fast cloud inference)
# FDP_AI__CHAT_PROVIDER=groq
# FDP_AI__GROQ_API_KEY=gsk_...

# NVIDIA (powerful cloud models)
# FDP_AI__CHAT_PROVIDER=nvidia
# FDP_AI__NVIDIA_API_KEY=nvapi-...

# Custom (any OpenAI-compatible or Anthropic-compatible endpoint)
# FDP_AI__CHAT_PROVIDER=custom
# FDP_AI__CUSTOM_BASE_URL=https://api.minimax.io/anthropic/v1
# FDP_AI__CUSTOM_API_KEY=sk-...
# FDP_AI__CUSTOM_MODEL=MiniMax-M2.7
# FDP_AI__CUSTOM_API_TYPE=anthropic  # "openai" (default) or "anthropic"
#
# More examples:
# Together AI:
#   FDP_AI__CUSTOM_BASE_URL=https://api.together.xyz/v1
#   FDP_AI__CUSTOM_MODEL=meta-llama/Llama-3.3-70B-Instruct-Turbo
# Fireworks:
#   FDP_AI__CUSTOM_BASE_URL=https://api.fireworks.ai/inference/v1
#   FDP_AI__CUSTOM_MODEL=accounts/fireworks/models/llama-v3p3-70b-instruct
# OpenRouter:
#   FDP_AI__CUSTOM_BASE_URL=https://openrouter.ai/api/v1
#   FDP_AI__CUSTOM_MODEL=meta-llama/llama-3.3-70b-instruct

# ─── Embedding Provider ─────────────────────────────────────────
FDP_AI__EMBEDDING_PROVIDER=local  # "local" (sentence-transformers) or "nvidia"
FDP_AI__EMBEDDING_MODEL=all-MiniLM-L6-v2

# ─── AI Features ─────────────────────────────────────────────────
FDP_AI__AUTO_TAG=true
FDP_AI__AUTO_SUMMARIZE=true
FDP_AI__TAG_CONFIDENCE_THRESHOLD=0.7
FDP_AI__TAG_SUGGESTION_THRESHOLD=0.4
FDP_AI__SYNC_ENRICHMENT=true  # Run AI enrichment inline if Huey worker is not running

# ─── Storage ─────────────────────────────────────────────────────
FDP_STORAGE__BASE_PATH=./data
FDP_STORAGE__MAX_ARCHIVE_SIZE_MB=50

# ─── Server ──────────────────────────────────────────────────────
FDP_SERVER__HOST=0.0.0.0
FDP_SERVER__PORT=4040
FDP_SERVER__CORS_ORIGINS=["http://localhost:5173","http://localhost:4040"]
FDP_SERVER__SECURE_COOKIES=false  # Set true behind HTTPS in production

# ─── Docker Compose ──────────────────────────────────────────────
MEILI_MASTER_KEY=masterkey123
