# ------------------------------------------------------------------ # KnowledgeFS integration service (started by the default Dify Compose deployment). # Copy to knowledge-fs.env and configure durable dependencies before enabling product traffic. # The Dify product flag remains disabled by default and no public proxy route is added. # Dify inner API connection values and integrated mode are injected by docker-compose.yaml. # Physical object storage is owned by Dify's configured STORAGE_TYPE and credentials; do not copy # provider endpoints, bucket names, access keys, or secret keys into this service. # Optional feature flags and capacity tunables use safe runtime defaults and belong here only when # an operator intentionally enables or overrides that feature. # ------------------------------------------------------------------ # Required durable database. Do not point this at Dify's application database or reuse # Dataset/Document tables. Apply KnowledgeFS migrations before starting product traffic. DATABASE_URL= KNOWLEDGE_DOCUMENT_COMPILATION_RUNTIME=on # A quiescing step performs several bounded cleanup statements in one transaction. Keep this # comfortably below the derived worker lease while allowing normal database round trips to finish. DURABLE_DELETION_STEP_TIMEOUT_MS=30000 # Source reads, parsing, archive/media extraction, thumbnails, and artifact writes share this # process-wide admission budget across every supported document format. KNOWLEDGE_DOCUMENT_MATERIALIZATION_MAX_CONCURRENCY=2 # A canonical ParseArtifact stays live through outline, semantic, graph, and index consumers. # These process-wide limits prevent the compilation claim batch from retaining many large parser # responses at once. One artifact charged at the byte ceiling is allowed to run exclusively. KNOWLEDGE_DOCUMENT_RETAINED_ARTIFACT_MAX_CONCURRENCY=4 KNOWLEDGE_DOCUMENT_RETAINED_ARTIFACT_MAX_BYTES=134217728 # PDF image elements are rasterized by the Poppler executable bundled in the API image. The # limits are per document/asset operation. Set the mode to off as an emergency or low-resource # kill switch; do not set a host-specific command path when using the published image. KNOWLEDGE_PDF_RASTERIZER=poppler KNOWLEDGE_PDF_RASTERIZER_DPI=144 KNOWLEDGE_PDF_RASTERIZER_THUMBNAIL_DPI=48 KNOWLEDGE_PDF_RASTERIZER_TIMEOUT_MS=30000 KNOWLEDGE_PDF_RASTERIZER_MAX_ASSETS=500 KNOWLEDGE_PDF_RASTERIZER_MAX_CONCURRENCY=2 # Ingestion-time LLM concurrency. The per-document outline limit improves one document's latency; # the process-wide fair limit prevents simultaneous imports from multiplying provider pressure. # The global value is per API replica and also covers embedding transport requests. KNOWLEDGE_OUTLINE_SUMMARY_MAX_CONCURRENCY=8 KNOWLEDGE_OUTLINE_SUMMARY_BATCH_SIZE=8 KNOWLEDGE_OUTLINE_SUMMARY_BATCH_MAX_INPUT_CHARS=32000 KNOWLEDGE_MODEL_RUNTIME_GLOBAL_CONCURRENCY=16 KNOWLEDGE_SEMANTIC_EXTRACTION_BATCH_SIZE=8 KNOWLEDGE_SEMANTIC_EXTRACTION_MAX_CONCURRENCY=4 # Dify/plugin-daemon embedding requests carry at most 16 texts each. Two concurrent requests # improve large-document latency while keeping high-dimensional response memory bounded. KNOWLEDGE_EMBEDDING_REQUEST_CONCURRENCY=2 # Visual embeddings follow each knowledge space's active embedding capability. Keep each enabled # image-byte request below both a count and raw-byte ceiling; these values never select a model. KNOWLEDGE_VISUAL_EMBEDDING_MAX_ASSET_BYTES=20971520 KNOWLEDGE_VISUAL_EMBEDDING_MAX_BATCH_ASSETS=8 KNOWLEDGE_VISUAL_EMBEDDING_MAX_BATCH_BYTES=33554432 KNOWLEDGE_VISUAL_EMBEDDING_MAX_CONCURRENCY=2 # Document image understanding and answer image blocks follow the active reasoning capability. # These ceilings bound per-process VLM concurrency and raw bytes retained before base64 encoding. KNOWLEDGE_MULTIMODAL_ENRICHMENT_MAX_CONCURRENCY=4 KNOWLEDGE_MULTIMODAL_ENRICHMENT_MAX_IMAGE_BYTES=10485760 KNOWLEDGE_MULTIMODAL_ANSWER_MAX_CONCURRENCY=2 KNOWLEDGE_MULTIMODAL_ANSWER_MAX_IMAGE_ATTACHMENTS=8 KNOWLEDGE_MULTIMODAL_ANSWER_MAX_IMAGE_BYTES=10485760 KNOWLEDGE_MULTIMODAL_ANSWER_MAX_TOTAL_IMAGE_BYTES=33554432 # Required before enabling integrated product traffic. Set ENABLED=true only after providing the # public-only current/previous JWKS that matches Dify's signer. Never copy Dify's private key here. KNOWLEDGE_FS_CAPABILITY_V2_ENABLED=false KNOWLEDGE_FS_CAPABILITY_V2_PUBLIC_JWKS= # Internal Dify API-to-KnowledgeFS data paths. These flags do not expose browser CORS routes. # Integrated document staging depends on upload sessions. Keep the default upload, multipart, # and parser envelopes aligned with Dify's current 15 MiB document limit. Direct KnowledgeFS # clients may raise the upload/parser limits together up to the documented 50 MiB hard ceiling; # Dify product routes remain capped by their 15 MiB product-operation contract. KNOWLEDGE_DIRECT_UPLOAD_ENABLED=on KNOWLEDGE_DIRECT_UPLOAD_MAX_FILE_BYTES=15728640 KNOWLEDGE_DIRECT_UPLOAD_MULTIPART_THRESHOLD_BYTES=15728640 KNOWLEDGE_DIRECT_UPLOAD_SMALL_FALLBACK_MAX_BYTES=15728640 # The integrated Dify adapter cannot presign uploads, so this compatibility path buffers request # bytes before writing them. Bound both active uploads and their aggregate retained payload bytes. KNOWLEDGE_DIRECT_UPLOAD_SMALL_FALLBACK_MAX_CONCURRENCY=2 KNOWLEDGE_DIRECT_UPLOAD_SMALL_FALLBACK_MAX_RESERVED_BYTES=31457280 # Direct multipart document routes use a separate pre-validator gate. The retained-byte charge is # conservative (bounded stream chunks + Hono caches + File.arrayBuffer), not an RSS measurement. KNOWLEDGE_BUFFERED_DOCUMENT_UPLOAD_MAX_CONCURRENCY=2 KNOWLEDGE_BUFFERED_DOCUMENT_UPLOAD_MAX_RESERVED_BYTES=201326592 KNOWLEDGE_BUFFERED_DOCUMENT_UPLOAD_IDLE_TIMEOUT_MS=30000 KNOWLEDGE_BUFFERED_DOCUMENT_UPLOAD_TOTAL_TIMEOUT_MS=600000 # Enable Research task SSE only when the durable task progress repository is ready. KNOWLEDGE_DIRECT_STREAM_ENABLED=off # One generous cap avoids a second full Judge call when a reasoning model consumes hidden tokens. # Judge prompts still require compact JSON and supported OpenAI reasoning models use low effort. KNOWLEDGE_RESEARCH_REASONING_MAX_OUTPUT_TOKENS=8192 KNOWLEDGE_RESEARCH_REASONING_TIMEOUT_MS=60000 # One initial pool is shared fairly across the original query and all planned intents. # Lower it to trade recall depth for latency. A durable supplemental list is separately plan-bounded. KNOWLEDGE_RESEARCH_MAX_RERANK_CANDIDATES=200 # Query-image retrieval follows the active knowledge-space embedding/reasoning model capabilities. # Deep/Research perform at most one vision expansion per query; durable Research retries reuse it. KNOWLEDGE_QUERY_IMAGE_EXPANSION_TIMEOUT_MS=8000 # The bundled profile uses this internal service name. Override it with an external # Unstructured-compatible endpoint when the deployment owns that provider instead. UNSTRUCTURED_API_URL=http://knowledge_fs_unstructured:8000 UNSTRUCTURED_API_KEY= # This is the process-wide ceiling shared by all remote parser requests. The nested heavy limit # covers every PDF plus structurally/byte-heavy Office, email, EPUB, ODT, and RTF request. UNSTRUCTURED_MAX_CONCURRENCY=2 UNSTRUCTURED_HEAVY_MAX_CONCURRENCY=1 # Keep the parser cap aligned with the default 15 MiB product upload limit. Operators increasing # the upload cap must raise this value deliberately; the API rejects values above 50 MiB. UNSTRUCTURED_MAX_INPUT_BYTES=15728640 # Ordinary documents use a generic ten-minute deadline. Only classified heavy documents get # bounded extra headroom, so a small DOCX/PPTX/XLSX does not inherit the 40-minute ceiling. UNSTRUCTURED_REQUEST_TIMEOUT_MS=600000 UNSTRUCTURED_HEAVY_REQUEST_TIMEOUT_MS=2400000 UNSTRUCTURED_MAX_RESPONSE_BYTES=33554432 # Durable compilation owns attempt retries. Do not multiply them with parser-client retries. UNSTRUCTURED_MAX_RETRIES=0 # Bound authenticated Dify object-storage calls so cleanup cannot hang a compilation lease forever. DIFY_OBJECT_STORAGE_REQUEST_TIMEOUT_MS=60000 DIFY_REMOTE_IMAGE_REQUEST_TIMEOUT_MS=30000