chore: list models query
This commit is contained in:
@@ -5,15 +5,13 @@ import SealSelect from '@/components/seal-form/seal-select';
|
||||
import { PageAction } from '@/config';
|
||||
import { PageActionType } from '@/config/types';
|
||||
import { convertFileSize } from '@/utils';
|
||||
import { SearchOutlined } from '@ant-design/icons';
|
||||
import { useIntl } from '@umijs/max';
|
||||
import { Form, Input, Modal } from 'antd';
|
||||
import { Form, Modal } from 'antd';
|
||||
import _ from 'lodash';
|
||||
import { memo, useCallback, useEffect, useState } from 'react';
|
||||
import { queryHuggingfaceModelFiles, queryHuggingfaceModels } from '../apis';
|
||||
import { modelSourceMap } from '../config';
|
||||
import { FormData, ListItem } from '../config/types';
|
||||
import SearchInput from './search-input';
|
||||
|
||||
type AddModalProps = {
|
||||
title: string;
|
||||
@@ -50,7 +48,6 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
||||
const [fileOptions, setFileOptions] = useState<
|
||||
{ label: string; value: string }[]
|
||||
>([]);
|
||||
const [ollamaTags, setOllamaTags] = useState<string[]>([]);
|
||||
|
||||
const initFormValue = () => {
|
||||
if (action === PageAction.CREATE && open) {
|
||||
@@ -154,24 +151,11 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
||||
}
|
||||
]}
|
||||
>
|
||||
<SealAutoComplete
|
||||
<SealInput.Input
|
||||
label={intl.formatMessage({ id: 'models.form.repoid' })}
|
||||
required
|
||||
showSearch
|
||||
onBlur={handleRepoOnBlur}
|
||||
onSelect={handleRepoOnBlur}
|
||||
onSearch={debounceSearch}
|
||||
options={repoOptions}
|
||||
addAfter={
|
||||
<span style={{ position: 'relative', top: '2px' }}>
|
||||
<SearchOutlined></SearchOutlined>
|
||||
</span>
|
||||
}
|
||||
disabled={true}
|
||||
description={intl.formatMessage({ id: 'models.form.repoid.desc' })}
|
||||
>
|
||||
<Input></Input>
|
||||
</SealAutoComplete>
|
||||
></SealInput.Input>
|
||||
</Form.Item>
|
||||
<Form.Item<FormData>
|
||||
name="huggingface_filename"
|
||||
@@ -246,14 +230,6 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
||||
}
|
||||
]}
|
||||
>
|
||||
{/* <SealAutoComplete
|
||||
filterOption
|
||||
disabled={action === PageAction.EDIT}
|
||||
label={intl.formatMessage({ id: 'model.form.ollama.model' })}
|
||||
placeholder={intl.formatMessage({ id: 'model.form.ollamaholder' })}
|
||||
required
|
||||
options={ollamaModelOptions}
|
||||
></SealAutoComplete> */}
|
||||
<SealInput.Input
|
||||
disabled={action === PageAction.EDIT}
|
||||
label={intl.formatMessage({ id: 'model.form.ollama.model' })}
|
||||
@@ -261,12 +237,6 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
||||
required
|
||||
></SealInput.Input>
|
||||
</Form.Item>
|
||||
<Form.Item name="tag">
|
||||
<SealInput.Input
|
||||
label="Tag"
|
||||
placeholder={`${_.join(ollamaTags, ',')} or another...`}
|
||||
></SealInput.Input>
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -286,7 +256,6 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
||||
|
||||
const handleOnSelectModel = useCallback((item: any) => {
|
||||
const repo = item.name;
|
||||
setOllamaTags(_.map(item.tags, (tag: string) => _.toLower(tag)));
|
||||
if (form.getFieldValue('source') === modelSourceMap.huggingface_value) {
|
||||
form.setFieldValue('huggingface_repo_id', repo);
|
||||
handleFetchModelFiles(repo);
|
||||
@@ -320,13 +289,6 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
||||
<ModalFooter onCancel={onCancel} onOk={handleSumit}></ModalFooter>
|
||||
}
|
||||
>
|
||||
{action === PageAction.CREATE && (
|
||||
<SearchInput
|
||||
modelSource={modelSource}
|
||||
onSourceChange={handleSourceChange}
|
||||
onSelectModel={handleOnSelectModel}
|
||||
></SearchInput>
|
||||
)}
|
||||
<Form name="addModalForm" form={form} onFinish={onOk} preserve={false}>
|
||||
<Form.Item<FormData>
|
||||
name="name"
|
||||
@@ -362,7 +324,6 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
||||
)
|
||||
}
|
||||
]}
|
||||
noStyle={action === PageAction.CREATE}
|
||||
>
|
||||
{action === PageAction.EDIT && (
|
||||
<SealSelect
|
||||
|
||||
Reference in New Issue
Block a user