fix(ui): get vae model select working

This commit is contained in:
psychedelicious
2024-02-20 11:14:08 +11:00
parent f870f810d5
commit e7e3045a8a
4 changed files with 17 additions and 20 deletions

View File

@@ -6,7 +6,6 @@ import type { ModelIdentifierWithBase } from 'features/nodes/types/common';
import { groupBy, map, reduce } from 'lodash-es';
import { useCallback, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { getModelId } from 'services/api/endpoints/models';
import type { AnyModelConfig } from 'services/api/types';
type UseGroupedModelComboboxArg<T extends AnyModelConfig> = {
@@ -58,8 +57,7 @@ export const useGroupedModelCombobox = <T extends AnyModelConfig>(
const value = useMemo(
() =>
options.flatMap((o) => o.options).find((m) => (selectedModel ? m.value === getModelId(selectedModel) : false)) ??
null,
options.flatMap((o) => o.options).find((m) => (selectedModel ? m.value === selectedModel.key : false)) ?? null,
[options, selectedModel]
);

View File

@@ -1,14 +1,14 @@
import type { ComboboxOnChange, ComboboxOption } from '@invoke-ai/ui-library';
import type { EntityState } from '@reduxjs/toolkit';
import type { ModelIdentifierWithBase } from 'features/nodes/types/common';
import { map } from 'lodash-es';
import { useCallback, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import type { AnyModelConfig } from 'services/api/endpoints/models';
import { getModelId } from 'services/api/endpoints/models';
import type { AnyModelConfig } from 'services/api/types';
type UseModelComboboxArg<T extends AnyModelConfig> = {
modelEntities: EntityState<T, string> | undefined;
selectedModel?: Pick<T, 'base_model' | 'model_name' | 'model_type'> | null;
selectedModel?: ModelIdentifierWithBase | null;
onChange: (value: T | null) => void;
getIsDisabled?: (model: T) => boolean;
optionsFilter?: (model: T) => boolean;
@@ -33,14 +33,14 @@ export const useModelCombobox = <T extends AnyModelConfig>(arg: UseModelCombobox
return map(modelEntities.entities)
.filter(optionsFilter)
.map((model) => ({
label: model.model_name,
value: model.id,
label: model.name,
value: model.key,
isDisabled: getIsDisabled ? getIsDisabled(model) : false,
}));
}, [optionsFilter, getIsDisabled, modelEntities]);
const value = useMemo(
() => options.find((m) => (selectedModel ? m.value === getModelId(selectedModel) : false)),
() => options.find((m) => (selectedModel ? m.value === selectedModel.key : false)),
[options, selectedModel]
);