fix: query modelscope files by recursive

This commit is contained in:
jialin
2024-09-27 16:50:09 +08:00
parent 7e985991cd
commit 49c0467428
26 changed files with 292 additions and 118 deletions
+1
View File
@@ -203,6 +203,7 @@ export async function queryModelScopeModelFiles(
const res = await fetch(
`${MODE_SCOPE_MODEL_FIELS_API}${params.name}/repo/files?${qs.stringify({
Revision: 'master',
Recursive: true,
Root: ''
})}`,
{
@@ -192,6 +192,32 @@ const AdvanceConfig: React.FC<AdvanceConfigProps> = (props) => {
</Form.Item>
</>
)}
{scheduleType === 'manual' && (
<Form.Item<FormData>
name="gpu_selector"
rules={[
{
required: true,
message: intl.formatMessage(
{
id: 'common.form.rule.select'
},
{
name: 'gpu_selector'
}
)
}
]}
>
<SealSelect label="GPU Selector" required>
{gpuOptions.map((item) => (
<Select.Option key={item.value} value={item.value}>
<GPUCard data={item}></GPUCard>
</Select.Option>
))}
</SealSelect>
</Form.Item>
)}
<Form.Item name="backend">
<SealSelect
label={intl.formatMessage({ id: 'models.form.backend' })}
@@ -219,32 +245,6 @@ const AdvanceConfig: React.FC<AdvanceConfigProps> = (props) => {
options={paramsConfig}
></ListInput>
</Form.Item>
{scheduleType === 'manual' && (
<Form.Item<FormData>
name="gpu_selector"
rules={[
{
required: true,
message: intl.formatMessage(
{
id: 'common.form.rule.select'
},
{
name: 'gpu_selector'
}
)
}
]}
>
<SealSelect label="GPU Selector" required>
{gpuOptions.map((item) => (
<Select.Option key={item.value} value={item.value}>
<GPUCard data={item}></GPUCard>
</Select.Option>
))}
</SealSelect>
</Form.Item>
)}
{isGGUF && (
<div style={{ paddingBottom: 22, paddingLeft: 10 }}>
<Form.Item<FormData>
@@ -35,6 +35,7 @@ const pattern = /^(.*)-(\d+)-of-(\d+)\.(.*)$/;
const filterReg = /\.(safetensors|gguf)$/i;
const includeReg = /\.(safetensors|gguf)$/i;
const filterRegGGUF = /\.(gguf)$/i;
const HFModelFile: React.FC<HFModelFileProps> = forwardRef((props, ref) => {
const { collapsed, modelSource } = props;
@@ -159,8 +160,11 @@ const HFModelFile: React.FC<HFModelFileProps> = forwardRef((props, ref) => {
}
);
const fileList = _.filter(_.get(data, ['Data', 'Files']), (file: any) => {
return filterReg.test(file.Path) || _.includes(includeReg, file.Path);
return (
filterRegGGUF.test(file.Path) || _.includes(filterRegGGUF, file.Path)
);
});
const list = _.map(fileList, (item: any) => {
return {
path: item.Path,
@@ -23,6 +23,7 @@ interface InstanceItemProps {
list: ModelInstanceListItem[];
gpuDeviceList: GPUDeviceItem[];
workerList: WorkerListItem[];
modelData?: any;
handleChildSelect: (
val: string,
item: ModelInstanceListItem,
@@ -33,6 +34,7 @@ interface InstanceItemProps {
const InstanceItem: React.FC<InstanceItemProps> = ({
list,
workerList,
modelData,
handleChildSelect
}) => {
const intl = useIntl();
@@ -98,6 +100,10 @@ const InstanceItem: React.FC<InstanceItemProps> = ({
{intl.formatMessage({ id: 'models.table.gpuindex' })}: [
{_.join(item.gpu_indexes?.sort?.(), ',')}]
</div>
<div>
{intl.formatMessage({ id: 'models.form.backend' })}:{' '}
{modelData?.backend || ''}
</div>
</div>
);
};
@@ -8,6 +8,7 @@ import {
} from '@ant-design/icons';
import { useIntl } from '@umijs/max';
import { Button, Empty, Spin, Tag, Tooltip } from 'antd';
import 'overlayscrollbars/overlayscrollbars.css';
import React, { useCallback, useEffect, useRef, useState } from 'react';
import SimpleBar from 'simplebar-react';
import 'simplebar-react/dist/simplebar.min.css';
+5 -4
View File
@@ -402,10 +402,11 @@ const Models: React.FC<ModelsProps> = ({
);
const renderChildren = useCallback(
(list: any) => {
(list: any, parent?: any) => {
return (
<InstanceItem
list={list}
modelData={parent}
gpuDeviceList={gpuDeviceList}
workerList={workerList}
handleChildSelect={handleChildSelect}
@@ -417,12 +418,12 @@ const Models: React.FC<ModelsProps> = ({
const generateSource = useCallback((record: ListItem) => {
if (record.source === modelSourceMap.modelscope_value) {
return `${modelSourceMap.modelScope} / ${record.model_scope_file_path || record.model_scope_model_id}`;
return `${modelSourceMap.modelScope}/${record.model_scope_file_path || record.model_scope_model_id}`;
}
if (record.source === modelSourceMap.huggingface_value) {
return `${modelSourceMap.huggingface} / ${record.huggingface_filename || record.huggingface_repo_id}`;
return `${modelSourceMap.huggingface}/${record.huggingface_filename || record.huggingface_repo_id}`;
}
return `${modelSourceMap.ollama_library} / ${record.ollama_library_model_name}`;
return `${modelSourceMap.ollama_library}/${record.ollama_library_model_name}`;
}, []);
const handleCloseViewCode = useCallback(() => {
+22 -15
View File
@@ -2,6 +2,20 @@ import { StatusMaps } from '@/config';
import { EditOutlined } from '@ant-design/icons';
export const ollamaModelOptions = [
{
label: 'llama3.2',
value: 'llama3.2',
name: 'llama3.2',
id: 'llama3.2',
tags: ['Tools', '1B', '3B']
},
{
label: 'qwen2.5',
value: 'qwen2.5',
name: 'qwen2.5',
tags: ['Tools', '0.5B', '1.5B', '3B', '7B', '14B', '32B', '72B'],
id: 'gemma2'
},
{
label: 'llama3.1',
value: 'llama3.1',
@@ -9,20 +23,20 @@ export const ollamaModelOptions = [
id: 'llama3.1',
tags: ['8B', '70B', '405B']
},
{
label: 'llama3',
value: 'llama3',
name: 'llama3',
tags: ['8B', '70B'],
id: 'llama3'
},
{
label: 'gemma2',
value: 'gemma2',
name: 'gemma2',
tags: ['9B', '27B'],
tags: ['2B', '9B', '27B'],
id: 'gemma2'
},
{
label: 'llava',
value: 'llava',
name: 'llava',
tags: ['7B', '13B', '34B'],
id: 'llava'
},
{
label: 'mistral-nemo',
value: 'mistral-nemo',
@@ -44,13 +58,6 @@ export const ollamaModelOptions = [
tags: ['7B'],
id: 'mistral'
},
{
label: 'llava',
value: 'llava',
name: 'llava',
tags: ['7B', '13B', '34B'],
id: 'llava'
},
{
label: 'qwen2',
value: 'qwen2',
+18 -2
View File
@@ -1,11 +1,12 @@
export default [
const options = [
{
label: '--chat-template',
value: '--chat-template'
},
{
label: '--ctx-size',
value: '--ctx-size'
value: '--ctx-size',
options: ['8192']
},
{
label: '--flash-attn',
@@ -24,3 +25,18 @@ export default [
value: '--ubatch-size'
}
];
const resultList = options.map((option) => {
return {
label: option.label,
value: option.value,
opts: option.options?.map((opt) => {
return {
label: opt,
value: opt
};
})
};
});
export default resultList;
+1 -1
View File
@@ -183,7 +183,7 @@ const options = [
{
label: '--max-model-len',
value: '--max-model-len',
options: []
options: ['8192']
},
{
label: '--guided-decoding-backend',
+1 -1
View File
@@ -5,7 +5,7 @@
}
.simplebar-scrollbar::before {
background: rgba(0, 0, 0, 50%);
width: var(--scrollbar-size);
}
.column-wrapper-footer {
@@ -8,10 +8,6 @@
// height: calc(100vh - 194px);
}
.simplebar-scrollbar::before {
background: rgba(0, 0, 0, 50%);
}
.search-bar {
left: 0;
right: 0;