Skip to content

Commit b18916d

Browse files
feat(ui): toast warning when installed model is unidentified
1 parent d6b72a3 commit b18916d

File tree

4 files changed

+50
-3
lines changed

4 files changed

+50
-3
lines changed

invokeai/frontend/web/public/locales/en.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -914,6 +914,9 @@
914914
"hfTokenReset": "HF Token Reset",
915915
"urlUnauthorizedErrorMessage": "You may need to configure an API token to access this model.",
916916
"urlUnauthorizedErrorMessage2": "Learn how here.",
917+
"unidentifiedModelTitle": "Unable to identify model",
918+
"unidentifiedModelMessage": "We were unable to identify the type, base and/or format of the installed model. Try editing the model and selecting the appropriate settings for the model.",
919+
"unidentifiedModelMessage2": "If you don't see the correct settings, or the model doesn't work after changing them, ask for help on <DiscordLink /> or create an issue on <GitHubIssuesLink />.",
917920
"imageEncoderModelId": "Image Encoder Model ID",
918921
"installedModelsCount": "{{installed}} of {{total}} models installed.",
919922
"includesNModels": "Includes {{n}} models and their dependencies.",
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export const githubLink = 'http://github.com/invoke-ai/InvokeAI';
2+
export const githubIssuesLink = 'https://github.com/invoke-ai/InvokeAI/issues';
23
export const discordLink = 'https://discord.gg/ZmtBAhwWhy';
34
export const websiteLink = 'https://www.invoke.com/';

invokeai/frontend/web/src/services/events/onModelInstallError.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { logger } from 'app/logging/logger';
44
import type { AppDispatch, AppGetState } from 'app/store/store';
55
import { getPrefixedId } from 'features/controlLayers/konva/util';
66
import { useFeatureStatus } from 'features/system/hooks/useFeatureStatus';
7+
import { discordLink, githubIssuesLink } from 'features/system/store/constants';
78
import { toast, toastApi } from 'features/toast/toast';
89
import { navigationApi } from 'features/ui/layouts/navigation-api';
910
import { t } from 'i18next';
@@ -191,3 +192,10 @@ const HFUnauthorizedToastDescription = () => {
191192
</Text>
192193
);
193194
};
195+
196+
export const DiscordLink = () => {
197+
return <ExternalLink fontWeight="semibold" href={discordLink} display="inline-flex" label="Discord" />;
198+
};
199+
export const GitHubIssuesLink = () => {
200+
return <ExternalLink fontWeight="semibold" href={githubIssuesLink} display="inline-flex" label="GitHub" />;
201+
};

invokeai/frontend/web/src/services/events/setEventListeners.tsx

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ExternalLink } from '@invoke-ai/ui-library';
1+
import { ExternalLink, Flex, Text } from '@invoke-ai/ui-library';
22
import { isAnyOf } from '@reduxjs/toolkit';
33
import { logger } from 'app/logging/logger';
44
import { socketConnected } from 'app/store/middleware/listenerMiddleware/listeners/socketConnected';
@@ -20,13 +20,14 @@ import ErrorToastDescription, { getTitle } from 'features/toast/ErrorToastDescri
2020
import { toast } from 'features/toast/toast';
2121
import { t } from 'i18next';
2222
import { LRUCache } from 'lru-cache';
23+
import { Trans } from 'react-i18next';
2324
import type { ApiTagDescription } from 'services/api';
2425
import { api, LIST_ALL_TAG, LIST_TAG } from 'services/api';
2526
import { modelsApi } from 'services/api/endpoints/models';
2627
import { queueApi } from 'services/api/endpoints/queue';
2728
import { workflowsApi } from 'services/api/endpoints/workflows';
2829
import { buildOnInvocationComplete } from 'services/events/onInvocationComplete';
29-
import { buildOnModelInstallError } from 'services/events/onModelInstallError';
30+
import { buildOnModelInstallError, DiscordLink, GitHubIssuesLink } from 'services/events/onModelInstallError';
3031
import type { ClientToServerEvents, ServerToClientEvents } from 'services/events/types';
3132
import type { Socket } from 'socket.io-client';
3233
import type { JsonObject } from 'type-fest';
@@ -292,7 +293,41 @@ export const setEventListeners = ({ socket, store, setIsConnected }: SetEventLis
292293
socket.on('model_install_complete', (data) => {
293294
log.debug({ data }, 'Model install complete');
294295

295-
const { id } = data;
296+
const { id, config } = data;
297+
298+
if (
299+
config.type === 'unknown' ||
300+
config.base === 'unknown' ||
301+
/**
302+
* Checking if type/base are 'unknown' technically narrows the config such that it's not possible for a config
303+
* that passes to the `config.[type|base] === 'unknown'` checks. In the future, if we have more model config
304+
* classes, this may change, so we will continue to check all three. Any one being 'unknown' is concerning
305+
* enough to warrant a toast.
306+
*/
307+
/* @ts-expect-error See note above */
308+
config.format === 'unknown'
309+
) {
310+
toast({
311+
id: 'UNKNOWN_MODEL',
312+
title: t('modelManager.unidentifiedModelTitle'),
313+
description: (
314+
<Flex flexDir="column" gap={2}>
315+
<Text fontSize="md" as="span">
316+
<Trans i18nKey="modelManager.unidentifiedModelMessage" />
317+
</Text>
318+
<Text fontSize="md" as="span">
319+
<Trans
320+
i18nKey="modelManager.unidentifiedModelMessage2"
321+
components={{ DiscordLink: <DiscordLink />, GitHubIssuesLink: <GitHubIssuesLink /> }}
322+
/>
323+
</Text>
324+
</Flex>
325+
),
326+
status: 'error',
327+
isClosable: true,
328+
duration: null,
329+
});
330+
}
296331

297332
const installs = selectModelInstalls(getState()).data;
298333

0 commit comments

Comments
 (0)