From 006dc60e0bf3863898f7b48505ac59c0b95d9c91 Mon Sep 17 00:00:00 2001 From: Bowen Liang Date: Sat, 15 Jun 2024 22:49:47 +0800 Subject: [PATCH] ToolConfigs --- api/config.py | 4 --- api/configs/feature/__init__.py | 32 +++++++++++++------ .../console/workspace/tool_providers.py | 2 +- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/api/config.py b/api/config.py index c99e77f40589c9..be00dbe70b730f 100644 --- a/api/config.py +++ b/api/config.py @@ -46,7 +46,6 @@ 'INVITE_EXPIRY_HOURS': 72, 'ETL_TYPE': 'dify', 'KEYWORD_STORE': 'jieba', - 'TOOL_ICON_CACHE_MAX_AGE': 3600, 'MILVUS_DATABASE': 'default', 'KEYWORD_DATA_SOURCE_TYPE': 'database', 'INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH': 1000, @@ -261,9 +260,6 @@ def __init__(self): # Indexing Configurations. self.INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH = get_env('INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH') - # Tool Configurations. - self.TOOL_ICON_CACHE_MAX_AGE = get_env('TOOL_ICON_CACHE_MAX_AGE') - # ------------------------ # Platform Configurations. # ------------------------ diff --git a/api/configs/feature/__init__.py b/api/configs/feature/__init__.py index 68d89f59e53f00..f94de8daa0f3fc 100644 --- a/api/configs/feature/__init__.py +++ b/api/configs/feature/__init__.py @@ -259,21 +259,33 @@ class ModerationConfigs(BaseModel): ) +class ToolConfigs(BaseModel): + """ + Tool configs + """ + + TOOL_ICON_CACHE_MAX_AGE: PositiveInt = Field( + description='max age in seconds for tool icon caching', + default=3600, + ) + + class FeatureConfigs( - OAuthConfigs, - ModerationConfigs, + AppExecutionConfigs, + BillingConfigs, + CodeExecutionSandboxConfigs, EndpointConfigs, + FileAccessConfigs, + FileUploadConfigs, HttpConfigs, + InnerAPIConfigs, LoggingConfigs, + ModelLoadBalanceConfigs, + ModerationConfigs, + OAuthConfigs, SecurityConfigs, - InnerAPIConfigs, - AppExecutionConfigs, - WorkflowConfigs, - CodeExecutionSandboxConfigs, - FileUploadConfigs, - FileAccessConfigs, + ToolConfigs, UpdateConfigs, - ModelLoadBalanceConfigs, - BillingConfigs, + WorkflowConfigs, ): pass diff --git a/api/controllers/console/workspace/tool_providers.py b/api/controllers/console/workspace/tool_providers.py index a911e9b2cb3e54..6e3f78d4e2e55b 100644 --- a/api/controllers/console/workspace/tool_providers.py +++ b/api/controllers/console/workspace/tool_providers.py @@ -104,7 +104,7 @@ class ToolBuiltinProviderIconApi(Resource): @setup_required def get(self, provider): icon_bytes, mimetype = BuiltinToolManageService.get_builtin_tool_provider_icon(provider) - icon_cache_max_age = int(current_app.config.get('TOOL_ICON_CACHE_MAX_AGE')) + icon_cache_max_age = current_app.config.get('TOOL_ICON_CACHE_MAX_AGE') return send_file(io.BytesIO(icon_bytes), mimetype=mimetype, max_age=icon_cache_max_age) class ToolApiProviderAddApi(Resource):