fix: add a button to last page on logs

This commit is contained in:
jialin
2025-01-08 15:26:03 +08:00
parent 2a9c501ee2
commit decb3ef2f1
21 changed files with 245 additions and 127 deletions
@@ -50,7 +50,7 @@ const ActiveTable = () => {
render: (text: any, record: any) => {
return (
<AutoTooltip ghost>
<span>{text}</span>
<span>{text || 'N/A'}</span>
</AutoTooltip>
);
}
+1 -1
View File
@@ -151,7 +151,7 @@ export async function queryModelScopeModels(
config?: any
) {
const tagsCriterion = params.tags?.map((tag: string) => {
return { category: 'tags', predicate: 'contains', values: [tag] };
return { category: 'libraries', predicate: 'contains', values: [tag] };
});
const tasksCriterion = params.tasks?.map((task: string) => {
return { category: 'tasks', predicate: 'contains', values: [task] };
@@ -303,7 +303,6 @@ const AdvanceConfig: React.FC<AdvanceConfigProps> = (props) => {
{ backend: backendParamsTips.backend || '' }
)}{' '}
<Typography.Link
style={{ color: 'var(--ant-blue-4)' }}
href={backendParamsTips.link}
target="_blank"
>
@@ -125,6 +125,10 @@ const HFModelFile: React.FC<HFModelFileProps> = forwardRef((props, ref) => {
return [...shardFileListResult, ...newGeneralFileList];
}, []);
const hfFileFilter = (file: any) => {
return filterRegGGUF.test(file.path) || _.includes(file.path, '.gguf');
};
// hugging face files
const getHuggingfaceFiles = async () => {
try {
@@ -139,7 +143,7 @@ const HFModelFile: React.FC<HFModelFileProps> = forwardRef((props, ref) => {
});
const list = _.filter(fileList, (file: any) => {
return filterRegGGUF.test(file.path) || _.includes(file.path, '.gguf');
return hfFileFilter(file);
});
return list;
@@ -148,6 +152,10 @@ const HFModelFile: React.FC<HFModelFileProps> = forwardRef((props, ref) => {
}
};
const modelscopeFileFilter = (file: any) => {
return filterRegGGUF.test(file.Path) && file.Type === 'blob';
};
// modelscope files
const getModelScopeFiles = async () => {
try {
@@ -161,7 +169,7 @@ const HFModelFile: React.FC<HFModelFileProps> = forwardRef((props, ref) => {
}
);
const fileList = _.filter(_.get(data, ['Data', 'Files']), (file: any) => {
return filterRegGGUF.test(file.Path) && file.Type === 'blob';
return modelscopeFileFilter(file);
});
const list = _.map(fileList, (item: any) => {
@@ -51,6 +51,8 @@ const ViewCodeModal: React.FC<ViewModalProps> = (props) => {
url: `${MODELS_API}/${props.modelId}/instances`,
handler: updateHandler
});
} else {
logsViewerRef.current?.abort();
}
return () => {
requestRef.current?.current?.cancel?.();
@@ -302,7 +302,7 @@ const AudioInput: React.FC<AudioInputProps> = (props) => {
href={`${externalRefer.audioPermission}`}
target="_blank"
style={{
color: 'var(--ant-blue-5)'
paddingInline: 0
}}
>
{intl.formatMessage({ id: 'playground.audio.enablemic.doc' })}
@@ -6,7 +6,7 @@ import { InfoCircleOutlined } from '@ant-design/icons';
import { useIntl } from '@umijs/max';
import { Form, InputNumber, Slider, Tooltip } from 'antd';
import _ from 'lodash';
import { memo, useCallback, useEffect, useId } from 'react';
import { memo, useCallback, useEffect, useId, useState } from 'react';
import CustomLabelStyles from '../style/custom-label.less';
type ParamsSettingsFormProps = {
@@ -29,12 +29,13 @@ type ParamsSettingsProps = {
globalParams?: ParamsSettingsFormProps;
};
const METAKEYS: Record<string, string> = {
const METAKEYS: Record<string, any> = {
seed: 'seed',
stop: 'stop',
temperature: 'temperature',
top_p: 'top_p',
max_tokens: 'n_ctx'
n_slot_ctx: 'max_tokens',
max_model_len: 'max_tokens'
};
const ParamsSettings: React.FC<ParamsSettingsProps> = ({
@@ -56,6 +57,8 @@ const ParamsSettings: React.FC<ParamsSettingsProps> = ({
};
const [form] = Form.useForm();
const formId = useId();
const [metaData, setMetaData] = useState<Record<string, any>>({});
const [firstLoad, setFirstLoad] = useState(true);
const handleOnFinish = (values: any) => {
console.log('handleOnFinish', values);
@@ -97,18 +100,16 @@ const ParamsSettings: React.FC<ParamsSettingsProps> = ({
const handleModelChange = (val: string) => {
const model = _.find(modelList, { value: val });
const modelMeta = model?.meta || {};
const keys = Object.keys(METAKEYS).map((k: string) => {
return METAKEYS[k];
});
const modelMetaKeys = _.pick(modelMeta, keys);
const obj = _.reduce(
METAKEYS,
(result: any, value: any, key: string) => {
result[key] = modelMetaKeys[value];
return result;
},
{}
);
const modelMetaValue = _.pick(modelMeta, _.keys(METAKEYS));
const obj = Object.entries(METAKEYS).reduce((acc: any, [key, value]) => {
const val = modelMetaValue[key];
if (val && _.hasIn(modelMetaValue, key)) {
acc[value] = val;
}
return acc;
}, {});
form.setFieldsValue(obj);
setMetaData(obj);
return obj;
};
@@ -127,11 +128,14 @@ const ParamsSettings: React.FC<ParamsSettingsProps> = ({
...mergeData,
model: model
});
setFirstLoad(false);
}, [modelList, showModelSelector, selectedModel]);
useEffect(() => {
form.setFieldsValue(globalParams);
}, [globalParams]);
if (!firstLoad) {
form.setFieldsValue(globalParams);
}
}, [globalParams, firstLoad]);
const renderLabel = (args: {
field: string;
@@ -196,7 +200,11 @@ const ParamsSettings: React.FC<ParamsSettingsProps> = ({
}
]}
>
<SealSelect showSearch={true} options={modelList}></SealSelect>
<SealSelect
showSearch={true}
options={modelList}
onChange={handleModelChange}
></SealSelect>
</Form.Item>
</>
)}
@@ -246,7 +254,7 @@ const ParamsSettings: React.FC<ParamsSettingsProps> = ({
>
<Slider
defaultValue={2048}
max={16 * 1024}
max={metaData.max_tokens || 16 * 1024}
step={1}
style={{ marginBottom: 0, marginTop: 16, marginInline: 0 }}
tooltip={{ open: false }}
@@ -80,7 +80,7 @@ const AddWorker: React.FC<ViewModalProps> = (props) => {
</ul>
<h3>1. {intl.formatMessage({ id: 'resources.worker.add.step1' })}</h3>
<HighlightCode
code={addWorkerGuide.mac.getToken}
code={addWorkerGuide.container.getToken}
theme="dark"
></HighlightCode>
<h3>
+4
View File
@@ -56,6 +56,10 @@ export const addWorkerGuide: Record<string, any> = {
registerWorker(params: { server: string; tag: string; token: string }) {
return `docker run -d --ipc=host --network=host gpustack/gpustack:${params.tag} --server-url ${params.server} --token ${params.token}`;
}
},
container: {
getToken:
'docker run -it ${gpustack_container_id} cat /var/lib/gpustack/token'
}
};