fix: categories value error

This commit is contained in:
jialin
2025-04-02 17:55:10 +08:00
parent 89a6d6a4c1
commit d3e58c85cf
9 changed files with 46 additions and 44 deletions
+2 -4
View File
@@ -13,10 +13,8 @@ export default {
'models.form.env': 'Environment Variables',
'models.form.configurations': 'Configurations',
'models.form.s3address': 'S3 Address',
'models.form.partialoffload.tips':
'After enabling CPU offloading, GPUStack prioritizes loading as many layers as possible onto the GPU to maximize performance. If GPU resources are limited, some layers will be offloaded to the CPU, with full CPU inference used only when no GPU is available.',
'models.form.distribution.tips':
'Allows for offloading part of the computation to single or multiple remote workers when the resources of a single GPU or worker are insufficient.',
'models.form.partialoffload.tips': `When CPU offloading is enabled, if GPU resources are insufficient, part of the model's layers will be offloaded to the CPU. If no GPU is available, full CPU inference will be used.`,
'models.form.distribution.tips': `Allows for offloading part of the model's layers to single or multiple remote workers when the resources of a worker are insufficient.`,
'models.openinplayground': 'Open in Playground',
'models.instances': 'instances',
'models.table.replicas.edit': 'Edit Replicas',
+2 -2
View File
@@ -14,9 +14,9 @@ export default {
'models.form.configurations': '配置',
'models.form.s3address': 'S3 地址',
'models.form.partialoffload.tips':
'启用 CPU 卸载后,GPUStack 优先将尽可能多的层加载到 GPU 上,以最大化性能。如果 GPU 资源有限,则某些层将被卸载到 CPU 上,只有在没有 GPU 可用时,才会完全使用 CPU 进行推理。',
'启用 CPU 卸载的说明:启用 CPU 卸载时,如果 GPU 资源不足,则模型的一部分层将被卸载到 CPU 上,在没有 GPU 可用时,使用 CPU 推理。',
'models.form.distribution.tips':
'允许在单个 GPU 或 worker 资源不足时,将部分计算卸载到一个或多个远程 woker。',
'允许在单个 worker 资源不足时,将部分计算卸载到一个或多个远程 worker。',
'models.openinplayground': '在 Playground 中打开',
'models.instances': '实例',
'models.table.replicas.edit': '调整副本数',
+13 -9
View File
@@ -13,6 +13,7 @@ import {
ModelscopeTaskMap,
backendOptionsMap,
backendTipsList,
excludeFields,
modelSourceMap,
modelTaskMap,
sourceOptions
@@ -23,7 +24,7 @@ import { FormData, SourceType } from '../config/types';
import CatalogFrom from '../forms/catalog';
import HuggingFaceForm from '../forms/hugging-face';
import LocalPathForm from '../forms/local-path';
import OllamaForm from '../forms/ollama-library';
import OllamaForm from '../forms/ollama_library';
import AdvanceConfig from './advance-config';
interface DataFormProps {
@@ -190,19 +191,17 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
const handleOk = async (formdata: FormData) => {
let data = _.cloneDeep(formdata);
if (data.categories) {
data.categories = [data.categories];
} else {
data.categories = [];
}
data.categories = Array.isArray(data.categories)
? data.categories
: data.categories
? [data.categories]
: [];
const gpuSelector = generateGPUIds(data);
const allValues = {
..._.omit(data, ['scheduleType']),
...gpuSelector
};
console.log('allValues--------', allValues);
onOk(allValues);
};
@@ -211,7 +210,10 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
};
const handleOnValuesChange = async (changedValues: any, allValues: any) => {
console.log('changeValues--------', changedValues);
const fieldName = Object.keys(changedValues)[0];
if (excludeFields.includes(fieldName)) {
return;
}
onValuesChange?.(changedValues, allValues);
};
@@ -251,6 +253,7 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
style={{ padding: '16px 24px' }}
clearOnDestroy={true}
onValuesChange={handleOnValuesChange}
scrollToFirstError={true}
initialValues={{
replicas: 1,
source: props.source,
@@ -258,6 +261,7 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
cpu_offloading: true,
scheduleType: 'auto',
categories: null,
restart_on_error: true,
distributed_inference_across_workers: true,
...initialValues
}}
@@ -419,7 +419,10 @@ const AddModal: React.FC<AddModalProps> = (props) => {
};
const handleOk = async (values: FormData) => {
const data = generateSubmitData(values);
const data = {
..._.omit(selectSpecRef.current, ['name']),
...values
};
onOk(data);
};
@@ -14,6 +14,7 @@ import React, { useEffect, useMemo, useRef } from 'react';
import {
backendOptionsMap,
backendTipsList,
excludeFields,
getSourceRepoConfigValue,
localPathTipsList,
modelSourceMap,
@@ -319,6 +320,10 @@ const UpdateModal: React.FC<AddModalProps> = (props) => {
};
const onValuesChange = (changedValues: any, allValues: any) => {
const fieldName = Object.keys(changedValues)[0];
if (excludeFields.includes(fieldName)) {
return;
}
handleOnValuesChange({
changedValues,
allValues,
@@ -423,6 +428,7 @@ const UpdateModal: React.FC<AddModalProps> = (props) => {
form={form}
onFinish={handleOk}
onValuesChange={onValuesChange}
scrollToFirstError={true}
preserve={false}
clearOnDestroy={true}
initialValues={{
+3 -1
View File
@@ -456,5 +456,7 @@ export const excludeFields = [
'source',
'quantization',
'size',
'restart_on_error'
'restart_on_error',
'worker_selector',
'backend_parameters'
];
+2 -2
View File
@@ -22,7 +22,7 @@ const LocalPathForm: React.FC = () => {
const { modelFileOptions, byBuiltIn } = formCtx;
const { getRuleMessage } = useAppUtils();
const intl = useIntl();
const localPathCache = useRef<string>(form.getFieldValue('local_path'));
const localPathCache = useRef<string>(form.getFieldValue('local_path') || '');
if (![modelSourceMap.local_path_value].includes(source) || byBuiltIn) {
return null;
@@ -30,7 +30,7 @@ const LocalPathForm: React.FC = () => {
const handleLocalPathBlur = (e: any) => {
const value = e.target.value;
if (value === localPathCache.current && value) {
if (value === localPathCache.current || !value) {
return;
}
const isEndwithGGUF = _.endsWith(value, '.gguf');
+14 -25
View File
@@ -8,7 +8,6 @@ import { useEffect, useRef, useState } from 'react';
import { evaluationsModelSpec, queryGPUList } from '../apis';
import {
backendOptionsMap,
excludeFields,
getSourceRepoConfigValue,
modelSourceMap,
setSourceRepoConfigValue
@@ -157,7 +156,10 @@ export const useGenerateModelFileOptions = () => {
labels: worker.labels,
parent: true,
children: list
.filter((item) => item.worker_id === worker.id)
.filter(
(item) =>
item.worker_id === worker.id && !!item.resolved_paths?.length
)
.map((item) => {
const resolved_paths =
Array.isArray(item.resolved_paths) && item.resolved_paths.length
@@ -384,34 +386,21 @@ export const useCheckCompatibility = () => {
source: string;
}) => {
const { changedValues, allValues, source } = params;
const keys = Object.keys(changedValues);
const isExcludeField = keys.some((key) => excludeFields.includes(key));
const hasValue = keys.every((key) => {
return !!changedValues[key];
const data = getSourceRepoConfigValue(source, allValues);
const gpuSelector = generateGPUIds(data.values);
const currentRequestId = updateRequestId();
const evalutionData = await handleEvaluate({
...data.values,
...gpuSelector
});
if (
!isExcludeField &&
hasValue &&
!_.has(changedValues, 'backend') &&
!_.has(changedValues, 'local_path')
) {
const data = getSourceRepoConfigValue(source, allValues);
const gpuSelector = generateGPUIds(data.values);
const currentRequestId = updateRequestId();
const evalutionData = await handleEvaluate({
...data.values,
...gpuSelector
});
if (currentRequestId === requestIdRef.current) {
handleShowCompatibleAlert?.(evalutionData);
}
if (currentRequestId === requestIdRef.current) {
handleShowCompatibleAlert?.(evalutionData);
}
};
const debounceHandleValuesChange = _.debounce(handleOnValuesChange, 300);
const debounceHandleValuesChange = _.debounce(handleOnValuesChange, 500);
const cancelEvaluate = () => {
checkTokenRef.current?.cancel();