diff --git a/src/app.tsx b/src/app.tsx index feb5c732..0fb222c3 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -13,6 +13,7 @@ import { writeState } from '@/utils/localstore/index'; import { RequestConfig, history } from '@umijs/max'; +import { message } from 'antd'; const loginPath = '/login'; @@ -51,13 +52,26 @@ export async function getInitialState(): Promise<{ const fetchUserInfo = async (): Promise => { try { const data = await queryCurrentUserState({ - skipErrorHandler: true + skipErrorHandler: false }); if (data.is_admin) { getUpdateCheck(); } return data; - } catch (error) { + } catch (error: any) { + const data = error?.response?.data; + if (data?.code === 401) { + message.error({ + content: ( +
+ {data?.message || 'Please login again.'} +
+
Please contact the administrator.
+
+ ), + duration: 5 + }); + } history.push(loginPath); } return {} as Global.UserInfo; diff --git a/src/components/seal-form/seal-textarea.tsx b/src/components/seal-form/seal-textarea.tsx index 7853572b..b9efa086 100644 --- a/src/components/seal-form/seal-textarea.tsx +++ b/src/components/seal-form/seal-textarea.tsx @@ -24,6 +24,7 @@ const LabelWrapper = styled.div.attrs({ interface InputTextareaProps extends TextAreaProps { scaleSize?: boolean; + alwaysFocus?: boolean; } const SealTextArea: React.FC = ( @@ -45,6 +46,7 @@ const SealTextArea: React.FC = ( addAfter, trim, scaleSize, + alwaysFocus, ...rest } = props; const [isFocus, setIsFocus] = useState(false); @@ -119,7 +121,7 @@ const SealTextArea: React.FC = ( {label}} - isFocus={isFocus} + isFocus={alwaysFocus || isFocus} required={required} description={description} className="seal-textarea-wrapper" @@ -134,7 +136,7 @@ const SealTextArea: React.FC = ( spellCheck={rest.spellCheck ?? false} autoSize={autoSize} ref={inputRef} - style={{ minHeight: '80px', ...style }} + style={{ ...style }} className="seal-textarea" onFocus={handleOnFocus} onBlur={handleOnBlur} diff --git a/src/components/seal-form/wrapper/input.ts b/src/components/seal-form/wrapper/input.ts index 63edd699..3ecc2b61 100644 --- a/src/components/seal-form/wrapper/input.ts +++ b/src/components/seal-form/wrapper/input.ts @@ -163,6 +163,12 @@ const InputWrapper = styled.div` .seal-textarea-wrapper { height: auto; padding-right: 10px; + .ant-input-outlined { + height: auto !important; + } + textarea { + overflow-y: auto !important; + } } .ant-input-textarea-allow-clear.ant-input-affix-wrapper { padding: 0; diff --git a/src/pages/backends/forms/versions-config.tsx b/src/pages/backends/forms/versions-config.tsx index 5c26b048..13fdf0a5 100644 --- a/src/pages/backends/forms/versions-config.tsx +++ b/src/pages/backends/forms/versions-config.tsx @@ -317,6 +317,7 @@ const VersionsForm: React.FC = ({ style={{ marginBottom: 0 }} > diff --git a/src/pages/cluster-management/components/cluster-form.tsx b/src/pages/cluster-management/components/cluster-form.tsx index 38e47f1c..3e0499b3 100644 --- a/src/pages/cluster-management/components/cluster-form.tsx +++ b/src/pages/cluster-management/components/cluster-form.tsx @@ -1,4 +1,5 @@ import SealInput from '@/components/seal-form/seal-input'; +import SealTextArea from '@/components/seal-form/seal-textarea'; import { PageActionType } from '@/config/types'; import { useIntl } from '@umijs/max'; import { Form } from 'antd'; @@ -85,9 +86,10 @@ const ClusterForm: React.FC = forwardRef( > )} name="description" rules={[{ required: false }]}> - + > ); diff --git a/src/pages/llmodels/components/deploy-modal.tsx b/src/pages/llmodels/components/deploy-modal.tsx index b19f914b..b326843b 100644 --- a/src/pages/llmodels/components/deploy-modal.tsx +++ b/src/pages/llmodels/components/deploy-modal.tsx @@ -265,7 +265,7 @@ const AddModal: FC = (props) => { // evaluate the form data when select a model file // TODO: reset backend related fields when select a GGUF file if (item.fakeName) { - // onSelectFile(item, modelInfo, manual); + onSelectFile(item, modelInfo, manual); } }; diff --git a/src/pages/llmodels/forms/backend.tsx b/src/pages/llmodels/forms/backend.tsx index 4caef44e..d5720d95 100644 --- a/src/pages/llmodels/forms/backend.tsx +++ b/src/pages/llmodels/forms/backend.tsx @@ -2,6 +2,7 @@ import IconFont from '@/components/icon-font'; import AutoComplete from '@/components/seal-form/auto-complete'; import SealInput from '@/components/seal-form/seal-input'; import SealSelect from '@/components/seal-form/seal-select'; +import SealTextArea from '@/components/seal-form/seal-textarea'; import TooltipList from '@/components/tooltip-list'; import useAppUtils from '@/hooks/use-app-utils'; import { useIntl } from '@umijs/max'; @@ -127,7 +128,6 @@ const BackendFields: React.FC = () => { @@ -140,15 +140,17 @@ const BackendFields: React.FC = () => { } ]} > - + > )} diff --git a/src/pages/llmodels/forms/index.tsx b/src/pages/llmodels/forms/index.tsx index 08be618f..9d4baa1c 100644 --- a/src/pages/llmodels/forms/index.tsx +++ b/src/pages/llmodels/forms/index.tsx @@ -1,6 +1,5 @@ import { PageActionType } from '@/config/types'; import CollapsePanel from '@/pages/_components/collapse-panel'; -import { useWrapperContext } from '@/pages/_components/column-wrapper/use-wrapper-context'; import { useIntl } from '@umijs/max'; import { Form } from 'antd'; import _ from 'lodash'; @@ -54,7 +53,6 @@ const DataForm: React.FC = forwardRef((props, ref) => { onValuesChange, onOk } = props; - const { scrollToTarget, scrollToBottom } = useWrapperContext(); const { backendOptions, getBackendOptions } = useQueryBackends(); const { getGPUOptionList, gpuOptions } = useGenerateGPUOptions(); const [form] = Form.useForm(); diff --git a/src/pages/llmodels/hooks/use-form-initial-values.ts b/src/pages/llmodels/hooks/use-form-initial-values.ts index 8c530a79..00f8a2fd 100644 --- a/src/pages/llmodels/hooks/use-form-initial-values.ts +++ b/src/pages/llmodels/hooks/use-form-initial-values.ts @@ -80,6 +80,8 @@ export const useGenerateGPUOptions = () => { return gpuSelectorList; }; + const generateWorkerSelectorOptions = (workerList: WorkerListItem[]) => {}; + const getGPUOptionList = async (params?: { clusterId: number; }): Promise => { diff --git a/src/pages/playground/hooks/use-chat-completion.ts b/src/pages/playground/hooks/use-chat-completion.ts index fba3ee50..cb479149 100644 --- a/src/pages/playground/hooks/use-chat-completion.ts +++ b/src/pages/playground/hooks/use-chat-completion.ts @@ -52,11 +52,18 @@ export default function useChatCompletion( return; } - reasonContentRef.current = - reasonContentRef.current + - _.get(chunk, 'choices.0.delta.reasoning_content', ''); - contentRef.current = - contentRef.current + _.get(chunk, 'choices.0.delta.content', ''); + const deltaReasoningContent = + _.get(chunk, 'choices.0.delta.reasoning_content', '') === null + ? '' + : _.get(chunk, 'choices.0.delta.reasoning_content', ''); + + const deltaContent = + _.get(chunk, 'choices.0.delta.content', '') === null + ? '' + : _.get(chunk, 'choices.0.delta.content', ''); + + reasonContentRef.current = reasonContentRef.current + deltaReasoningContent; + contentRef.current = contentRef.current + deltaContent; const content = formatContent({ content: contentRef.current,