mirror of
https://gitee.com/dify_ai/dify.git
synced 2025-12-06 11:29:30 +08:00
feat: add APP_DEFAULT_ACTIVE_REQUESTS as the default value for APP_AC… (#26930)
This commit is contained in:
@@ -540,6 +540,7 @@ WORKFLOW_LOG_CLEANUP_BATCH_SIZE=100
|
||||
|
||||
# App configuration
|
||||
APP_MAX_EXECUTION_TIME=1200
|
||||
APP_DEFAULT_ACTIVE_REQUESTS=0
|
||||
APP_MAX_ACTIVE_REQUESTS=0
|
||||
|
||||
# Celery beat configuration
|
||||
|
||||
@@ -73,6 +73,10 @@ class AppExecutionConfig(BaseSettings):
|
||||
description="Maximum allowed execution time for the application in seconds",
|
||||
default=1200,
|
||||
)
|
||||
APP_DEFAULT_ACTIVE_REQUESTS: NonNegativeInt = Field(
|
||||
description="Default number of concurrent active requests per app (0 for unlimited)",
|
||||
default=0,
|
||||
)
|
||||
APP_MAX_ACTIVE_REQUESTS: NonNegativeInt = Field(
|
||||
description="Maximum number of concurrent active requests per app (0 for unlimited)",
|
||||
default=0,
|
||||
|
||||
@@ -135,7 +135,7 @@ class AppGenerateService:
|
||||
Returns:
|
||||
The maximum number of active requests allowed
|
||||
"""
|
||||
app_limit = app.max_active_requests or 0
|
||||
app_limit = app.max_active_requests or dify_config.APP_DEFAULT_ACTIVE_REQUESTS
|
||||
config_limit = dify_config.APP_MAX_ACTIVE_REQUESTS
|
||||
|
||||
# Filter out infinite (0) values and return the minimum, or 0 if both are infinite
|
||||
|
||||
@@ -53,10 +53,11 @@ class PipelineGenerateService:
|
||||
|
||||
@staticmethod
|
||||
def _get_max_active_requests(app_model: App) -> int:
|
||||
max_active_requests = app_model.max_active_requests
|
||||
if max_active_requests is None:
|
||||
max_active_requests = int(dify_config.APP_MAX_ACTIVE_REQUESTS)
|
||||
return max_active_requests
|
||||
app_limit = app_model.max_active_requests or dify_config.APP_DEFAULT_ACTIVE_REQUESTS
|
||||
config_limit = dify_config.APP_MAX_ACTIVE_REQUESTS
|
||||
# Filter out infinite (0) values and return the minimum, or 0 if both are infinite
|
||||
limits = [limit for limit in [app_limit, config_limit] if limit > 0]
|
||||
return min(limits) if limits else 0
|
||||
|
||||
@classmethod
|
||||
def generate_single_iteration(
|
||||
|
||||
@@ -175,6 +175,7 @@ MAX_VARIABLE_SIZE=204800
|
||||
|
||||
# App configuration
|
||||
APP_MAX_EXECUTION_TIME=1200
|
||||
APP_DEFAULT_ACTIVE_REQUESTS=0
|
||||
APP_MAX_ACTIVE_REQUESTS=0
|
||||
|
||||
# Celery beat configuration
|
||||
|
||||
@@ -82,6 +82,7 @@ class TestAppGenerateService:
|
||||
# Setup dify_config mock returns
|
||||
mock_dify_config.BILLING_ENABLED = False
|
||||
mock_dify_config.APP_MAX_ACTIVE_REQUESTS = 100
|
||||
mock_dify_config.APP_DEFAULT_ACTIVE_REQUESTS = 100
|
||||
mock_dify_config.APP_DAILY_RATE_LIMIT = 1000
|
||||
|
||||
mock_global_dify_config.BILLING_ENABLED = False
|
||||
|
||||
@@ -133,6 +133,8 @@ ACCESS_TOKEN_EXPIRE_MINUTES=60
|
||||
# Refresh token expiration time in days
|
||||
REFRESH_TOKEN_EXPIRE_DAYS=30
|
||||
|
||||
# The default number of active requests for the application, where 0 means unlimited, should be a non-negative integer.
|
||||
APP_DEFAULT_ACTIVE_REQUESTS=0
|
||||
# The maximum number of active requests for the application, where 0 means unlimited, should be a non-negative integer.
|
||||
APP_MAX_ACTIVE_REQUESTS=0
|
||||
APP_MAX_EXECUTION_TIME=1200
|
||||
|
||||
@@ -34,6 +34,7 @@ x-shared-env: &shared-api-worker-env
|
||||
FILES_ACCESS_TIMEOUT: ${FILES_ACCESS_TIMEOUT:-300}
|
||||
ACCESS_TOKEN_EXPIRE_MINUTES: ${ACCESS_TOKEN_EXPIRE_MINUTES:-60}
|
||||
REFRESH_TOKEN_EXPIRE_DAYS: ${REFRESH_TOKEN_EXPIRE_DAYS:-30}
|
||||
APP_DEFAULT_ACTIVE_REQUESTS: ${APP_DEFAULT_ACTIVE_REQUESTS:-0}
|
||||
APP_MAX_ACTIVE_REQUESTS: ${APP_MAX_ACTIVE_REQUESTS:-0}
|
||||
APP_MAX_EXECUTION_TIME: ${APP_MAX_EXECUTION_TIME:-1200}
|
||||
DIFY_BIND_ADDRESS: ${DIFY_BIND_ADDRESS:-0.0.0.0}
|
||||
|
||||
Reference in New Issue
Block a user