Skip to content

Commit

Permalink
feature: remove max_active_request on create app page
Browse files Browse the repository at this point in the history
  • Loading branch information
liuzhenghua-jk committed Jul 8, 2024
1 parent 96d78a7 commit ea655da
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 26 deletions.
3 changes: 0 additions & 3 deletions api/controllers/console/app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion api/core/app/features/rate_limiting/rate_limit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
1 change: 0 additions & 1 deletion api/services/app_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
22 changes: 2 additions & 20 deletions web/app/components/app/create-app-modal/index.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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<number | null>(null)
const handleMaxActiveRequestsChange = (e: ChangeEvent<HTMLInputElement>) => {
const value = e.target.value
if ((parseInt(value) >= 0 && !value.startsWith('-')))
setMaxActiveRequests(parseInt(value))
}
const [description, setDescription] = useState('')

const { plan, enableBilling } = useProviderContext()
Expand All @@ -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') })
Expand All @@ -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 (
<Modal
Expand Down Expand Up @@ -295,17 +288,6 @@ const CreateAppModal = ({ show, onSuccess, onClose }: CreateAppDialogProps) => {
}}
/>}
</div>
{/* max active requests */}
<div className='pt-2 px-8'>
<div className='py-2 text-sm font-medium leading-[20px] text-gray-900'>{t('app.newApp.appMaxActiveRequests')}</div>
<input
type="number"
className='w-full h-10 px-3 text-sm font-normal bg-gray-100 rounded-lg border border-transparent outline-none appearance-none caret-primary-600 placeholder:text-gray-400 hover:bg-gray-50 hover:border hover:border-gray-300 focus:bg-gray-50 focus:border focus:border-gray-300 focus:shadow-xs'
placeholder={t('app.newApp.appMaxActiveRequestsPlaceholder') || ''}
value={max_active_requests}
onChange={handleMaxActiveRequestsChange}
/>
</div>
{/* description */}
<div className='pt-2 px-8'>
<div className='py-2 text-sm font-medium leading-[20px] text-gray-900'>{t('app.newApp.captionDescription')}</div>
Expand Down
1 change: 0 additions & 1 deletion web/app/components/explore/app-list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit ea655da

Please sign in to comment.