Remove more files no longer needed in main

This commit is contained in:
Brandon Rising
2023-07-27 10:49:43 -04:00
parent 57271ad125
commit f7bb4c3f05
13 changed files with 67 additions and 74 deletions

View File

@ -19,7 +19,6 @@ import {
useGetMainModelsQuery,
useGetOnnxModelsQuery,
} from 'services/api/endpoints/models';
import { modelIdToOnnxModelField } from 'features/nodes/util/modelIdToOnnxModelField';
import { NON_REFINER_BASE_MODELS } from 'services/api/constants';
import { useFeatureStatus } from '../../../../system/hooks/useFeatureStatus';
@ -39,7 +38,9 @@ const ParamMainModelSelect = () => {
const { data: mainModels, isLoading } = useGetMainModelsQuery(
NON_REFINER_BASE_MODELS
);
const { data: onnxModels, isLoading: onnxLoading } = useGetOnnxModelsQuery();
const { data: onnxModels, isLoading: onnxLoading } = useGetOnnxModelsQuery(
NON_REFINER_BASE_MODELS
);
const activeTabName = useAppSelector(activeTabNameSelector);
@ -101,11 +102,7 @@ const ParamMainModelSelect = () => {
return;
}
let newModel = modelIdToMainModelParam(v);
if (v.includes('onnx')) {
newModel = modelIdToOnnxModelField(v);
}
const newModel = modelIdToMainModelParam(v);
if (!newModel) {
return;

View File

@ -229,10 +229,7 @@ export const generationSlice = createSlice({
const { image_name, width, height } = action.payload;
state.initialImage = { imageName: image_name, width, height };
},
modelChanged: (
state,
action: PayloadAction<MainModelParam | OnnxModelField | null>
) => {
modelChanged: (state, action: PayloadAction<MainModelParam | null>) => {
state.model = action.payload;
if (state.model === null) {

View File

@ -236,6 +236,11 @@ export const zMainModel = z.object({
* Type alias for model parameter, inferred from its zod schema
*/
export type MainModelParam = z.infer<typeof zMainModel>;
/**
* Type alias for model parameter, inferred from its zod schema
*/
export type OnnxModelParam = z.infer<typeof zMainModel>;
/**
* Validates/type-guards a value as a model parameter
*/

View File

@ -0,0 +1,31 @@
import { logger } from 'app/logging/logger';
import {
OnnxModelParam,
zMainModel,
} from 'features/parameters/types/parameterSchemas';
export const modelIdToOnnxModelParam = (
mainModelId: string
): OnnxModelParam | undefined => {
const log = logger('models');
const [base_model, model_type, model_name] = mainModelId.split('/');
const result = zMainModel.safeParse({
base_model,
model_name,
model_type,
});
if (!result.success) {
log.error(
{
mainModelId,
errors: result.error.format(),
},
'Failed to parse main model id'
);
return;
}
return result.data;
};