From 56b0e957907961f64472aef655761ed961b0bc90 Mon Sep 17 00:00:00 2001 From: Jannic Debus Date: Fri, 14 Aug 2026 23:18:57 +0200 Subject: [PATCH] feat: enhance LiteLLM proxy configuration and deployment setup Configuration updates to the Aido deployment stack, focusing on LiteLLM proxy hardening, improved model configuration, and enhanced environment setup. --- .env.example | 38 +++++--- docker-compose.yml | 52 ++++------ litellm-config.yaml | 227 ++++++++++++++++++++++---------------------- setup.sh | 2 +- 4 files changed, 158 insertions(+), 161 deletions(-) diff --git a/.env.example b/.env.example index b2da321..45b30e3 100644 --- a/.env.example +++ b/.env.example @@ -124,7 +124,7 @@ POSTGRES_TCP_KEEPALIVES_COUNT=5 # 5 probes before disconnect ## File Store Backend: "s3" (default, uses MinIO) or "postgres" (no extra services needed) ## COMPOSE_PROFILES activates the MinIO service. To use PostgreSQL file storage instead, ## remove s3-filestore from COMPOSE_PROFILES and set FILE_STORE_BACKEND=postgres. -#COMPOSE_PROFILES=s3-filestore +COMPOSE_PROFILES=s3-filestore FILE_STORE_BACKEND=s3 ## MinIO/S3 Configuration (only needed when FILE_STORE_BACKEND=s3) @@ -132,7 +132,7 @@ FILE_STORE_BACKEND=s3 ## edit .env by hand, change all four values before production. Keep the S3_AWS_* ## pair identical to MINIO_ROOT_* (the app uses MinIO's root creds). S3_ENDPOINT_URL= -S3_REGION= +S3_REGION=us-east-1 S3_AWS_ACCESS_KEY_ID= S3_AWS_SECRET_ACCESS_KEY= S3_FILE_STORE_BUCKET_NAME= @@ -263,15 +263,8 @@ DISABLE_LITELLM_STREAMING=false # LITELLM_EXTRA_HEADERS= # GEN_AI_API_KEY= GENERATIVE_MODEL_ACCESS_CHECK_FREQ=300 # 5 minutes -LITELLM_CUSTOM_ERROR_MESSAGE_MAPPINGS={ - "RateLimitError": "Service is temporarily busy. Please try again in a moment.", - "Timeout": "Request took too long. Please try with a shorter query.", - "AuthenticationError": "AI service authentication failed. Contact your administrator.", - "BadRequestError": "Invalid request format. Please rephrase your query.", - "InternalServerError": "Temporary service issue. Please retry shortly." -} -LITELLM_PROXY_API_KEY=${LITELLM_MASTER_KEY} -LITELLM_PROXY_API_BASE=http://litellm-proxy:4000 +LITELLM_CUSTOM_ERROR_MESSAGE_MAPPINGS={"RateLimitError":"Service is temporarily busy. Please try again in a moment.","Timeout":"Request took too long. Please try with a shorter query.","AuthenticationError":"AI service authentication failed. Contact your administrator.","Interna + ## Query Options # DOC_TIME_DECAY= @@ -338,10 +331,25 @@ INDEXING_MODEL_SERVER_HOST=indexing_model_server INTERNAL_URL=http://api_server:8080 ENABLE_CONTEXTUAL_RAG=true +# ============================================================================= # LiteLLM Proxy Settings +# ============================================================================= LITELLM_MASTER_KEY=sk-$(openssl rand -hex 32) LITELLM_SALT_KEY=$(openssl rand -hex 32) -LITELLM_DATABASE_URL=postgresql://llmproxy:${LITELLM_POSTGRES_PASSWORD}@litellm-db:5432/litellm -LITELLM_POSTGRES_PASSWORD=$(openssl rand -hex 16) -LITELLM_INFOMANIAK_API_KEY= -LITELLM_REDIS_PASSWORD=$(openssl rand -hex 16) \ No newline at end of file +DATABASE_URL=postgresql://llmproxy:${POSTGRES_PASSWORD}@litellm-db:5432/litellm +POSTGRES_PASSWORD=$(openssl rand -hex 16) +INFOMANIAK_API_KEY= + +# ============================================================================= +# DOCUMENT INGESTION CONFIGURATION +# ============================================================================= +# Onyx Ingestion API Key (generate via Admin Panel -> Settings -> API Keys) +ONYX_INGESTION_API_KEY=your-api-key-here +# Connector Credential Pair ID (from Admin Panel -> Connectors) +# Get this from the URL: /admin/connector/ -> cc_pair_id +ONYX_CC_PAIR_ID=243 +# How often to check for new files (in seconds) +INGESTION_INTERVAL_SECONDS=300 +# Host path to your SMB/network mount +# Example: /mnt/smb-share or /Volumes/network-drive +DOCUMENT_SOURCE_HOST_PATH=/opt/stacks/onyx/ingestion_data \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 7d7e519..bc173ee 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -280,14 +280,6 @@ services: inference_model_server: image: ${ONYX_MODEL_SERVER_IMAGE:-onyxdotapp/onyx-model-server:${IMAGE_TAG:-latest}} - command: > - /bin/sh -c "if [ \"${DISABLE_MODEL_SERVER:-}\" = \"True\" ] || [ - \"${DISABLE_MODEL_SERVER:-}\" = \"true\" ]; then - echo 'Skipping service...'; - exit 0; - else - exec uvicorn model_server.main:app --host 0.0.0.0 --port 9000; - fi" networks: - onyx-network env_file: @@ -319,14 +311,6 @@ services: start_period: 600s indexing_model_server: image: ${ONYX_MODEL_SERVER_IMAGE:-onyxdotapp/onyx-model-server:${IMAGE_TAG:-latest}} - command: > - /bin/sh -c "if [ \"${DISABLE_MODEL_SERVER:-}\" = \"True\" ] || [ - \"${DISABLE_MODEL_SERVER:-}\" = \"true\" ]; then - echo 'Skipping service...'; - exit 0; - else - exec uvicorn model_server.main:app --host 0.0.0.0 --port 9000; - fi" networks: - onyx-network env_file: @@ -521,7 +505,6 @@ services: user: root volumes: - ${DOCKER_SOCK_PATH:-/var/run/docker.sock}:/var/run/docker.sock - # litellm proxy litellm-proxy: image: docker.litellm.ai/berriai/litellm:main-stable @@ -531,26 +514,30 @@ services: command: > --config /app/config.yaml --port 4000 - --num_workers 4 + --num_workers 2 --max_requests_before_restart 10000 --max_requests_before_restart_jitter 1000 --run_gunicorn networks: - litellm-network - onyx-network + expose: + - 4000 environment: - - INFOMANIAK_API_KEY=${LITELLM_INFOMANIAK_API_KEY} + - INFOMANIAK_API_KEY=${INFOMANIAK_API_KEY} - LITELLM_MASTER_KEY=${LITELLM_MASTER_KEY} - REDIS_HOST=litellm-redis - REDIS_PORT=6379 - - REDIS_PASSWORD=${LITELLM_REDIS_PASSWORD} + - REDIS_PASSWORD=${REDIS_PASSWORD} - LITELLM_SALT_KEY=${LITELLM_SALT_KEY} - LITELLM_MODE=PRODUCTION - LITELLM_LOG=ERROR - - NUM_WORKERS=4 + - NUM_WORKERS=2 - MAX_REQUESTS_BEFORE_RESTART=10000 - MAX_REQUESTS_BEFORE_RESTART_JITTER=1000 - - DATABASE_URL=${LITELLM_DATABASE_URL} + - DATABASE_URL=${DATABASE_URL} + - GUNICORN_TIMEOUT=120 + - UVICORN_TIMEOUT=120 env_file: - .env # Load local .env file depends_on: @@ -565,22 +552,26 @@ services: interval: 30s # Perform health check every 30 seconds timeout: 10s # Health check command times out after 10 seconds retries: 3 # Retry up to 3 times if health check fails - start_period: 60s # Wait 40 seconds after container start before beginning health checks + start_period: 120s # Wait 120 seconds after container start before beginning health checks deploy: resources: limits: cpus: '2.0' - memory: 2G + memory: 4G reservations: - cpus: '0.5' - memory: 512M + cpus: '1.0' + memory: 1G + memswap_limit: 4G litellm-db: image: postgres:16 restart: unless-stopped environment: POSTGRES_DB: litellm POSTGRES_USER: llmproxy - POSTGRES_PASSWORD: ${LITELLM_POSTGRES_PASSWORD} + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} + command: -c 'max_connections=200' + env_file: + - .env # Load local .env file networks: - litellm-network volumes: @@ -599,6 +590,8 @@ services: - REDIS_HOST=litellm-redis - REDIS_PORT=6379 - REDIS_SSL=False + env_file: + - .env # Load local .env file networks: - litellm-network volumes: @@ -607,14 +600,11 @@ services: test: - CMD - redis-cli - - -a - - ${LITELLM_REDIS_PASSWORD} - ping interval: 5s timeout: 3s retries: 5 - command: redis-server --requirepass ${LITELLM_REDIS_PASSWORD} --appendonly yes --maxmemory 256mb --maxmemory-policy allkeys-lru - + command: redis-server --appendonly yes --maxmemory 256mb --maxmemory-policy allkeys-lru volumes: # Persistent data for OpenSearch. opensearch-data: null diff --git a/litellm-config.yaml b/litellm-config.yaml index 9ae62a2..98ac79b 100644 --- a/litellm-config.yaml +++ b/litellm-config.yaml @@ -3,41 +3,50 @@ general_settings: database_url: os.environ/DATABASE_URL store_model_in_db: true store_prompts_in_spend_logs: false - use_redis_transaction_buffer: true # Required for high traffic (1000+ RPS) [1] - user_api_key_cache_ttl: 300 # Optional: TTL for API key auth cache [2] - enable_redis_auth_cache: true + use_redis_transaction_buffer: false + user_api_key_cache_ttl: 300 + enable_redis_auth_cache: false allow_requests_on_db_unavailable: true json_logs: true -# LiteLLM Proxy Configuration for Infomaniak AI API -# Base URL: https://api.infomaniak.com/2/ai/105341/openai/v1 + health_check_interval: 60 + health_check_timeout: 10 + +# LiteLLM module settings +litellm_settings: + drop_params: false + set_verbose: false + request_timeout: 600 + num_retries: 2 + cache: false + #cache_params: + # type: redis + # host: litellm-redis + # port: 6379 + # ttl: 300 + # namespace: "litellm.livtec.caching" + redact_user_api_key_info: true + turn_off_message_logging: true + model_list: - # Primary Model: Qwen3.5 (LivQwen) - - model_name: LivQwen + - model_name: LivQwenMax litellm_params: - model: openai/Qwen/Qwen3.5-397B-A17B-FP8 + model: Qwen/Qwen3.5-397B-A17B-FP8 + custom_llm_provider: openai api_base: https://api.infomaniak.com/2/ai/105341/openai/v1 api_key: os.environ/INFOMANIAK_API_KEY rpm: 50 - tpm: 100000 - timeout: 600 - max_retries: 3 - retry_policy: - RateLimitError: 5 - Timeout: 3 - APIConnectionError: 3 + tpm: 500000 model_info: - id: "infomaniak-qwen-1" + id: "infomaniak-qwen397-1" base_model: "Qwen/Qwen3.5-397B-A17B-FP8" # Model capabilities (Infomaniak doesn't provide these via API) - input_cost_per_token: 0.0 # Set based on Infomaniak pricing - output_cost_per_token: 0.0 - max_tokens: 200000 - input_cost_per_second: 0.0 - output_cost_per_second: 0.0 + #max_tokens: 200000 + input_cost_per_token: 0.0000008 + output_cost_per_token: 0.0000036 # Capabilities - supports_vision: true # Qwen3.5 has vision capabilities - supports_reasoning: true # Qwen3.5 has enhanced reasoning + supports_vision: true + supports_reasoning: true supports_function_calling: true supports_parallel_function_calling: true supports_response_schema: true @@ -52,34 +61,60 @@ model_list: # Model family info mode: "chat" model_group: "qwen-family" - region: "eu-west" # Infomaniak is Switzerland-based + region: "ch-gva" # Infomaniak is Switzerland-based - # Secondary Model: Kimi-K2.6 (LivKimi) - - model_name: LivKimi + - model_name: LivQwen litellm_params: - model: openai/moonshotai/Kimi-K2.6 + model: Qwen/Qwen3.5-122B-A10B-FP8 + custom_llm_provider: openai api_base: https://api.infomaniak.com/2/ai/105341/openai/v1 api_key: os.environ/INFOMANIAK_API_KEY rpm: 50 - tpm: 100000 - timeout: 600 - max_retries: 3 - retry_policy: - RateLimitError: 5 - Timeout: 3 - APIConnectionError: 3 + tpm: 500000 + model_info: + id: "infomaniak-qwen122-1" + base_model: "Qwen/Qwen3.5-122B-A10B-FP8" + # Model capabilities (Infomaniak doesn't provide these via API) + #max_tokens: 200000 + input_cost_per_token: 0.0000004 + output_cost_per_token: 0.0000032 + # Capabilities + supports_vision: true + supports_reasoning: true + supports_function_calling: true + supports_parallel_function_calling: true + supports_response_schema: true + supports_system_messages: true + supports_tool_choice: true + supports_web_search: false # Unless Infomaniak enables it + supports_prompt_caching: false + supports_embedding: false + supports_audio_input: false + supports_audio_output: false + supports_computer_use: false + # Model family info + mode: "chat" + model_group: "qwen-family" + region: "ch-gva" # Infomaniak is Switzerland-based + + - model_name: LivKimi + litellm_params: + model: moonshotai/Kimi-K2.6 + custom_llm_provider: openai + api_base: https://api.infomaniak.com/2/ai/105341/openai/v1 + api_key: os.environ/INFOMANIAK_API_KEY + rpm: 50 + tpm: 500000 model_info: id: "infomaniak-kimi-1" base_model: "moonshotai/Kimi-K2.6" # Model capabilities - input_cost_per_token: 0.0 - output_cost_per_token: 0.0 - max_tokens: 256000 - input_cost_per_second: 0.0 - output_cost_per_second: 0.0 + #max_tokens: 256000 + input_cost_per_token: 0.0000006 + output_cost_per_token: 0.000003 # Capabilities - supports_vision: true # Kimi K2.5+ supports vision - supports_reasoning: true # Strong reasoning capabilities + supports_vision: true + supports_reasoning: true supports_function_calling: true supports_parallel_function_calling: true supports_response_schema: true @@ -94,36 +129,27 @@ model_list: # Model family info mode: "chat" model_group: "kimi-family" - region: "eu-west" + region: "ch-gva" - # Tertiary Model: Gemma-4 (LivGemma) - - model_name: LivGemma + - model_name: LivMinistral litellm_params: - model: openai/google/gemma-4-31B-it + model: mistralai/Ministral-3-14B-Instruct-2512 + custom_llm_provider: openai api_base: https://api.infomaniak.com/2/ai/105341/openai/v1 api_key: os.environ/INFOMANIAK_API_KEY rpm: 50 - tpm: 100000 - timeout: 600 - max_retries: 3 - retry_policy: - RateLimitError: 5 - Timeout: 3 - APIConnectionError: 3 + tpm: 500000 model_info: - id: "infomaniak-gemma-1" - base_model: "google/gemma-4-31B-it" + id: "infomaniak-ministral-3-14b-1" + base_model: "mistralai/Ministral-3-14B-Instruct-2512" # Model capabilities - input_cost_per_token: 0.0 - output_cost_per_token: 0.0 - max_tokens: 100000 - input_cost_per_second: 0.0 - output_cost_per_second: 0.0 - # Capabilities - supports_vision: false # Gemma-4-31B-it is text-only - supports_reasoning: false # Basic reasoning, not enhanced + #max_tokens: 100000 + input_cost_per_token: 0.0000003 + output_cost_per_token: 0.0000004 + supports_vision: true + supports_reasoning: false supports_function_calling: true - supports_parallel_function_calling: false + supports_parallel_function_calling: true supports_response_schema: true supports_system_messages: true supports_tool_choice: true @@ -133,37 +159,24 @@ model_list: supports_audio_input: false supports_audio_output: false supports_computer_use: false - # Model family info mode: "chat" - model_group: "gemma-family" - region: "eu-west" + model_group: "mistral-family" + region: "ch-gva" -# Cost-Optimized Model: Nemotron-3-Nano (LivNemotron) - # Best for: high-volume tasks like Onyx contextual retrieval, classification, - # summarization, and any workload where cost matters more than - # peak reasoning quality. - # Infomaniak pricing (CHF): 0.05 / 1M input tokens | 0.20 / 1M output tokens - model_name: LivNemotron litellm_params: - model: openai/nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-FP8 + model: nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-FP8 + custom_llm_provider: openai api_base: https://api.infomaniak.com/2/ai/105341/openai/v1 api_key: os.environ/INFOMANIAK_API_KEY rpm: 50 - tpm: 100000 - timeout: 600 - max_retries: 3 - retry_policy: - RateLimitError: 5 - Timeout: 3 - APIConnectionError: 3 + tpm: 500000 model_info: id: "infomaniak-nemotron-nano-1" base_model: "nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-FP8" - input_cost_per_token: 0.0 - output_cost_per_token: 0.0 - max_tokens: 128000 - input_cost_per_second: 0.0 - output_cost_per_second: 0.0 + #max_tokens: 128000 + input_cost_per_token: 0.00000005 + output_cost_per_token: 0.0000002 # Capabilities supports_vision: false # Text-only model supports_reasoning: false # Standard instruction following, not deep reasoning @@ -181,54 +194,40 @@ model_list: # Model family info mode: "chat" model_group: "nemotron-family" - region: "eu-west" + region: "ch-gva" router_settings: redis_host: litellm-redis redis_port: 6379 - redis_password: os.environ/REDIS_PASSWORD routing_strategy: simple-shuffle - num_retries: 3 retry_after: 5 allowed_fails: 3 cooldown_time: 30 + client_ttl: 3600 enable_pre_call_checks: true + # Retry policy for different error types retry_policy: - RateLimitErrorRetries: 5 + RateLimitErrorRetries: 2 TimeoutErrorRetries: 3 AuthenticationErrorRetries: 0 BadRequestErrorRetries: 1 InternalServerErrorRetries: 4 + ContentPolicyViolationErrorRetries: 1 # Allowed fails policy before cooldown allowed_fails_policy: - BadRequestErrorAllowedFails: 1000 - AuthenticationErrorAllowedFails: 5 - TimeoutErrorAllowedFails: 12 - RateLimitErrorAllowedFails: 10000 - InternalServerErrorAllowedFails: 20 - - fallbacks: - - LivQwen: [LivKimi, LivGemma] - - LivKimi: [LivGemma, LivQwen] - - LivGemma: [LivKimi, LivQwen] + BadRequestErrorAllowedFails: 3 + AuthenticationErrorAllowedFails: 1 + TimeoutErrorAllowedFails: 5 + RateLimitErrorAllowedFails: 3 + InternalServerErrorAllowedFails: 5 + ContentPolicyViolationErrorAllowedFails: 1 + + fallbacks: + - LivQwenMax: [LivQwen, LivKimi] + - LivQwen: [LivQwenMax, LivKimi] + - LivKimi: [LivQwen, LivQwenMax] -# LiteLLM module settings -litellm_settings: - drop_params: false - set_verbose: false - request_timeout: 600 - num_retries: 3 - cache: true # Enable caching [2] - cache_params: - type: redis - host: litellm-redis - port: 6379 - password: os.environ/REDIS_PASSWORD - ttl: 3600 - namespace: "litellm.livtec.caching" - redact_user_api_key_info: true - turn_off_message_logging: false \ No newline at end of file diff --git a/setup.sh b/setup.sh index 3e0de45..9e5bf39 100644 --- a/setup.sh +++ b/setup.sh @@ -2,7 +2,7 @@ cd ~ curl -sL https://deb.nodesource.com/setup_25.x -o nodesource_setup.sh sudo bash nodesource_setup.sh -apt install make -y +apt install nodejs make -y mkdir /opt/stacks/onyx cd /opt/stacks/onyx wget XY