Skip to content

LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows

15.1 KB
Raw Blame
DJANGO_SETTINGS_MODULE='backend.settings.dev'
# NOTE: Debug is off by default. Set to True only for local development; it
# returns stack traces and internal state to any client that triggers an error.
# DJANGO_DEBUG=True

# NOTE: Change below to True if you are running in HTTPS mode.
SESSION_COOKIE_SECURE=False
CSRF_COOKIE_SECURE=False

# Default log level
DEFAULT_LOG_LEVEL="INFO"

# Gunicorn tuning. GUNICORN_THREADS must exceed concurrent browser tabs —
# each open Socket.IO WebSocket holds one thread for its lifetime.
GUNICORN_WORKERS=2
GUNICORN_THREADS=512

# Common
PATH_PREFIX="api/v1"

# Django settings
DJANGO_APP_BACKEND_URL=http://frontend.unstract.localhost
DJANGO_SECRET_KEY="1(xf&nc6!y7!l&!5xe&i_rx7e^m@fcut9fduv86ft=-b@2g6"

# Postgres DB envs
DB_HOST='unstract-db'
DB_USER='unstract_dev'
DB_PASSWORD='unstract_pass'
DB_NAME='unstract_db'
DB_PORT=5432
DB_SCHEMA="unstract"

# Celery Backend Database (optional - defaults to DB_NAME if unset)
# Example:
# CELERY_BACKEND_DB_NAME=unstract_celery_db
# Redis
REDIS_HOST="unstract-redis"
REDIS_PORT=6379
REDIS_PASSWORD=""
REDIS_USER=default

# Redis Retry Configuration
# Controls automatic retry behavior for transient Redis connection failures
# These settings apply to all Redis read operations in execution status trackers
# Max retry attempts after initial attempt before giving up (default: 4, total attempts: 5)
REDIS_RETRY_MAX_ATTEMPTS=4
# Exponential backoff multiplier in seconds (default: 0.5)
# With defaults (4 retries after initial = 5 total attempts):
# Retry delays: 0.5s, 1s, 2s, 4s = 5 total attempts over 7.5s
# Handles: network blips, Redis restarts (3-5s), connection pool exhaustion
REDIS_RETRY_BACKOFF_FACTOR=0.5

# Redis Sentinel mode - set to True for HA deployments (K8s only)
# When True: point REDIS_HOST to Sentinel K8s service DNS, REDIS_PORT to 26379
# REDIS_PASSWORD is reused for Sentinel auth.
REDIS_SENTINEL_MODE=False
REDIS_SENTINEL_MASTER_NAME=mymaster

# Managed / external Redis with TLS (UN-4123). All optional — unset means the
# plaintext connection this file otherwise describes, unchanged.
#
# Two ways to configure it, pick one:
#   1. Discrete vars (what the Helm chart and these samples use). Set REDIS_SSL=true
#      alongside REDIS_HOST/REDIS_PORT. No URL-encoding to get wrong.
#   2. REDIS_URL, where the SCHEME carries TLS and nothing else is needed:
#        REDIS_URL=rediss://<host>:6380/0?ssl_cert_reqs=required
#        REDIS_PASSWORD=<password>
#        REDIS_USER=                        # blank — see below
#        (The password is better kept OUT of the URL. A URL is printed into log
#         lines, error messages and deployment tooling; a password in one travels
#         with it. Credentials in the URL still work and still win, so an existing
#         rediss://:<password>@host URL keeps behaving exactly as before.)
#        (6380 is an EXAMPLE, not a default — the TLS port is provider-specific:
#         Memorystore 6378, ElastiCache 6379, Azure Cache 6380. A wrong port
#         hangs the connection rather than erroring, so read it off the instance.)
#      A URL wins over the discrete vars above. Percent-encode @ / + in the password.
#
# Auth is password-only, as Redis's built-in `default` user — that is what a managed
# AUTH string is. Leave REDIS_USER empty for a managed endpoint; named ACL users are
# not supported platform-wide.
#
# REDIS_SSL_CA_CERTS is only needed when the server's CA is not in the system trust
# store (Memorystore). ElastiCache and Azure Cache chain to public CAs.
# REDIS_SSL=false
# REDIS_SSL_CERT_REQS=required
# REDIS_SSL_CA_CERTS=
#
# Hostname verification is ON by default (UN-4123): a chain verified against a
# public CA still says nothing about WHICH server answered. Set this to false for
# an endpoint whose certificate does not cover how you address it — an IP, or an
# internal CNAME. Forced off anyway when REDIS_SSL_CERT_REQS=none. Sentinel MASTER
# connections skip it by default, because Sentinel returns an IP that no DNS
# SAN covers and that changes on failover.
# Shown as `false` because that is the only value there is a reason to set:
# `true` is already the default, and setting it EXPLICITLY is not a no-op —
# an explicit value is honoured on Sentinel MASTER connections too, turning
# the compatibility default above back off.
# REDIS_SSL_CHECK_HOSTNAME=false
# REDIS_URL=

# Proactive health check for pooled connections, in seconds (0 disables).
# Managed Redis fails over during maintenance and reaps idle connections — Azure
# Cache closes them at 10 minutes — so a parked connection can be dead before its
# next command. Defaults to 30.
# REDIS_HEALTH_CHECK_INTERVAL=30

# Connector OAuth
SOCIAL_AUTH_EXTRA_DATA_EXPIRATION_TIME_IN_SECOND=3600
GOOGLE_OAUTH2_KEY=
GOOGLE_OAUTH2_SECRET=

# Microsoft sharepoint oauth
AZUREAD_TENANT_OAUTH2_KEY=
AZUREAD_TENANT_OAUTH2_SECRET=

# User session
SESSION_EXPIRATION_TIME_IN_SECOND=7200

# FE Web Application Dependencies
WEB_APP_ORIGIN_URL="http://frontend.unstract.localhost"

# API keys for trusted services
# Workers send this as X-API-Key on internal calls to backend.
# Must match workers/sample.env INTERNAL_SERVICE_API_KEY; rotate in both for prod.
INTERNAL_SERVICE_API_KEY=dev-internal-key-123

# Unstract Core envs
BUILTIN_FUNCTIONS_API_KEY=

FREE_STORAGE_AWS_ACCESS_KEY_ID=
FREE_STORAGE_AWS_SECRET_ACCESS_KEY=
UNSTRACT_FREE_STORAGE_BUCKET_NAME=

GDRIVE_GOOGLE_SERVICE_ACCOUNT=
GDRIVE_GOOGLE_PROJECT_ID=
GOOGLE_STORAGE_ACCESS_KEY_ID=
GOOGLE_STORAGE_SECRET_ACCESS_KEY=
GOOGLE_STORAGE_BASE_URL=https://storage.googleapis.com

# Platform Service
PLATFORM_SERVICE_HOST=http://unstract-platform-service
PLATFORM_SERVICE_PORT=3001

# Tool Runner
UNSTRACT_RUNNER_HOST=http://unstract-runner
UNSTRACT_RUNNER_PORT=5002
UNSTRACT_RUNNER_API_TIMEOUT=240  # (in seconds) 2 mins
UNSTRACT_RUNNER_API_RETRY_COUNT=5  # Number of retries for failed requests
UNSTRACT_RUNNER_API_BACKOFF_FACTOR=3  # Exponential backoff factor for retries

#Prompt Studio
PROMPT_STUDIO_FILE_PATH=/app/prompt-studio-data

# Structure Tool Image (Runs prompt studio exported tools)
# https://hub.docker.com/r/unstract/tool-structure
STRUCTURE_TOOL_IMAGE_URL="docker:unstract/tool-structure:0.0.101"
STRUCTURE_TOOL_IMAGE_NAME="unstract/tool-structure"
STRUCTURE_TOOL_IMAGE_TAG="0.0.101"

# Feature Flags
EVALUATION_SERVER_IP=unstract-flipt
EVALUATION_SERVER_PORT=9000
PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python


#X2Text Service
X2TEXT_HOST=http://unstract-x2text-service
X2TEXT_PORT=3004

# Encryption Key
# Key must be 32 url-safe base64-encoded bytes. Check the README.md for details
ENCRYPTION_KEY="Sample-Key"

# Cache TTL
CACHE_TTL_SEC=10800

# API Deployment Rate Limiting
# Default concurrent request limit per organization
API_DEPLOYMENT_DEFAULT_RATE_LIMIT=20
# Global system-wide concurrent request limit across all organizations
API_DEPLOYMENT_GLOBAL_RATE_LIMIT=100
# Time window (in hours) to consider requests as "active" for rate limiting
API_DEPLOYMENT_RATE_LIMIT_TTL_HOURS=6
# Cache TTL for organization rate limits (in seconds) - TTL is refreshed on every read
# Frequently-used orgs stay cached, inactive orgs expire after this duration
API_DEPLOYMENT_RATE_LIMIT_CACHE_TTL=600
# Redis lock timeout (in seconds) - lock auto-expires if holder crashes
API_DEPLOYMENT_RATE_LIMIT_LOCK_TIMEOUT=2
# Redis lock blocking timeout (in seconds) - how long to wait to acquire lock
API_DEPLOYMENT_RATE_LIMIT_LOCK_BLOCKING_TIMEOUT=5

# Agent-KV API (backend/backend/settings/base.py) — see docs/agent-kv-api.md
# ---------------------------------------------------------------------------
AGENT_KV_PATH_PREFIX=api/v1/agent-kv                # Public URL prefix; shares the /api/v1 ingress rule
AGENT_KV_MAX_FILE_SIZE_MB=50                        # Submit-time file size cap (MB)
AGENT_KV_MAX_PAGES=100                              # Pre-OCR page cap for PDFs/images; also the post-OCR cap the engine enforces
AGENT_KV_MAX_CALCULATIONS_BYTES=20000               # Byte cap on the optional `calculations` field
AGENT_KV_MAX_SCHEMA_BYTES=262144                    # Byte cap on the raw `keys` JSON schema (256 KiB)
AGENT_KV_RESULT_TTL_DAYS=7                          # Result/input retention window, stamped at submit time
AGENT_KV_MAX_TIMEOUT_SECONDS=300                    # Upper bound on the submit `timeout` (sync-wait) field
AGENT_KV_CONCURRENT_LIMIT=5                         # Per-org concurrent in-flight job cap
AGENT_KV_KEY_RATE_LIMIT_PER_MINUTE=60               # Per-key request rate limit (submit + validate)
AGENT_KV_LIMITER_FAIL_OPEN=false                    # true = both limiters above allow the request when Redis is down (default: refuse with 429)
AGENT_KV_SWEEP_GRACE_SECONDS=3600                   # Age before a never-dispatched PENDING job is swept
AGENT_KV_STUCK_JOB_GRACE_SECONDS=21600              # Age (from dispatch) before a stuck DISPATCHED/RUNNING job is force-failed (6h)
AGENT_KV_ABANDONED_SLOT_GRACE_SECONDS=3600         # Age (from CANCELLATION) before a cancelled job's executor is presumed dead and its slot released; must be < the 6h slot TTL
AGENT_KV_CALCULATIONS_ENABLED=false                 # Gates the submit `calculations` field; engine can't run it yet
AGENT_KV_STRUCTURED_OUTPUT_ENABLED=false            # Gates the submit `structured_output` field; engine can't run it yet

# Bucket-rooted object-store root for staged inputs/results
# ({AGENT_KV_STORAGE_DIR_PREFIX}/{org_id}/{job_id}/…), like WORKFLOW_EXECUTION_DIR_PREFIX.
# The FIRST segment is the BUCKET (s3fs/gcsfs treat it so) and must already exist —
# the MinIO dev bootstrap creates `unstract`. MUST match the cloud executor's
# AGENT_KV_STORAGE_DIR_PREFIX: the executor keys its OCR cache under the same root.
AGENT_KV_STORAGE_DIR_PREFIX="unstract/agent_kv"

# Object storage credentials for those files — same shape as
# WORKFLOW_EXECUTION_FILE_STORAGE_CREDENTIALS; required, no default.
AGENT_KV_FILE_STORAGE_CREDENTIALS='{"provider": "minio", "credentials": {"endpoint_url": "http://unstract-minio:9000", "key": "minio", "secret": "minio123"}}'

# Default user auth credentials
DEFAULT_AUTH_USERNAME=
DEFAULT_AUTH_PASSWORD=

# System admin credentials
SYSTEM_ADMIN_USERNAME="admin"
SYSTEM_ADMIN_PASSWORD="admin"
SYSTEM_ADMIN_EMAIL="[email protected]"

# Set Django Session Expiry Time (in seconds)
SESSION_COOKIE_AGE=86400

# Enable logging of workflow history.
ENABLE_LOG_HISTORY=True
# Interval in seconds for periodic consumer operations.
LOG_HISTORY_CONSUMER_INTERVAL=30
# Maximum number of logs to insert in a single batch.
LOGS_BATCH_LIMIT=30
# Logs Expiry of 24 hours
LOGS_EXPIRATION_TIME_IN_SECOND=86400

# Celery Configuration
# Used by celery and to connect to queue to push logs
CELERY_BROKER_BASE_URL="amqp://unstract-rabbitmq:5672//"
CELERY_BROKER_USER=admin
CELERY_BROKER_PASS=password

# Indexing flag to prevent re-index
INDEXING_FLAG_TTL=1800

# Notification Timeout in Seconds
NOTIFICATION_TIMEOUT=5

# Path where public and private tools are registered
# with a YAML and JSONs
TOOL_REGISTRY_CONFIG_PATH="/data/tool_registry_config"

# Flipt Service
FLIPT_SERVICE_AVAILABLE=False

# File System Configuration for Workflow and API Execution

# Directory Prefixes for storing execution files
WORKFLOW_EXECUTION_DIR_PREFIX="unstract/execution"
API_EXECUTION_DIR_PREFIX="unstract/api"

# Storage Provider for Workflow Execution
# Valid options: MINIO, S3, etc..
WORKFLOW_EXECUTION_FILE_STORAGE_CREDENTIALS='{"provider": "minio", "credentials": {"endpoint_url": "http://unstract-minio:9000", "key": "minio", "secret": "minio123"}}'

# Storage Provider for API Execution
API_FILE_STORAGE_CREDENTIALS='{"provider": "minio", "credentials": {"endpoint_url": "http://unstract-minio:9000", "key": "minio", "secret": "minio123"}}'

#Remote storage related envs
PERMANENT_REMOTE_STORAGE='{"provider": "minio", "credentials": {"endpoint_url": "http://unstract-minio:9000", "key": "minio", "secret": "minio123"}}'
TEMPORARY_REMOTE_STORAGE='{"provider": "minio", "credentials": {"endpoint_url": "http://unstract-minio:9000", "key": "minio", "secret": "minio123"}}'
# Profile photos; defaults to a user-profile-photos folder beside the Prompt Studio path
# REMOTE_USER_PROFILE_PHOTO_PATH=unstract/user-profile-photos
REMOTE_PROMPT_STUDIO_FILE_PATH=unstract/prompt-studio-data

# Storage Provider for Tool registry
TOOL_REGISTRY_STORAGE_CREDENTIALS='{"provider":"local"}'

# Highlight data to be available in api deployment
ENABLE_HIGHLIGHT_API_DEPLOYMENT=False

# Execution result and cache expire time
# For API results cached per workflow execution (24 hours)
EXECUTION_RESULT_TTL_SECONDS=86400
# For execution metadata cached per workflow execution (24 hours)
EXECUTION_CACHE_TTL_SECONDS=86400
# Instant workflow polling timeout in seconds (5 minutes)
INSTANT_WF_POLLING_TIMEOUT=300

# Maximum number of batches (i.e., parallel tasks) created for a single workflow execution (1 file at a time)
MAX_PARALLEL_FILE_BATCHES=1
# Maximum allowed value for MAX_PARALLEL_FILE_BATCHES (upper limit for validation)
MAX_PARALLEL_FILE_BATCHES_MAX_VALUE=100
# Maximum number of files allowed per workflow page execution
WORKFLOW_PAGE_MAX_FILES=2

# File execution tracker TTL in seconds (5 hours)
FILE_EXECUTION_TRACKER_TTL_IN_SECOND=18000
# File execution tracker completed TTL in seconds (10 minutes)
FILE_EXECUTION_TRACKER_COMPLETED_TTL_IN_SECOND=600

# Maximum number of times a file can be executed in ETL/TASK workflows
# Default: 3 (file is permanently skipped after 3 execution attempts)
MAX_FILE_EXECUTION_COUNT=3

# Org-scoped group sharing (UN-2977 / mfbt UNS-612)
# Max OrganizationGroup rows allowed per Organization
MAX_GROUPS_PER_ORG=200
# Max GroupMembership rows allowed per OrganizationGroup
MAX_MEMBERS_PER_GROUP=500

# Runner polling timeout (3 hours)
MAX_RUNNER_POLLING_WAIT_SECONDS=10800
# Runner polling interval (2 seconds)
RUNNER_POLLING_INTERVAL_SECONDS=2

# ETL Pipeline minimum schedule interval (in seconds)
# Default: 1800 seconds (30 minutes)
# Examples: 900 (15 min), 1800 (30 min), 3600 (60 min)
MIN_SCHEDULE_INTERVAL_SECONDS=1800

# Dashboard Metrics Cache TTLs (in seconds)
DASHBOARD_CACHE_TTL_CURRENT_BUCKET=60
DASHBOARD_CACHE_TTL_HISTORICAL=28800
DASHBOARD_CACHE_TTL_OVERVIEW=300
DASHBOARD_CACHE_TTL_SUMMARY=900
DASHBOARD_CACHE_TTL_SERIES=1800
DASHBOARD_CACHE_TTL_WORKFLOW_USAGE=3600

# HITL Files Storage Configuration
HITL_FILES_FILE_STORAGE_CREDENTIALS='{"provider": "minio", "credentials": {"endpoint_url": "http://unstract-minio:9000", "key": "minio", "secret": "minio123"}}'

# File active cache redis db
FILE_ACTIVE_CACHE_REDIS_DB=0

# Hosted MCP servers
# The deployment-scoped server (/deployment/api/<org>/<api_name>/mcp) is always
# mounted. The organization-scoped server (/api/v1/unstract/<org>/mcp/) is off
# by default — it exposes 23 org-wide tools and only the deployment server is
# required for the initial release. Set to "true" to enable it.
MCP_PLATFORM_SERVER_ENABLED=false
# Budget for billable MCP tool calls (LLM inference, indexing, pipeline runs),
# counted per organization over a rolling window. Counts calls, not tokens.
MCP_BILLABLE_CALL_LIMIT=50
MCP_BILLABLE_WINDOW_SECONDS=3600

# Platform audit log (Settings > Audit log): days events stay readable. Each org
# can override it. Expired rows are hidden, and deleted when the
# `purge_platform_audit_events` management command runs.
PLATFORM_AUDIT_RETENTION_DAYS=365