fix: backend edit format
This commit is contained in:
@@ -144,20 +144,20 @@ export const frameworks = [
|
||||
];
|
||||
|
||||
export const yamlTemplate = `# backend configuration template
|
||||
backend_name: SGLang
|
||||
description: SGLang backend
|
||||
backend_name: my-backend
|
||||
description: this is my-backend
|
||||
default_version: v0.5.1
|
||||
health_check_path: /health
|
||||
default_backend_param:
|
||||
- --host
|
||||
default_run_command: run sglang
|
||||
default_run_command: myBackend serve {model} --port {port}
|
||||
version_configs:
|
||||
v0.0.1:
|
||||
image_name: lm/sglang
|
||||
run_command: run sglang
|
||||
image_name: lm/mybackend:latest
|
||||
run_command: myBackend serve {model} --port {port}
|
||||
custom_framework: cuda
|
||||
v0.0.2:
|
||||
image_name: lm/sglang
|
||||
image_name: lm/mybackend:test
|
||||
run_command:
|
||||
custom_framework:
|
||||
`;
|
||||
|
||||
@@ -48,7 +48,7 @@ const BackendList = () => {
|
||||
isInfiniteScroll: true,
|
||||
contentForDelete: 'backends.title',
|
||||
defaultQueryParams: {
|
||||
perPage: 100
|
||||
perPage: 24
|
||||
}
|
||||
});
|
||||
const { exportYAML } = useExportYAML();
|
||||
|
||||
@@ -4,6 +4,7 @@ import { PipelineType } from '@huggingface/tasks';
|
||||
import { request } from '@umijs/max';
|
||||
import qs from 'query-string';
|
||||
import {
|
||||
AccessControlFormData,
|
||||
CatalogItem,
|
||||
CatalogSpec,
|
||||
EvaluateResult,
|
||||
@@ -426,7 +427,7 @@ export async function queryModelAccessUserList(id: number) {
|
||||
|
||||
export async function updateModelAccessUser(params: {
|
||||
id: number;
|
||||
data: { users: { id: number }[]; set_public: boolean };
|
||||
data: AccessControlFormData;
|
||||
}) {
|
||||
return request(`${MODELS_API}/${params.id}/access`, {
|
||||
method: 'POST',
|
||||
|
||||
@@ -25,7 +25,7 @@ const AccessControlForm = forwardRef((props: AccessControlFormProps, ref) => {
|
||||
const { currentData, onFinish } = props;
|
||||
const intl = useIntl();
|
||||
const [form] = Form.useForm();
|
||||
const setPublic = Form.useWatch('set_public', form);
|
||||
const accessPolicy = Form.useWatch('access_policy', form);
|
||||
const [targetKeys, setTargetKeys] = useState<TransferKey[]>([]);
|
||||
const [totalPages, setTotalPages] = useState(0);
|
||||
const [userList, setUserList] = useState<{ title: string; key: number }[]>(
|
||||
@@ -86,7 +86,7 @@ const AccessControlForm = forwardRef((props: AccessControlFormProps, ref) => {
|
||||
const keys = res.items.map((item) => item.id);
|
||||
setTargetKeys(keys);
|
||||
form.setFieldsValue({
|
||||
set_public: currentData.public,
|
||||
access_policy: currentData.access_policy,
|
||||
users: res.items.map((item) => ({ id: item.id }))
|
||||
});
|
||||
});
|
||||
@@ -105,28 +105,34 @@ const AccessControlForm = forwardRef((props: AccessControlFormProps, ref) => {
|
||||
clearOnDestroy={true}
|
||||
scrollToFirstError={true}
|
||||
initialValues={{
|
||||
set_public: true
|
||||
access_policy: 'authed'
|
||||
}}
|
||||
>
|
||||
<Label>{intl.formatMessage({ id: 'models.table.accessScope' })}</Label>
|
||||
<Form.Item<AccessControlFormData> name="set_public" noStyle>
|
||||
<Form.Item<AccessControlFormData> name="access_policy" noStyle>
|
||||
<Radio.Group
|
||||
style={{ marginBottom: 12 }}
|
||||
options={[
|
||||
{
|
||||
label: intl.formatMessage({ id: 'models.table.accessScope.all' }),
|
||||
value: true
|
||||
label: intl.formatMessage({ id: 'models.accessSettings.authed' }),
|
||||
value: 'authed'
|
||||
},
|
||||
{
|
||||
label: intl.formatMessage({
|
||||
id: 'models.table.accessScope.selected'
|
||||
id: 'models.accessSettings.allowedUsers'
|
||||
}),
|
||||
value: false
|
||||
value: 'allowed_users'
|
||||
},
|
||||
{
|
||||
label: intl.formatMessage({
|
||||
id: 'models.accessSettings.public'
|
||||
}),
|
||||
value: 'public'
|
||||
}
|
||||
]}
|
||||
></Radio.Group>
|
||||
</Form.Item>
|
||||
{!setPublic && (
|
||||
{accessPolicy === 'allowed_users' && (
|
||||
<>
|
||||
<Label>
|
||||
{intl.formatMessage({ id: 'models.table.userSelection' })}
|
||||
|
||||
@@ -20,8 +20,9 @@ const AccessControlModal: React.FC<
|
||||
const handleOnFinish = async (values: AccessControlFormData) => {
|
||||
try {
|
||||
const data = {
|
||||
set_public: values.set_public,
|
||||
users: values.set_public ? [] : values.users || []
|
||||
access_policy: values.access_policy,
|
||||
users:
|
||||
values.access_policy === 'allowed_users' ? values.users || [] : []
|
||||
};
|
||||
await updateModelAccessUser({
|
||||
id: currentData?.id as number,
|
||||
|
||||
@@ -24,7 +24,7 @@ export interface ListItem {
|
||||
local_path?: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
public?: boolean;
|
||||
access_policy: 'public' | 'authed' | 'allowed_users';
|
||||
gpu_selector?: {
|
||||
gpu_ids: string[];
|
||||
};
|
||||
@@ -261,6 +261,6 @@ export interface BackendOption {
|
||||
}
|
||||
|
||||
export interface AccessControlFormData {
|
||||
set_public: boolean;
|
||||
access_policy: 'public' | 'authed' | 'allowed_users';
|
||||
users: { id: number }[];
|
||||
}
|
||||
|
||||
@@ -28,7 +28,10 @@ const UserModels: React.FC = () => {
|
||||
fetchAPI: queryMyModels,
|
||||
API: MY_MODELS_API,
|
||||
watch: false,
|
||||
isInfiniteScroll: true
|
||||
isInfiniteScroll: true,
|
||||
defaultQueryParams: {
|
||||
perPage: 24
|
||||
}
|
||||
});
|
||||
const intl = useIntl();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user