-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: error while importing local model is not shown (#3294)
* fix: error while importing local model is not shown Signed-off-by: James <[email protected]> * fix: failed download should not be added to download state (#3297) Signed-off-by: James <[email protected]> --------- Signed-off-by: James <[email protected]>
- Loading branch information
Showing
12 changed files
with
120 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
export * from './modelEntity' | ||
export * from './modelInterface' | ||
export * from './modelImport' | ||
export * from './chatCompletion' |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { useMutation } from '@tanstack/react-query' | ||
|
||
import { useSetAtom } from 'jotai' | ||
|
||
import { toaster } from '@/containers/Toast' | ||
|
||
import useCortex from './useCortex' | ||
import { addDownloadModelStateAtom } from './useDownloadState' | ||
|
||
export type DownloadModelMutationVariables = { | ||
modelId: string | ||
fileName?: string | ||
persistedModelId?: string | ||
} | ||
|
||
const useModelDownloadMutation = () => { | ||
const { downloadModel } = useCortex() | ||
const addDownloadState = useSetAtom(addDownloadModelStateAtom) | ||
|
||
return useMutation({ | ||
mutationFn: downloadModel, | ||
|
||
onMutate: (variables) => { | ||
console.debug('Downloading model', variables) | ||
}, | ||
|
||
onSuccess: (data, variables) => { | ||
console.debug('Download response success', data, variables) | ||
|
||
const { persistedModelId, modelId } = variables | ||
if (persistedModelId) { | ||
addDownloadState(persistedModelId) | ||
} else { | ||
addDownloadState(modelId) | ||
} | ||
}, | ||
|
||
onError: (err, variables) => { | ||
console.error('Failed to download model', err, variables) | ||
toaster({ | ||
title: 'Failed to download model', | ||
description: err.message, | ||
type: 'error', | ||
}) | ||
}, | ||
}) | ||
} | ||
|
||
export default useModelDownloadMutation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.