* chore: add react developer tools to electron * feat: add small convert modal * feat: separate modals and add hugging face extension * feat: fully implement hugging face converter * fix: forgot to uncomment this... * fix: typo * feat: try hf-to-gguf script first and then use convert.py HF-to-GGUF has support for some unusual models maybe using convert.py first would be better but we can change the usage order later * fix: pre-install directory changed * fix: sometimes exit code is undefined * chore: download additional files for qwen * fix: event handling changed * chore: add one more necessary package * feat: download gguf-py from llama.cpp * fix: cannot interpret wildcards on GNU tar Co-authored-by: hiento09 <136591877+hiento09@users.noreply.github.com> --------- Co-authored-by: hiento09 <136591877+hiento09@users.noreply.github.com>
71 lines
2.1 KiB
TypeScript
71 lines
2.1 KiB
TypeScript
import { CommandModal, Modal, ModalContent } from '@janhq/uikit'
|
|
import { useAtomValue, useSetAtom } from 'jotai'
|
|
|
|
import { HuggingFaceConvertingErrorModal } from '../HuggingFaceConvertingErrorModal'
|
|
import { HuggingFaceConvertingModal } from '../HuggingFaceConvertingModal'
|
|
import { HuggingFaceRepoDataLoadedModal } from '../HuggingFaceRepoDataLoadedModal'
|
|
import { HuggingFaceSearchErrorModal } from '../HuggingFaceSearchErrorModal'
|
|
import { HuggingFaceSearchModal } from '../HuggingFaceSearchModal'
|
|
|
|
import {
|
|
repoDataAtom,
|
|
fetchErrorAtom,
|
|
resetAtom,
|
|
conversionStatusAtom,
|
|
conversionErrorAtom,
|
|
} from '@/helpers/atoms/HFConverter.atom'
|
|
|
|
const HuggingFaceModal = ({
|
|
...props
|
|
}: Omit<Parameters<typeof CommandModal>[0], 'children'>) => {
|
|
const repoData = useAtomValue(repoDataAtom)
|
|
const fetchError = useAtomValue(fetchErrorAtom)
|
|
const conversionStatus = useAtomValue(conversionStatusAtom)
|
|
const conversionError = useAtomValue(conversionErrorAtom)
|
|
const setReset = useSetAtom(resetAtom)
|
|
|
|
return (
|
|
<Modal
|
|
{...props}
|
|
onOpenChange={(open) => {
|
|
if (open === false) {
|
|
if (
|
|
!repoData ||
|
|
['done', 'stopping'].includes(conversionStatus ?? '') ||
|
|
conversionError
|
|
) {
|
|
setReset()
|
|
}
|
|
}
|
|
if (props.onOpenChange) {
|
|
props.onOpenChange(open)
|
|
}
|
|
}}
|
|
>
|
|
<ModalContent>
|
|
<div className="px-2 py-3">
|
|
<div className="flex w-full flex-col items-center justify-center gap-4 p-4">
|
|
{repoData ? (
|
|
conversionStatus ? (
|
|
conversionError ? (
|
|
<HuggingFaceConvertingErrorModal />
|
|
) : (
|
|
<HuggingFaceConvertingModal />
|
|
)
|
|
) : (
|
|
<HuggingFaceRepoDataLoadedModal />
|
|
)
|
|
) : fetchError ? (
|
|
<HuggingFaceSearchErrorModal />
|
|
) : (
|
|
<HuggingFaceSearchModal />
|
|
)}
|
|
</div>
|
|
</div>
|
|
</ModalContent>
|
|
</Modal>
|
|
)
|
|
}
|
|
|
|
export { HuggingFaceModal }
|