diff --git a/.env.example b/.env.example index 7be4ee38..d78e89ab 100644 --- a/.env.example +++ b/.env.example @@ -1,85 +1,7 @@ -# Hindsight Environment Variables -# Copy this file to .env and fill in your values +# Required: LLM provider for memory classification +LLM_API_KEY=sk-your-key-here +LLM_PROVIDER=openai +LLM_MODEL=gpt-4o-mini -# LLM Configuration (Required) -# Supported providers: openai, groq, ollama, gemini, anthropic, lmstudio, vertexai, minimax, volcano -HINDSIGHT_API_LLM_PROVIDER=openai -HINDSIGHT_API_LLM_API_KEY=your-api-key-here -HINDSIGHT_API_LLM_MODEL=gpt-4o-mini -HINDSIGHT_API_LLM_BASE_URL=https://api.openai.com/v1 - -# Example: Anthropic Claude configuration -# HINDSIGHT_API_LLM_PROVIDER=anthropic -# HINDSIGHT_API_LLM_API_KEY=your-anthropic-api-key -# HINDSIGHT_API_LLM_MODEL=claude-sonnet-4-20250514 - -# Example: Google Vertex AI configuration -# HINDSIGHT_API_LLM_PROVIDER=vertexai -# HINDSIGHT_API_LLM_MODEL=google/gemini-2.0-flash-001 -# HINDSIGHT_API_LLM_VERTEXAI_PROJECT_ID=your-gcp-project-id -# HINDSIGHT_API_LLM_VERTEXAI_REGION=us-central1 -# HINDSIGHT_API_LLM_VERTEXAI_SERVICE_ACCOUNT_KEY=/path/to/service-account-key.json # Optional, uses ADC if not set - -# Example: MiniMax configuration (1M context window) -# HINDSIGHT_API_LLM_PROVIDER=minimax -# HINDSIGHT_API_LLM_API_KEY=your-minimax-api-key -# HINDSIGHT_API_LLM_MODEL=MiniMax-M2.7 - -# Example: LM Studio local configuration (Qwen 2.5 32B recommended) -# HINDSIGHT_API_LLM_PROVIDER=lmstudio -# HINDSIGHT_API_LLM_API_KEY=lmstudio -# HINDSIGHT_API_LLM_BASE_URL=http://localhost:1234/v1 -# HINDSIGHT_API_LLM_MODEL=qwen2.5-32b-instruct - -# API Configuration (Optional) -HINDSIGHT_API_HOST=0.0.0.0 -HINDSIGHT_API_PORT=8888 -HINDSIGHT_API_LOG_LEVEL=info - -# Base Path / Reverse Proxy Support (Optional) -# Set these when deploying behind a reverse proxy with path-based routing -# Example: To deploy at example.com/hindsight/, set both to "/hindsight" -# HINDSIGHT_API_BASE_PATH=/hindsight -# NEXT_PUBLIC_BASE_PATH=/hindsight - -# Database (Optional - uses embedded pg0 by default) -# HINDSIGHT_API_DATABASE_URL=postgresql://user:pass@host:5432/db -# HINDSIGHT_API_MIGRATION_DATABASE_URL= # Direct PostgreSQL URL for migrations (bypasses PgBouncer). Falls back to DATABASE_URL. -# HINDSIGHT_API_DATABASE_SCHEMA=public # PostgreSQL schema name (default: public) - -# Vector Extension (Optional - uses pgvector by default) -# Options: "pgvector" (default), "vchord", "pgvectorscale" (DiskANN) -# HINDSIGHT_API_VECTOR_EXTENSION=pgvector -# For Azure PostgreSQL with DiskANN: -# HINDSIGHT_API_VECTOR_EXTENSION=pgvectorscale # Auto-detects pg_diskann on Azure - -# Embeddings Configuration (Optional - uses local by default) -# Provider: "local" (default) or "tei" (HuggingFace Text Embeddings Inference) -# HINDSIGHT_API_EMBEDDINGS_PROVIDER=local -# For local provider: -# HINDSIGHT_API_EMBEDDINGS_LOCAL_MODEL=BAAI/bge-small-en-v1.5 -# For TEI provider: -# HINDSIGHT_API_EMBEDDINGS_TEI_URL=http://localhost:8080 - -# Reranker Configuration (Optional - uses local by default) -# Provider: "local" (default) or "tei" (HuggingFace Text Embeddings Inference) -# HINDSIGHT_API_RERANKER_PROVIDER=local -# For local provider: -# HINDSIGHT_API_RERANKER_LOCAL_MODEL=cross-encoder/ms-marco-MiniLM-L-6-v2 -# For TEI provider: -# HINDSIGHT_API_RERANKER_TEI_URL=http://localhost:8081 - -# Observability & Tracing (Optional - disabled by default) -# Enable OpenTelemetry tracing for LLM calls (GenAI semantic conventions) -# HINDSIGHT_API_OTEL_TRACES_ENABLED=true -# -# Local development with Grafana LGTM stack (recommended - see scripts/dev/grafana/README.md) -# HINDSIGHT_API_OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 -# -# Cloud backends (Grafana Cloud, Langfuse, DataDog, etc.) -# HINDSIGHT_API_OTEL_EXPORTER_OTLP_ENDPOINT=https://your-backend-url -# HINDSIGHT_API_OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer your-token" -# -# Custom service name and environment (optional, defaults: hindsight-api, development) -# HINDSIGHT_API_OTEL_SERVICE_NAME=hindsight-production -# HINDSIGHT_API_OTEL_DEPLOYMENT_ENVIRONMENT=production +# Optional: database password (default: hindsight_dev) +DB_PASSWORD=hindsight_dev diff --git a/docker-compose.rcll.yml b/docker-compose.rcll.yml new file mode 100644 index 00000000..fb5d582b --- /dev/null +++ b/docker-compose.rcll.yml @@ -0,0 +1,50 @@ +version: "3.8" + +# RCLL — local dev stack (API + pgvector). +# Note: the HINDSIGHT_API_* variables below are upstream config names and stay +# as-is on purpose — we rebrand the product, not the config interface. + +services: + db: + image: pgvector/pgvector:pg16 + environment: + POSTGRES_DB: hindsight + POSTGRES_USER: hindsight + POSTGRES_PASSWORD: ${DB_PASSWORD:-hindsight_dev} + volumes: + - hindsight_data:/var/lib/postgresql/data + ports: + - "5432:5432" + healthcheck: + test: ["CMD-SHELL", "pg_isready -U hindsight"] + interval: 5s + timeout: 5s + retries: 5 + + rcll: + build: + context: ./hindsight-api-slim + dockerfile: Dockerfile + depends_on: + db: + condition: service_healthy + environment: + HINDSIGHT_API_DATABASE_URL: postgresql://hindsight:${DB_PASSWORD:-hindsight_dev}@db:5432/hindsight + HINDSIGHT_API_MIGRATION_DATABASE_URL: postgresql+psycopg2://hindsight:${DB_PASSWORD:-hindsight_dev}@db:5432/hindsight + HINDSIGHT_API_HOST: "0.0.0.0" + HINDSIGHT_API_PORT: "5100" + HINDSIGHT_API_LOG_LEVEL: info + HINDSIGHT_API_LLM_PROVIDER: ${LLM_PROVIDER:-openai} + HINDSIGHT_API_LLM_API_KEY: ${LLM_API_KEY} + HINDSIGHT_API_LLM_MODEL: ${LLM_MODEL:-gpt-4o-mini} + HINDSIGHT_API_EMBEDDINGS_PROVIDER: local + HINDSIGHT_API_EMBEDDINGS_LOCAL_FORCE_CPU: "true" + HINDSIGHT_API_RERANKER_PROVIDER: local + HINDSIGHT_API_RERANKER_LOCAL_FORCE_CPU: "true" + HINDSIGHT_API_RUN_MIGRATIONS: "true" + HINDSIGHT_API_WORKERS: "1" + ports: + - "5100:5100" + +volumes: + hindsight_data: diff --git a/docker/standalone/start-all.sh b/docker/standalone/start-all.sh index b5f163e6..007d7d89 100755 --- a/docker/standalone/start-all.sh +++ b/docker/standalone/start-all.sh @@ -156,7 +156,10 @@ PIDS=() # Start API if enabled if [ "$ENABLE_API" = "true" ]; then cd /app/api - API_HEALTH_URL="${HINDSIGHT_API_HEALTH_URL:-http://localhost:8888/health}" + # Health probe must follow HINDSIGHT_API_PORT — hardcoding 8888 made the + # readiness check hit a dead port whenever the API was bound elsewhere, + # timing out after API_STARTUP_WAIT_SECONDS and exiting 1 → crash loop. + API_HEALTH_URL="${HINDSIGHT_API_HEALTH_URL:-http://localhost:${HINDSIGHT_API_PORT:-8888}/health}" API_STARTUP_WAIT_SECONDS="${HINDSIGHT_API_STARTUP_WAIT_SECONDS:-300}" # Run API directly - Python's PYTHONUNBUFFERED=1 handles output buffering @@ -207,7 +210,7 @@ if [ "$ENABLE_CP" = "true" ]; then echo " Control Plane: http://localhost:${HINDSIGHT_CP_PORT:-9999}" fi if [ "$ENABLE_API" = "true" ]; then - echo " API: http://localhost:8888" + echo " API: http://localhost:${HINDSIGHT_API_PORT:-8888}" fi echo ""