mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fixed error handling
This commit is contained in:
committed by
psychedelicious
parent
6369ccd05e
commit
5ad048a161
@ -261,11 +261,16 @@ async def get_hugging_face_models(
|
|||||||
hugging_face_repo: str = Query(description="Hugging face repo to search for models", default=None),
|
hugging_face_repo: str = Query(description="Hugging face repo to search for models", default=None),
|
||||||
) -> List[AnyHttpUrl]:
|
) -> List[AnyHttpUrl]:
|
||||||
get_hugging_face_models = ApiDependencies.invoker.services.model_manager.install.get_hugging_face_models
|
get_hugging_face_models = ApiDependencies.invoker.services.model_manager.install.get_hugging_face_models
|
||||||
get_hugging_face_models(hugging_face_repo)
|
|
||||||
|
|
||||||
result = get_hugging_face_models(
|
try:
|
||||||
source=hugging_face_repo,
|
result = get_hugging_face_models(
|
||||||
)
|
source=hugging_face_repo,
|
||||||
|
)
|
||||||
|
except ValueError as e:
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=400,
|
||||||
|
detail=f"{e}",
|
||||||
|
)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -239,7 +239,11 @@ class ModelInstallService(ModelInstallServiceBase):
|
|||||||
if not access_token:
|
if not access_token:
|
||||||
self._logger.info("No HuggingFace access token present; some models may not be downloadable.")
|
self._logger.info("No HuggingFace access token present; some models may not be downloadable.")
|
||||||
|
|
||||||
metadata = HuggingFaceMetadataFetch(self._session).from_id(source)
|
try:
|
||||||
|
metadata = HuggingFaceMetadataFetch(self._session).from_id(source)
|
||||||
|
except:
|
||||||
|
raise ValueError("No HuggingFace repository found")
|
||||||
|
|
||||||
assert isinstance(metadata, ModelMetadataWithFiles)
|
assert isinstance(metadata, ModelMetadataWithFiles)
|
||||||
urls: List[AnyHttpUrl] = []
|
urls: List[AnyHttpUrl] = []
|
||||||
|
|
||||||
|
@ -858,7 +858,7 @@
|
|||||||
"settings": "Settings",
|
"settings": "Settings",
|
||||||
"showExisting": "Show Existing",
|
"showExisting": "Show Existing",
|
||||||
"sigmoid": "Sigmoid",
|
"sigmoid": "Sigmoid",
|
||||||
"simpleModelPlaceholder": "URL or path to a local file",
|
"simpleModelPlaceholder": "URL or path to a local file or diffusers folder",
|
||||||
"simpleModelDesc": "Provide a path to a local Diffusers model, local checkpoint / safetensors model a HuggingFace Repo ID, or a checkpoint/diffusers model URL.",
|
"simpleModelDesc": "Provide a path to a local Diffusers model, local checkpoint / safetensors model a HuggingFace Repo ID, or a checkpoint/diffusers model URL.",
|
||||||
"source": "Source",
|
"source": "Source",
|
||||||
"statusConverting": "Converting",
|
"statusConverting": "Converting",
|
||||||
|
@ -51,21 +51,20 @@ export const HuggingFaceForm = () => {
|
|||||||
|
|
||||||
const getModels = useCallback(async () => {
|
const getModels = useCallback(async () => {
|
||||||
_getHuggingFaceModels(huggingFaceRepo)
|
_getHuggingFaceModels(huggingFaceRepo)
|
||||||
|
.unwrap()
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
if (response.data?.some((result) => result.endsWith('model_index.json'))) {
|
if (response.some((result: string) => result.endsWith('model_index.json'))) {
|
||||||
handleInstallModel(huggingFaceRepo);
|
handleInstallModel(huggingFaceRepo);
|
||||||
setDisplayResults(false);
|
setDisplayResults(false);
|
||||||
} else if (response.data?.length === 1 && response.data[0]) {
|
} else if (response.length === 1 && response[0]) {
|
||||||
handleInstallModel(response.data[0]);
|
handleInstallModel(response[0]);
|
||||||
setDisplayResults(false);
|
setDisplayResults(false);
|
||||||
} else {
|
} else {
|
||||||
setDisplayResults(true);
|
setDisplayResults(true);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
if (error) {
|
setErrorMessage(error.data.detail || '');
|
||||||
setErrorMessage(error.data.detail);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}, [_getHuggingFaceModels, handleInstallModel, huggingFaceRepo]);
|
}, [_getHuggingFaceModels, handleInstallModel, huggingFaceRepo]);
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import { addToast } from 'features/system/store/systemSlice';
|
|||||||
import { makeToast } from 'features/system/util/makeToast';
|
import { makeToast } from 'features/system/util/makeToast';
|
||||||
import { useCallback } from 'react';
|
import { useCallback } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { IoAdd } from 'react-icons/io5';
|
import { PiPlusBold } from 'react-icons/pi';
|
||||||
import { useInstallModelMutation } from 'services/api/endpoints/models';
|
import { useInstallModelMutation } from 'services/api/endpoints/models';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
@ -51,7 +51,7 @@ export const HuggingFaceResultItem = ({ result }: Props) => {
|
|||||||
</Flex>
|
</Flex>
|
||||||
<Box>
|
<Box>
|
||||||
<Tooltip label={t('modelManager.quickAdd')}>
|
<Tooltip label={t('modelManager.quickAdd')}>
|
||||||
<IconButton aria-label={t('modelManager.quickAdd')} icon={<IoAdd />} onClick={handleQuickAdd} />
|
<IconButton aria-label={t('modelManager.quickAdd')} icon={<PiPlusBold />} onClick={handleQuickAdd} />
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</Box>
|
</Box>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
@ -17,11 +17,13 @@ export const ScanModelsForm = () => {
|
|||||||
const [_scanFolder, { isLoading, data }] = useLazyScanFolderQuery();
|
const [_scanFolder, { isLoading, data }] = useLazyScanFolderQuery();
|
||||||
|
|
||||||
const scanFolder = useCallback(async () => {
|
const scanFolder = useCallback(async () => {
|
||||||
_scanFolder({ scan_path: scanPath }).catch((error) => {
|
_scanFolder({ scan_path: scanPath })
|
||||||
if (error) {
|
.unwrap()
|
||||||
setErrorMessage(error.data.detail);
|
.catch((error) => {
|
||||||
}
|
if (error) {
|
||||||
});
|
setErrorMessage(error.data.detail);
|
||||||
|
}
|
||||||
|
});
|
||||||
}, [_scanFolder, scanPath]);
|
}, [_scanFolder, scanPath]);
|
||||||
|
|
||||||
const handleSetScanPath: ChangeEventHandler<HTMLInputElement> = useCallback(
|
const handleSetScanPath: ChangeEventHandler<HTMLInputElement> = useCallback(
|
||||||
|
@ -4,7 +4,7 @@ import { addToast } from 'features/system/store/systemSlice';
|
|||||||
import { makeToast } from 'features/system/util/makeToast';
|
import { makeToast } from 'features/system/util/makeToast';
|
||||||
import { useCallback } from 'react';
|
import { useCallback } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { IoAdd } from 'react-icons/io5';
|
import { PiPlusBold } from 'react-icons/pi';
|
||||||
import type { ScanFolderResponse } from 'services/api/endpoints/models';
|
import type { ScanFolderResponse } from 'services/api/endpoints/models';
|
||||||
import { useInstallModelMutation } from 'services/api/endpoints/models';
|
import { useInstallModelMutation } from 'services/api/endpoints/models';
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ export const ScanModelResultItem = ({ result }: Props) => {
|
|||||||
<Badge>{t('common.installed')}</Badge>
|
<Badge>{t('common.installed')}</Badge>
|
||||||
) : (
|
) : (
|
||||||
<Tooltip label={t('modelManager.quickAdd')}>
|
<Tooltip label={t('modelManager.quickAdd')}>
|
||||||
<IconButton aria-label={t('modelManager.quickAdd')} icon={<IoAdd />} onClick={handleQuickAdd} />
|
<IconButton aria-label={t('modelManager.quickAdd')} icon={<PiPlusBold />} onClick={handleQuickAdd} />
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
|
Reference in New Issue
Block a user