fix: gpu selector sort

This commit is contained in:
jialin
2025-05-06 13:19:06 +08:00
parent eccebae596
commit 56e8e84eaf
7 changed files with 9 additions and 291 deletions
@@ -163,7 +163,6 @@ const AdvanceConfig: React.FC<AdvanceConfigProps> = (props) => {
}, []);
const handleBackendParametersOnBlur = () => {
const backendParams = form.getFieldValue('backend_parameters');
onValuesChange?.({}, form.getFieldsValue());
};
+9 -4
View File
@@ -108,16 +108,21 @@ export const useGenerateFormEditInitialValues = () => {
if (gpu_ids.length === 0) {
return [];
}
const gpuids: string[][] = [];
const valueMap = new Map<string, string>();
gpuOptions?.forEach((item) => {
item.children?.forEach((child: any) => {
if (gpu_ids.includes(child.value)) {
gpuids.push([item.value, child.value]);
}
valueMap.set(child.value, item.value);
});
});
const gpuids: string[][] = gpu_ids
.map((id: string) => {
const parent = valueMap.get(id);
return parent ? [parent, id] : null;
})
.filter(Boolean) as string[][];
return data.backend === backendOptionsMap.voxBox ? gpuids[0] : gpuids;
};
@@ -1,127 +0,0 @@
import IconFont from '@/components/icon-font';
import HotKeys from '@/config/hotkeys';
import { platformCall } from '@/utils';
import { ClearOutlined, EnterOutlined, PlusOutlined } from '@ant-design/icons';
import { useIntl } from '@umijs/max';
import { Button, Col, Row, Space } from 'antd';
import { useHotkeys } from 'react-hotkeys-hook';
import { Roles } from '../config';
import '../style/chat-footer.less';
interface ChatFooterProps {
onSubmit: () => void;
onStop: () => void;
onClear: () => void;
onNewMessage: () => void;
onView: () => void;
disabled?: boolean;
feedback?: React.ReactNode;
hasTokenResult?: boolean;
selectedModel?: string;
}
const ChatFooter: React.FC<ChatFooterProps> = (props) => {
console.log('chat footer=====');
const platform = platformCall();
const intl = useIntl();
const {
onSubmit,
onClear,
onStop,
onNewMessage,
onView,
feedback,
disabled,
hasTokenResult,
selectedModel
} = props;
useHotkeys(
HotKeys.SUBMIT.join(','),
() => {
onSubmit();
},
{ enabled: !disabled }
);
const MessageRoles = [
{ key: Roles.User, label: intl.formatMessage({ id: 'playground.user' }) },
{
key: Roles.Assistant,
label: intl.formatMessage({ id: 'playground.assistant' })
}
];
return (
<div className="chat-footer">
<Row style={{ width: '100%' }}>
<Col lg={hasTokenResult ? 8 : 12} xs={24} sm={24} md={24}>
<Space size={20}>
<Button
disabled={disabled}
icon={<PlusOutlined />}
onClick={onNewMessage}
>
{intl.formatMessage({ id: 'playground.newMessage' })}
</Button>
<Button
icon={<ClearOutlined />}
onClick={onClear}
disabled={disabled}
>
{intl.formatMessage({ id: 'common.button.clear' })}
</Button>
</Space>
</Col>
<Col
lg={hasTokenResult ? 8 : 0}
xs={hasTokenResult ? 24 : 0}
sm={hasTokenResult ? 24 : 0}
md={hasTokenResult ? 24 : 0}
>
{feedback}
</Col>
<Col
lg={hasTokenResult ? 8 : 12}
xs={24}
sm={24}
md={24}
style={{ textAlign: 'right' }}
>
<Space size={20}>
{!disabled ? (
<Button
type="primary"
disabled={disabled || !selectedModel}
onClick={onSubmit}
>
{intl.formatMessage({ id: 'common.button.submit' })}
<span className="m-l-5 opct-7">
{platform.isMac ? (
<>
<IconFont type="icon-command"></IconFont> +{' '}
<EnterOutlined />
</>
) : (
<>
CTRL + <EnterOutlined />
</>
)}
</span>
</Button>
) : (
<Button
type="primary"
onClick={onStop}
icon={<IconFont type="icon-stop1"></IconFont>}
>
<span>{intl.formatMessage({ id: 'common.button.stop' })}</span>
</Button>
)}
</Space>
</Col>
</Row>
</div>
);
};
export default ChatFooter;
@@ -1,70 +0,0 @@
import avatar from '@/assets/images/avatar.png';
import logo from '@/assets/images/logo.png';
import {
CopyOutlined,
DislikeOutlined,
EditOutlined,
SyncOutlined
} from '@ant-design/icons';
import { Button, Space, Tooltip } from 'antd';
import chatStyle from '../style/chat-style.less';
import ChatEmpty from './chatEmpty';
export type ChatContentProps = {
messageList: any[];
};
const QuestionMessage: React.FC<{ content: string }> = ({ content }) => {
return (
<div className={chatStyle.chatMessageItem}>
<span className={chatStyle.img}>
<img src={avatar} alt="" />
</span>
<span className={chatStyle.name}>YOU</span>
<div className={chatStyle.contentWrap}>
<span className={chatStyle.edit}>
<Button type="text" size="middle" icon={<EditOutlined />}></Button>
</span>
<p className={chatStyle.content}>{content}</p>
</div>
</div>
);
};
const AnswerMessage: React.FC<{ content: string }> = ({ content }) => {
return (
<div className={chatStyle.chatMessageItem}>
<span className={chatStyle.img}>
<img src={logo} alt="" />
</span>
<span className={chatStyle.name}>AI</span>
<p className={chatStyle.content}>{content}</p>
<Space>
<Tooltip title="复制">
<Button type="text" size="middle" icon={<CopyOutlined />}></Button>
</Tooltip>
<Tooltip title="刷新">
<Button type="text" size="middle" icon={<SyncOutlined />}></Button>
</Tooltip>
<Tooltip title="回答错误">
<Button type="text" size="middle" icon={<DislikeOutlined />}></Button>
</Tooltip>
</Space>
</div>
);
};
const ChatContent: React.FC<ChatContentProps> = ({ messageList }) => {
if (messageList.length === 0) {
return <ChatEmpty />;
}
return (
<div className={chatStyle.chatContent}>
<QuestionMessage content="hello"></QuestionMessage>
<AnswerMessage content="hello, nice to meet you!"></AnswerMessage>
</div>
);
};
export default ChatContent;
@@ -1,15 +0,0 @@
import Logo from '@/assets/images/logo.png';
import chatStyle from '../style/chat-style.less';
const ChatEmpty: React.FC = () => {
return (
<div className={chatStyle.chatEmpty}>
<div className={chatStyle.logo}>
<img src={Logo} alt="chat empty" />
</div>
<h3 className={chatStyle.tips}>How can I help you today?</h3>
</div>
);
};
export default ChatEmpty;
@@ -1,6 +0,0 @@
.chat-footer {
// display: flex;
// align-items: center;
padding-block: 10px;
padding-right: 32px;
}
@@ -1,68 +0,0 @@
.chatEmpty {
display: flex;
justify-content: center;
align-items: center;
margin-top: 200px;
flex-direction: column;
.logo {
height: 60px;
width: 60px;
margin-block: 20px;
img {
width: 100%;
height: 100%;
}
}
.tips {
margin-top: 20px;
}
}
.chatContent {
width: max(50%, 500px);
}
.chatMessageItem {
margin-bottom: 12px;
position: relative;
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: flex-start;
padding-inline: 44px 16px;
.name {
padding-block: 8px 16px;
}
.content {
padding: 8px 12px;
border-radius: var(--border-radius-base);
background-color: var(--color-fill-3);
font-size: var(--font-size-base);
}
.contentWrap {
position: relative;
padding-right: 45px;
&:hover .edit {
display: block;
}
.edit {
display: none;
position: absolute;
top: -10px;
right: 0;
padding: 8px;
}
}
.img {
position: absolute;
top: 0;
left: 0;
width: 32px;
height: 32px;
border-radius: 50%;
img {
width: 100%;
height: 100%;
border-radius: 50%;
}
}
}