Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
allow to config max segmentation tokens length for RAG document using environment variable (#4375)
Rain Chenc255a20d7ce5
diff --git a/api/.env.example b/api/.env.exampleindex 05d4f4a530d..cadb4761504 100644--- a/api/.env.example+++ b/api/.env.example@@ -176,3 +176,6 @@ HTTP_REQUEST_NODE_MAX_TEXT_SIZE=1048576 # 1MB# Log file pathLOG_FILE=++# Indexing configuration+INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH=1000diff --git a/api/config.py b/api/config.pyindex 4d1f9054409..ed2ba41d4a1 100644--- a/api/config.py+++ b/api/config.py@@ -79,6 +79,7 @@ DEFAULTS = {'KEYWORD_DATA_SOURCE_TYPE': 'database','INNER_API': 'False','ENTERPRISE_ENABLED': 'False',+ 'INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH': 1000,}@@ -379,3 +380,8 @@ class Config:self.KEYWORD_DATA_SOURCE_TYPE = get_env('KEYWORD_DATA_SOURCE_TYPE')self.ENTERPRISE_ENABLED = get_bool_env('ENTERPRISE_ENABLED')++ # ------------------------+ # Indexing Configurations.+ # ------------------------+ self.INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH = get_env('INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH')diff --git a/api/core/indexing_runner.py b/api/core/indexing_runner.pyindex b812999b87e..d3886b8e77f 100644--- a/api/core/indexing_runner.py+++ b/api/core/indexing_runner.py@@ -411,8 +411,9 @@ class IndexingRunner:# The user-defined segmentation rulerules = json.loads(processing_rule.rules)segmentation = rules["segmentation"]- if segmentation["max_tokens"] < 50 or segmentation["max_tokens"] > 1000:- raise ValueError("Custom segment length should be between 50 and 1000.")+ max_segmentation_tokens_length = int(current_app.config['INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH'])+ if segmentation["max_tokens"] < 50 or segmentation["max_tokens"] > max_segmentation_tokens_length:+ raise ValueError(f"Custom segment length should be between 50 and {max_segmentation_tokens_length}.")separator = segmentation["separator"]if separator:diff --git a/api/core/rag/index_processor/index_processor_base.py b/api/core/rag/index_processor/index_processor_base.pyindex 509a1a189b2..c51634fee1f 100644--- a/api/core/rag/index_processor/index_processor_base.py+++ b/api/core/rag/index_processor/index_processor_base.py@@ -2,6 +2,8 @@from abc import ABC, abstractmethodfrom typing import Optional+from flask import current_app+from core.model_manager import ModelInstancefrom core.rag.extractor.entity.extract_setting import ExtractSettingfrom core.rag.models.document import Document@@ -43,8 +45,9 @@ class BaseIndexProcessor(ABC):# The user-defined segmentation rulerules = processing_rule['rules']segmentation = rules["segmentation"]- if segmentation["max_tokens"] < 50 or segmentation["max_tokens"] > 1000:- raise ValueError("Custom segment length should be between 50 and 1000.")+ max_segmentation_tokens_length = int(current_app.config['INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH'])+ if segmentation["max_tokens"] < 50 or segmentation["max_tokens"] > max_segmentation_tokens_length:+ raise ValueError(f"Custom segment length should be between 50 and {max_segmentation_tokens_length}.")separator = segmentation["separator"]if separator:diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yamlindex 8e7c94469d3..d130527682c 100644--- a/docker/docker-compose.yaml+++ b/docker/docker-compose.yaml@@ -167,6 +167,8 @@ services:# SSRF Proxy serverSSRF_PROXY_HTTP_URL: 'http://ssrf_proxy:3128'SSRF_PROXY_HTTPS_URL: 'http://ssrf_proxy:3128'+ # Indexing configuration+ INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH: 1000depends_on:- db- redis@@ -287,6 +289,8 @@ services:NOTION_CLIENT_SECRET: you-client-secretNOTION_CLIENT_ID: you-client-idNOTION_INTERNAL_SECRET: you-internal-secret+ # Indexing configuration+ INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH: 1000depends_on:- db- redis