From 343ada135dfb3e778b68e5bd142f953bf366552d Mon Sep 17 00:00:00 2001 From: jialin Date: Fri, 8 Nov 2024 15:08:32 +0800 Subject: [PATCH] fix: backend updateable when local path --- src/components/logs-viewer/logs-list.tsx | 10 ++++++---- .../logs-viewer/logs-pagination.tsx | 2 +- .../logs-viewer/virtual-log-list.tsx | 19 ++++++++++++------ .../llmodels/components/advance-config.tsx | 20 ++++++++++++++----- src/pages/llmodels/components/data-form.tsx | 1 + src/pages/llmodels/components/table-list.tsx | 2 +- .../llmodels/components/update-modal.tsx | 1 + 7 files changed, 38 insertions(+), 17 deletions(-) diff --git a/src/components/logs-viewer/logs-list.tsx b/src/components/logs-viewer/logs-list.tsx index efe2516c..f23acdee 100644 --- a/src/components/logs-viewer/logs-list.tsx +++ b/src/components/logs-viewer/logs-list.tsx @@ -41,8 +41,14 @@ const LogsList: React.FC = forwardRef((props, ref) => { updateScrollerPosition(0); }, [updateScrollerPosition]); + const debounceResetStopScroll = _.debounce(() => { + stopScroll.current = false; + }, 30000); + const scrollToTop = useCallback(() => { + stopScroll.current = true; updateScrollerPositionToTop(); + debounceResetStopScroll(); }, [updateScrollerPositionToTop]); useImperativeHandle(ref, () => ({ @@ -50,10 +56,6 @@ const LogsList: React.FC = forwardRef((props, ref) => { scrollToTop })); - const debounceResetStopScroll = _.debounce(() => { - stopScroll.current = false; - }, 30000); - const handleOnWheel = useCallback( (e: any) => { const scrollTop = scrollEventElement?.scrollTop; diff --git a/src/components/logs-viewer/logs-pagination.tsx b/src/components/logs-viewer/logs-pagination.tsx index 77940825..4f70ae9c 100644 --- a/src/components/logs-viewer/logs-pagination.tsx +++ b/src/components/logs-viewer/logs-pagination.tsx @@ -13,7 +13,7 @@ interface LogsPaginationProps { } const LogsPagination: React.FC = (props) => { - const { page, total, pageSize, onNext, onPrev } = props; + const { page, total, pageSize, onWheel, onNext, onPrev } = props; const intl = useIntl(); const handleOnPrev = () => { diff --git a/src/components/logs-viewer/virtual-log-list.tsx b/src/components/logs-viewer/virtual-log-list.tsx index db3c10f3..892fd9bc 100644 --- a/src/components/logs-viewer/virtual-log-list.tsx +++ b/src/components/logs-viewer/virtual-log-list.tsx @@ -181,6 +181,18 @@ const LogsViewer: React.FC = forwardRef((props, ref) => { [loading, isLoadend, logs.length, pageSize] ); + const debouncedScroll = useCallback( + _.debounce(() => { + if (scrollPos[0] === 'top') { + logListRef.current?.scrollToTop(); + } + if (scrollPos[0] === 'bottom') { + logListRef.current?.scrollToBottom(); + } + }, 150), + [scrollPos] + ); + useEffect(() => { createChunkConnection(); return () => { @@ -189,12 +201,7 @@ const LogsViewer: React.FC = forwardRef((props, ref) => { }, [url, props.params]); useEffect(() => { - if (scrollPos[0] === 'top') { - logListRef.current?.scrollToTop(); - } - if (scrollPos[0] === 'bottom') { - logListRef.current?.scrollToBottom(); - } + debouncedScroll(); }, [scrollPos]); return ( diff --git a/src/pages/llmodels/components/advance-config.tsx b/src/pages/llmodels/components/advance-config.tsx index 4a0635e9..fd3c33ad 100644 --- a/src/pages/llmodels/components/advance-config.tsx +++ b/src/pages/llmodels/components/advance-config.tsx @@ -17,7 +17,11 @@ import { } from 'antd'; import _ from 'lodash'; import React, { useCallback, useMemo } from 'react'; -import { backendOptionsMap, placementStrategyOptions } from '../config'; +import { + backendOptionsMap, + modelSourceMap, + placementStrategyOptions +} from '../config'; import llamaConfig from '../config/llama-config'; import { FormData } from '../config/types'; import vllmConfig from '../config/vllm-config'; @@ -29,10 +33,11 @@ interface AdvanceConfigProps { form: FormInstance; gpuOptions: Array; action: PageActionType; + source: string; } const AdvanceConfig: React.FC = (props) => { - const { form, gpuOptions, isGGUF, action } = props; + const { form, gpuOptions, isGGUF, action, source } = props; const intl = useIntl(); const wokerSelector = Form.useWatch('worker_selector', form); @@ -239,15 +244,20 @@ const AdvanceConfig: React.FC = (props) => { { label: `llama-box(llama.cpp)`, value: backendOptionsMap.llamaBox, - disabled: !isGGUF + disabled: + source === modelSourceMap.local_path_value ? false : !isGGUF }, { label: 'vLLM', value: backendOptionsMap.vllm, - disabled: isGGUF + disabled: + source === modelSourceMap.local_path_value ? false : isGGUF } ]} - disabled={action === PageAction.EDIT} + disabled={ + action === PageAction.EDIT && + source !== modelSourceMap.local_path_value + } > name="backend_parameters"> diff --git a/src/pages/llmodels/components/data-form.tsx b/src/pages/llmodels/components/data-form.tsx index 86034a25..c5962cc4 100644 --- a/src/pages/llmodels/components/data-form.tsx +++ b/src/pages/llmodels/components/data-form.tsx @@ -446,6 +446,7 @@ const DataForm: React.FC = forwardRef((props, ref) => { gpuOptions={gpuOptions} isGGUF={isGGUF} action={action} + source={props.source} > ); diff --git a/src/pages/llmodels/components/table-list.tsx b/src/pages/llmodels/components/table-list.tsx index bfeb774c..dacf34ef 100644 --- a/src/pages/llmodels/components/table-list.tsx +++ b/src/pages/llmodels/components/table-list.tsx @@ -461,7 +461,7 @@ const Models: React.FC = ({ return `${modelSourceMap.huggingface}/${record.huggingface_repo_id}`; } if (record.source === modelSourceMap.local_path_value) { - return `${modelSourceMap.local_path} ${record.local_path}`; + return `${modelSourceMap.local_path}${record.local_path}`; } if (record.source === modelSourceMap.ollama_library_value) { return `${modelSourceMap.ollama_library}/${record.ollama_library_model_name}`; diff --git a/src/pages/llmodels/components/update-modal.tsx b/src/pages/llmodels/components/update-modal.tsx index f71e2e2a..f23e77e0 100644 --- a/src/pages/llmodels/components/update-modal.tsx +++ b/src/pages/llmodels/components/update-modal.tsx @@ -424,6 +424,7 @@ const UpdateModal: React.FC = (props) => { form={form} gpuOptions={gpuOptions} action={PageAction.EDIT} + source={props.data?.source || ''} isGGUF={props.data?.backend === backendOptionsMap.llamaBox} >