fix: models compare system message sync to all

This commit is contained in:
jialin
2024-09-30 11:45:42 +08:00
parent 3978ec683d
commit 5f77a0082c
18 changed files with 51 additions and 25 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"private": true, "private": true,
"author": "jialin <jialinkuang@126.com>", "author": "jialin",
"scripts": { "scripts": {
"build": "max build", "build": "max build",
"dev": "max dev", "dev": "max dev",
+2
View File
@@ -6,6 +6,7 @@ interface HintInputProps {
value: string; value: string;
label?: string; label?: string;
onChange: (value: string) => void; onChange: (value: string) => void;
placeholder?: string;
sourceOptions?: Global.HintOptions[]; sourceOptions?: Global.HintOptions[];
} }
@@ -82,6 +83,7 @@ const HintInput: React.FC<HintInputProps> = (props) => {
return ( return (
<AutoComplete <AutoComplete
placeholder={props.placeholder}
defaultActiveFirstOption={true} defaultActiveFirstOption={true}
value={value} value={value}
onInput={handleInput} onInput={handleInput}
+2
View File
@@ -12,6 +12,7 @@ interface ListInputProps {
description?: string; description?: string;
btnText?: string; btnText?: string;
options?: Global.HintOptions[]; options?: Global.HintOptions[];
placeholder?: string;
onChange: (data: string[]) => void; onChange: (data: string[]) => void;
} }
@@ -75,6 +76,7 @@ const ListInput: React.FC<ListInputProps> = (props) => {
{_.map(list, (item: any, index: number) => { {_.map(list, (item: any, index: number) => {
return ( return (
<ListItem <ListItem
placeholder={props.placeholder}
options={options} options={options}
key={item.uid} key={item.uid}
value={item.value} value={item.value}
+2
View File
@@ -10,6 +10,7 @@ interface LabelItemProps {
onChange: (value: string) => void; onChange: (value: string) => void;
value: string; value: string;
label?: string; label?: string;
placeholder?: string;
options?: Global.HintOptions[]; options?: Global.HintOptions[];
} }
@@ -27,6 +28,7 @@ const ListItem: React.FC<LabelItemProps> = (props) => {
onChange={handleOnChange} onChange={handleOnChange}
label={label} label={label}
sourceOptions={options} sourceOptions={options}
placeholder={props.placeholder}
/> />
<Button <Button
size="small" size="small"
+2 -2
View File
@@ -75,7 +75,7 @@ const SealAutoComplete: React.FC<
<Wrapper <Wrapper
status={status} status={status}
extra={extra} extra={extra}
label={label || (placeholder as string)} label={label}
isFocus={isFocus} isFocus={isFocus}
required={required} required={required}
description={description} description={description}
@@ -87,7 +87,7 @@ const SealAutoComplete: React.FC<
{...rest} {...rest}
ref={inputRef} ref={inputRef}
placeholder={ placeholder={
isFocus ? ( isFocus || !label ? (
<span style={{ paddingLeft: '12px' }}>{placeholder}</span> <span style={{ paddingLeft: '12px' }}>{placeholder}</span>
) : ( ) : (
'' ''
+1 -1
View File
@@ -62,7 +62,7 @@ const SealInputNumber: React.FC<InputNumberProps & SealFormItemProps> = (
return ( return (
<Wrapper <Wrapper
status={status} status={status}
label={label || (placeholder as string)} label={label}
isFocus={isFocus} isFocus={isFocus}
required={required} required={required}
description={description} description={description}
+1 -1
View File
@@ -68,7 +68,7 @@ const SealInputSearch: React.FC<SearchProps & SealFormItemProps> = (props) => {
return ( return (
<Wrapper <Wrapper
status={status} status={status}
label={label || (placeholder as string)} label={label}
isFocus={isFocus} isFocus={isFocus}
required={required} required={required}
description={description} description={description}
+1 -1
View File
@@ -57,7 +57,7 @@ const SealPassword: React.FC<InputProps & SealFormItemProps> = (props) => {
return ( return (
<Wrapper <Wrapper
status={status} status={status}
label={label || (placeholder as string)} label={label}
isFocus={isFocus} isFocus={isFocus}
required={required} required={required}
description={description} description={description}
+2 -2
View File
@@ -72,7 +72,7 @@ const SealInput: React.FC<InputProps & SealFormItemProps> = (props) => {
return ( return (
<Wrapper <Wrapper
status={checkStatus || status} status={checkStatus || status}
label={label || (placeholder as string)} label={label}
isFocus={isFocus} isFocus={isFocus}
required={required} required={required}
description={description} description={description}
@@ -83,7 +83,7 @@ const SealInput: React.FC<InputProps & SealFormItemProps> = (props) => {
> >
<Input <Input
{...rest} {...rest}
placeholder={isFocus ? placeholder : ''} placeholder={isFocus || !label ? placeholder : ''}
ref={inputRef} ref={inputRef}
autoComplete="off" autoComplete="off"
onInput={handleInput} onInput={handleInput}
+1 -1
View File
@@ -60,7 +60,7 @@ const SealSelect: React.FC<SelectProps & SealFormItemProps> = (props) => {
return ( return (
<Wrapper <Wrapper
status={status} status={status}
label={label || (placeholder as string)} label={label}
isFocus={isFocus} isFocus={isFocus}
required={required} required={required}
description={description} description={description}
+1 -1
View File
@@ -79,7 +79,7 @@ const SealTextArea: React.FC<TextAreaProps & SealFormItemProps> = (props) => {
return ( return (
<Wrapper <Wrapper
status={status} status={status}
label={label || (placeholder as string)} label={label}
isFocus={isFocus} isFocus={isFocus}
required={required} required={required}
description={description} description={description}
+5 -1
View File
@@ -60,5 +60,9 @@ export default {
'models.form.backend_parameters': 'Backend Parameters', 'models.form.backend_parameters': 'Backend Parameters',
'models.search.gguf.tips': '1. GGUF model backend is llama-box(llama.cpp).', 'models.search.gguf.tips': '1. GGUF model backend is llama-box(llama.cpp).',
'models.search.vllm.tips': '2. Non-GGUF model backend is vLLM.', 'models.search.vllm.tips': '2. Non-GGUF model backend is vLLM.',
'models.form.ollamalink': 'Find More in Ollama Library' 'models.form.ollamalink': 'Find More in Ollama Library',
'models.form.backend_parameters.llamabox.placeholder':
'e.g., --ctx-size=8192',
'models.form.backend_parameters.vllm.placeholder':
'e.g., --max-model-len=8192'
}; };
+5 -1
View File
@@ -59,5 +59,9 @@ export default {
'models.form.backend_parameters': '后端参数', 'models.form.backend_parameters': '后端参数',
'models.search.gguf.tips': '1. GGUF 模型后端为 llama-box(llama.cpp)', 'models.search.gguf.tips': '1. GGUF 模型后端为 llama-box(llama.cpp)',
'models.search.vllm.tips': '2. 非 GGUF 模型后端为 vLLM', 'models.search.vllm.tips': '2. 非 GGUF 模型后端为 vLLM',
'models.form.ollamalink': '在 Ollama Library 中查找' 'models.form.ollamalink': '在 Ollama Library 中查找',
'models.form.backend_parameters.llamabox.placeholder':
'例如,--ctx-size=8192',
'models.form.backend_parameters.vllm.placeholder':
'例如,--max-model-len=8192'
}; };
@@ -238,6 +238,15 @@ const AdvanceConfig: React.FC<AdvanceConfigProps> = (props) => {
</Form.Item> </Form.Item>
<Form.Item<FormData> name="backend_parameters"> <Form.Item<FormData> name="backend_parameters">
<ListInput <ListInput
placeholder={
backend === backendOptionsMap.llamaBox
? intl.formatMessage({
id: 'models.form.backend_parameters.llamabox.placeholder'
})
: intl.formatMessage({
id: 'models.form.backend_parameters.vllm.placeholder'
})
}
btnText="common.button.addParams" btnText="common.button.addParams"
label={intl.formatMessage({ id: 'models.form.backend_parameters' })} label={intl.formatMessage({ id: 'models.form.backend_parameters' })}
dataList={form.getFieldValue('backend_parameters') || []} dataList={form.getFieldValue('backend_parameters') || []}
+1 -1
View File
@@ -6,7 +6,7 @@ const options = [
{ {
label: '--ctx-size', label: '--ctx-size',
value: '--ctx-size', value: '--ctx-size',
options: ['8192'] options: []
}, },
{ {
label: '--flash-attn', label: '--flash-attn',
+1 -1
View File
@@ -183,7 +183,7 @@ const options = [
{ {
label: '--max-model-len', label: '--max-model-len',
value: '--max-model-len', value: '--max-model-len',
options: ['8192'] options: []
}, },
{ {
label: '--guided-decoding-backend', label: '--guided-decoding-backend',
@@ -2,7 +2,7 @@ import { CloseOutlined } from '@ant-design/icons';
import { useIntl } from '@umijs/max'; import { useIntl } from '@umijs/max';
import { Button, Checkbox, Divider, Input, Tooltip } from 'antd'; import { Button, Checkbox, Divider, Input, Tooltip } from 'antd';
import classNames from 'classnames'; import classNames from 'classnames';
import React, { useState } from 'react'; import React, { useEffect, useState } from 'react';
import '../../style/sys-message.less'; import '../../style/sys-message.less';
interface SystemMessageProps { interface SystemMessageProps {
@@ -17,7 +17,7 @@ const SystemMessage: React.FC<SystemMessageProps> = (props) => {
const { systemMessage, showApplyToAll, setSystemMessage, style, applyToAll } = const { systemMessage, showApplyToAll, setSystemMessage, style, applyToAll } =
props; props;
const intl = useIntl(); const intl = useIntl();
const [isChange, setIsChange] = useState(false); const [applyToAllModels, setApplyToAllModels] = useState(false);
const systemMessageRef = React.useRef<any>(null); const systemMessageRef = React.useRef<any>(null);
const [autoSize, setAutoSize] = useState<{ const [autoSize, setAutoSize] = useState<{
minRows: number; minRows: number;
@@ -44,12 +44,10 @@ const SystemMessage: React.FC<SystemMessageProps> = (props) => {
maxRows: 1, maxRows: 1,
focus: false focus: false
}); });
setIsChange(false);
}; };
const handleOnChange = (e: any) => { const handleOnChange = (e: any) => {
setSystemMessage(e.target.value); setSystemMessage(e.target.value);
setIsChange(true);
}; };
const handleClearSystemMessage = () => { const handleClearSystemMessage = () => {
@@ -58,13 +56,14 @@ const SystemMessage: React.FC<SystemMessageProps> = (props) => {
const handleClickCheckbox = (e?: any) => { const handleClickCheckbox = (e?: any) => {
e.preventDefault(); e.preventDefault();
setApplyToAllModels(!applyToAllModels);
}; };
const handleApplyToAllModels = (e: any) => { useEffect(() => {
if (e.target.checked) { if (applyToAllModels) {
applyToAll?.(systemMessage); applyToAll?.(systemMessage);
} }
}; }, [applyToAllModels]);
return ( return (
<div <div
@@ -100,13 +99,14 @@ const SystemMessage: React.FC<SystemMessageProps> = (props) => {
allowClear={false} allowClear={false}
onChange={handleOnChange} onChange={handleOnChange}
></Input.TextArea> ></Input.TextArea>
{isChange && showApplyToAll && ( {showApplyToAll && (
<span className="apply-check" onMouseDown={handleClickCheckbox}> <span className="apply-check" onMouseDown={handleClickCheckbox}>
<Checkbox onChange={handleApplyToAllModels}> <span className="m-r-5">
{intl.formatMessage({ {intl.formatMessage({
id: 'playground.compare.applytoall' id: 'playground.compare.applytoall'
})} })}
</Checkbox> </span>
<Checkbox checked={applyToAllModels}></Checkbox>
</span> </span>
)} )}
<Divider style={{ margin: '0' }}></Divider> <Divider style={{ margin: '0' }}></Divider>
+4 -1
View File
@@ -8,10 +8,13 @@
.apply-check { .apply-check {
position: absolute; position: absolute;
bottom: 10px; bottom: 10px;
display: flex;
right: 10px; right: 10px;
direction: rtl;
background-color: var(--color-white-1); background-color: var(--color-white-1);
box-shadow: var(--ant-box-shadow-tertiary); box-shadow: var(--ant-box-shadow-tertiary);
align-items: center;
padding: 1px 4px;
cursor: pointer;
} }
.sys-content-wrap { .sys-content-wrap {