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