From 3978ec683d63c61f5deb4f19a41f28c8a019af69 Mon Sep 17 00:00:00 2001 From: jialin Date: Sun, 29 Sep 2024 20:30:08 +0800 Subject: [PATCH] style: no available models tips --- src/locales/en-US/playground.ts | 2 +- .../playground/components/empty-models.tsx | 13 +--- .../playground/components/ground-left.tsx | 61 ++++++++++--------- .../playground/components/message-input.tsx | 2 +- .../components/multiple-chat/index.tsx | 54 +++++++++------- src/pages/playground/index.tsx | 19 ++---- 6 files changed, 75 insertions(+), 76 deletions(-) diff --git a/src/locales/en-US/playground.ts b/src/locales/en-US/playground.ts index c86fd793..f70d4c62 100644 --- a/src/locales/en-US/playground.ts +++ b/src/locales/en-US/playground.ts @@ -44,7 +44,7 @@ export default { 'playground.input.holder': 'Type / to input message', 'playground.compare.apply': 'Apply', 'playground.compare.applytoall': 'Apply to all models', - 'playground.model.noavailable': 'No available models.', + 'playground.model.noavailable': 'No available models', 'playground.model.noavailable.tips': 'Please deploy a model first, and it should not be an embedding-only model.' }; diff --git a/src/pages/playground/components/empty-models.tsx b/src/pages/playground/components/empty-models.tsx index 06bc33ee..a66fae4a 100644 --- a/src/pages/playground/components/empty-models.tsx +++ b/src/pages/playground/components/empty-models.tsx @@ -1,5 +1,5 @@ import { useIntl, useNavigate } from '@umijs/max'; -import { Button, Empty, Typography } from 'antd'; +import { Empty, Typography } from 'antd'; import React from 'react'; const EmptyModels: React.FC<{ @@ -13,7 +13,7 @@ const EmptyModels: React.FC<{ }; return (
{intl.formatMessage({ id: 'playground.model.noavailable' })} - - {intl.formatMessage({ id: 'playground.model.noavailable.tips' })} -
} - > - - + > ); }; diff --git a/src/pages/playground/components/ground-left.tsx b/src/pages/playground/components/ground-left.tsx index 335278b7..2487c2a8 100644 --- a/src/pages/playground/components/ground-left.tsx +++ b/src/pages/playground/components/ground-left.tsx @@ -27,6 +27,7 @@ import ViewCodeModal from './view-code-modal'; interface MessageProps { modelList: Global.BaseOption[]; + loaded?: boolean; ref?: any; } @@ -253,38 +254,40 @@ const GroundLeft: React.FC = forwardRef((props, ref) => {
-
- +
-
+ > + +
-
- - {loading && ( - -
-
- )} -
+
+ + {loading && ( + +
+
+ )} +
+
{tokenResult && (
diff --git a/src/pages/playground/components/message-input.tsx b/src/pages/playground/components/message-input.tsx index af911131..a42d5ca8 100644 --- a/src/pages/playground/components/message-input.tsx +++ b/src/pages/playground/components/message-input.tsx @@ -108,7 +108,7 @@ const MessageInput: React.FC = ({ return disabled ? true : !message.content && isEmpty && !message.imgs?.length; - }, [disabled, message.content, isEmpty]); + }, [disabled, message, isEmpty]); const resetMessage = () => { setMessage({ diff --git a/src/pages/playground/components/multiple-chat/index.tsx b/src/pages/playground/components/multiple-chat/index.tsx index eb955374..b7fbb733 100644 --- a/src/pages/playground/components/multiple-chat/index.tsx +++ b/src/pages/playground/components/multiple-chat/index.tsx @@ -5,6 +5,7 @@ import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react'; import CompareContext from '../../config/compare-context'; import { MessageItem, ModelSelectionItem } from '../../config/types'; import '../../style/multiple-chat.less'; +import EmptyModels from '../empty-models'; import MessageInput from '../message-input'; import ActiveModels from './active-models'; @@ -12,10 +13,10 @@ type CurrentMessage = Omit; interface MultiCompareProps { modelList: (Global.BaseOption & { type?: string })[]; - spans?: number; + loaded?: boolean; } -const MultiCompare: React.FC = ({ modelList }) => { +const MultiCompare: React.FC = ({ modelList, loaded }) => { const { initialize } = useOverlayScroller(); const [loadingStatus, setLoadingStatus] = useState>( {} @@ -262,30 +263,41 @@ const MultiCompare: React.FC = ({ modelList }) => { return (
- - - + {modelList.length > 0 ? ( + + + + ) : ( + loaded && ( + + ) + )}
{ { key: 'compare', label: 'Compare', - children: + children: } ]; @@ -80,7 +79,7 @@ const Playground: React.FC = () => { }, []); const renderExtra = () => { - if (activeKey === 'compare' || modelList.length === 0) { + if (activeKey === 'compare') { return false; } return ( @@ -123,14 +122,14 @@ const Playground: React.FC = () => { title: (
{intl.formatMessage({ id: 'menu.playground' })} - {modelList.length > 0 && ( + { setActiveKey(key)} > - )} + }
) }} @@ -142,15 +141,7 @@ const Playground: React.FC = () => { >
- {modelList.length > 0 ? ( - - ) : ( - loaded && ( - - ) - )} +