From ea655da184720370886dcd1e20c804fe3e073e77 Mon Sep 17 00:00:00 2001 From: liuzhenghua-jk Date: Mon, 8 Jul 2024 13:41:35 +0000 Subject: [PATCH] feature: remove max_active_request on create app page --- api/controllers/console/app/app.py | 3 --- .../app/features/rate_limiting/rate_limit.py | 2 +- api/services/app_service.py | 1 - .../components/app/create-app-modal/index.tsx | 22 ++----------------- web/app/components/explore/app-list/index.tsx | 1 - 5 files changed, 3 insertions(+), 26 deletions(-) diff --git a/api/controllers/console/app/app.py b/api/controllers/console/app/app.py index 2587836e82b0a3..6952940649251c 100644 --- a/api/controllers/console/app/app.py +++ b/api/controllers/console/app/app.py @@ -58,7 +58,6 @@ def post(self): """Create app""" parser = reqparse.RequestParser() parser.add_argument('name', type=str, required=True, location='json') - parser.add_argument('max_active_requests', type=int, location='json') parser.add_argument('description', type=str, location='json') parser.add_argument('mode', type=str, choices=ALLOW_CREATE_APP_MODES, location='json') parser.add_argument('icon', type=str, location='json') @@ -71,8 +70,6 @@ def post(self): if 'mode' not in args or args['mode'] is None: raise BadRequest("mode is required") - if 'max_active_requests' in args and args['max_active_requests'] is not None and args['max_active_requests'] < 0: - raise BadRequest("max active requests should be a non-negative integer") app_service = AppService() app = app_service.create_app(current_user.current_tenant_id, args, current_user) diff --git a/api/core/app/features/rate_limiting/rate_limit.py b/api/core/app/features/rate_limiting/rate_limit.py index 5ca59a9479b9b3..d2d2f0e3b82f90 100644 --- a/api/core/app/features/rate_limiting/rate_limit.py +++ b/api/core/app/features/rate_limiting/rate_limit.py @@ -25,11 +25,11 @@ def __new__(cls: type['RateLimit'], client_id: str, max_active_requests: int): return cls._instance_dict[client_id] def __init__(self, client_id: str, max_active_requests: int): + self.max_active_requests = max_active_requests if hasattr(self, 'initialized'): return self.initialized = True self.client_id = client_id - self.max_active_requests = max_active_requests self.active_requests_key = self._ACTIVE_REQUESTS_KEY.format(client_id) self.max_active_requests_key = self._MAX_ACTIVE_REQUESTS_KEY.format(client_id) self.last_recalculate_time = float('-inf') diff --git a/api/services/app_service.py b/api/services/app_service.py index 97cda6c1f2186c..fc9d0dd5b89e18 100644 --- a/api/services/app_service.py +++ b/api/services/app_service.py @@ -119,7 +119,6 @@ def create_app(self, tenant_id: str, args: dict, account: Account) -> App: app = App(**app_template['app']) app.name = args['name'] - app.max_active_requests = args['max_active_requests'] app.description = args.get('description', '') app.mode = args['mode'] app.icon = args['icon'] diff --git a/web/app/components/app/create-app-modal/index.tsx b/web/app/components/app/create-app-modal/index.tsx index a296bf53036837..11e265e9ad606f 100644 --- a/web/app/components/app/create-app-modal/index.tsx +++ b/web/app/components/app/create-app-modal/index.tsx @@ -1,5 +1,5 @@ 'use client' -import type { ChangeEvent, MouseEventHandler } from 'react' +import type { MouseEventHandler } from 'react' import { useCallback, useRef, useState } from 'react' import { useTranslation } from 'react-i18next' import cn from 'classnames' @@ -43,12 +43,6 @@ const CreateAppModal = ({ show, onSuccess, onClose }: CreateAppDialogProps) => { const [emoji, setEmoji] = useState({ icon: '🤖', icon_background: '#FFEAD5' }) const [showEmojiPicker, setShowEmojiPicker] = useState(false) const [name, setName] = useState('') - const [max_active_requests, setMaxActiveRequests] = useState(null) - const handleMaxActiveRequestsChange = (e: ChangeEvent) => { - const value = e.target.value - if ((parseInt(value) >= 0 && !value.startsWith('-'))) - setMaxActiveRequests(parseInt(value)) - } const [description, setDescription] = useState('') const { plan, enableBilling } = useProviderContext() @@ -74,7 +68,6 @@ const CreateAppModal = ({ show, onSuccess, onClose }: CreateAppDialogProps) => { description, icon: emoji.icon, icon_background: emoji.icon_background, - max_active_requests, mode: appMode, }) notify({ type: 'success', message: t('app.newApp.appCreated') }) @@ -88,7 +81,7 @@ const CreateAppModal = ({ show, onSuccess, onClose }: CreateAppDialogProps) => { notify({ type: 'error', message: t('app.newApp.appCreateFailed') }) } isCreatingRef.current = false - }, [name, notify, t, appMode, emoji.icon, emoji.icon_background, max_active_requests, description, onSuccess, onClose, mutateApps, push, isCurrentWorkspaceEditor]) + }, [name, notify, t, appMode, emoji.icon, emoji.icon_background, description, onSuccess, onClose, mutateApps, push, isCurrentWorkspaceEditor]) return ( { }} />} - {/* max active requests */} -
-
{t('app.newApp.appMaxActiveRequests')}
- -
{/* description */}
{t('app.newApp.captionDescription')}
diff --git a/web/app/components/explore/app-list/index.tsx b/web/app/components/explore/app-list/index.tsx index c0769bc2b608cf..8a69d2f5cbf57e 100644 --- a/web/app/components/explore/app-list/index.tsx +++ b/web/app/components/explore/app-list/index.tsx @@ -188,7 +188,6 @@ const Apps = ({ appIcon={currApp?.app.icon || ''} appIconBackground={currApp?.app.icon_background || ''} appName={currApp?.app.name || ''} - maxActiveRequests={currApp?.app.max_active_request || 0} appDescription={currApp?.app.description || ''} show={isShowCreateModal} onConfirm={onCreate}