mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-02-16 15:25:00 -05:00
* first string only to test * more strings changed * almost half strings added in json file * more strings added * more changes * few strings and t function changed * resolved * errors resolved * chore(ui): fmt en.json --------- Co-authored-by: psychedelicious <4822129+psychedelicious@users.noreply.github.com>
84 lines
2.3 KiB
TypeScript
84 lines
2.3 KiB
TypeScript
import { Flex, Text } from '@chakra-ui/react';
|
|
|
|
import { useState } from 'react';
|
|
import {
|
|
MainModelConfigEntity,
|
|
DiffusersModelConfigEntity,
|
|
LoRAModelConfigEntity,
|
|
useGetMainModelsQuery,
|
|
useGetLoRAModelsQuery,
|
|
} from 'services/api/endpoints/models';
|
|
import CheckpointModelEdit from './ModelManagerPanel/CheckpointModelEdit';
|
|
import DiffusersModelEdit from './ModelManagerPanel/DiffusersModelEdit';
|
|
import LoRAModelEdit from './ModelManagerPanel/LoRAModelEdit';
|
|
import ModelList from './ModelManagerPanel/ModelList';
|
|
import { ALL_BASE_MODELS } from 'services/api/constants';
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
export default function ModelManagerPanel() {
|
|
const [selectedModelId, setSelectedModelId] = useState<string>();
|
|
const { mainModel } = useGetMainModelsQuery(ALL_BASE_MODELS, {
|
|
selectFromResult: ({ data }) => ({
|
|
mainModel: selectedModelId ? data?.entities[selectedModelId] : undefined,
|
|
}),
|
|
});
|
|
const { loraModel } = useGetLoRAModelsQuery(undefined, {
|
|
selectFromResult: ({ data }) => ({
|
|
loraModel: selectedModelId ? data?.entities[selectedModelId] : undefined,
|
|
}),
|
|
});
|
|
|
|
const model = mainModel ? mainModel : loraModel;
|
|
|
|
return (
|
|
<Flex sx={{ gap: 8, w: 'full', h: 'full' }}>
|
|
<ModelList
|
|
selectedModelId={selectedModelId}
|
|
setSelectedModelId={setSelectedModelId}
|
|
/>
|
|
<ModelEdit model={model} />
|
|
</Flex>
|
|
);
|
|
}
|
|
|
|
type ModelEditProps = {
|
|
model: MainModelConfigEntity | LoRAModelConfigEntity | undefined;
|
|
};
|
|
|
|
const ModelEdit = (props: ModelEditProps) => {
|
|
const { t } = useTranslation();
|
|
const { model } = props;
|
|
|
|
if (model?.model_format === 'checkpoint') {
|
|
return <CheckpointModelEdit key={model.id} model={model} />;
|
|
}
|
|
|
|
if (model?.model_format === 'diffusers') {
|
|
return (
|
|
<DiffusersModelEdit
|
|
key={model.id}
|
|
model={model as DiffusersModelConfigEntity}
|
|
/>
|
|
);
|
|
}
|
|
|
|
if (model?.model_type === 'lora') {
|
|
return <LoRAModelEdit key={model.id} model={model} />;
|
|
}
|
|
|
|
return (
|
|
<Flex
|
|
sx={{
|
|
w: 'full',
|
|
h: 'full',
|
|
justifyContent: 'center',
|
|
alignItems: 'center',
|
|
maxH: 96,
|
|
userSelect: 'none',
|
|
}}
|
|
>
|
|
<Text variant="subtext">{t('modelManager.noModelSelected')}</Text>
|
|
</Flex>
|
|
);
|
|
};
|