* fix: update new api from cortex to support 0.5.0 Signed-off-by: James <namnh0122@gmail.com> * fix stop button for streaming Signed-off-by: James <namnh0122@gmail.com> * fix stop inference for nonstreaming Signed-off-by: James <namnh0122@gmail.com> * chore: remove umami prevent tracking call to vercel Signed-off-by: James <namnh0122@gmail.com> * add warning modal when running more than 2 model concurrently Signed-off-by: James <namnh0122@gmail.com> * fix: skip summarize if abort Signed-off-by: James <namnh0122@gmail.com> * 0.5.0-3 * add inference error popup Signed-off-by: James <namnh0122@gmail.com> * add back import local model Signed-off-by: James <namnh0122@gmail.com> * fix: max token issue (#3225) Signed-off-by: James <namnh0122@gmail.com> * format status Signed-off-by: James <namnh0122@gmail.com> * fix migration missing instructions Signed-off-by: James <namnh0122@gmail.com> * fix: wait for cortex process overlay should be on top (#3224) * fix: wait for cortex process overlay should be on top * chore: update cortex.js * Cortex 0.5.0-5 * add import model to my model screen Signed-off-by: James <namnh0122@gmail.com> * fix: should migrate symlink models (#3226) * fix import on windows (#3229) Signed-off-by: James <namnh0122@gmail.com> * fix yarn lint Signed-off-by: James <namnh0122@gmail.com> * fix: clean up port before start jan (#3232) Signed-off-by: James <namnh0122@gmail.com> --------- Signed-off-by: James <namnh0122@gmail.com> Co-authored-by: Van Pham <64197333+Van-QA@users.noreply.github.com> Co-authored-by: Louis <louis@jan.ai>
93 lines
2.8 KiB
TypeScript
93 lines
2.8 KiB
TypeScript
import { useEffect } from 'react'
|
|
|
|
import { Modal } from '@janhq/joi'
|
|
import { useAtomValue, useSetAtom } from 'jotai'
|
|
|
|
import { AlertCircle } from 'lucide-react'
|
|
|
|
import useCortex from '@/hooks/useCortex'
|
|
import {
|
|
getImportModelStageAtom,
|
|
setImportModelStageAtom,
|
|
} from '@/hooks/useImportModel'
|
|
|
|
import ImportingModelItem from './ImportingModelItem'
|
|
|
|
import { importingModelsAtom } from '@/helpers/atoms/Model.atom'
|
|
|
|
const ImportingModelModal = () => {
|
|
const { downloadModel } = useCortex()
|
|
const setImportModelStage = useSetAtom(setImportModelStageAtom)
|
|
const importingModels = useAtomValue(importingModelsAtom)
|
|
const importModelStage = useAtomValue(getImportModelStageAtom)
|
|
|
|
const finishedImportModel = importingModels.filter(
|
|
(model) => model.status === 'IMPORTED'
|
|
).length
|
|
|
|
useEffect(() => {
|
|
const importModels = async () => {
|
|
for (const model of importingModels) {
|
|
await downloadModel(model.path)
|
|
// const parsedResult = await result?.json()
|
|
// if (
|
|
// parsedResult['message'] &&
|
|
// parsedResult['message'] === 'Download model started successfully.'
|
|
// ) {
|
|
// // update importingModels
|
|
// }
|
|
// console.log(`NamH result ${JSON.stringify(parsedResult)}`)
|
|
}
|
|
}
|
|
importModels()
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
}, [downloadModel])
|
|
|
|
return (
|
|
<Modal
|
|
open={importModelStage === 'IMPORTING_MODEL'}
|
|
onOpenChange={() => setImportModelStage('NONE')}
|
|
title={`Importing model (${finishedImportModel}/${importingModels.length})`}
|
|
content={
|
|
<div>
|
|
<div className="flex flex-row items-center space-x-2 pb-3">
|
|
{/* <label className="text-[hsla(var(--text-secondary)] text-xs">
|
|
{modelFolder}
|
|
</label>
|
|
<Button
|
|
theme="ghost"
|
|
size="small"
|
|
variant="outline"
|
|
onClick={onOpenModelFolderClick}
|
|
>
|
|
{openFileTitle()}
|
|
</Button> */}
|
|
</div>
|
|
|
|
<div className="mb-2 space-y-3">
|
|
{importingModels.map((model) => (
|
|
<ImportingModelItem key={model.importId} model={model} />
|
|
))}
|
|
</div>
|
|
|
|
<div>
|
|
<div className="flex flex-row gap-2 rounded-b-lg border-t border-[hsla(var(--app-border))] py-2">
|
|
<AlertCircle
|
|
size={16}
|
|
className="mt-1 flex-shrink-0 text-[hsla(var(--warning-bg))]"
|
|
/>
|
|
<p className="text-[hsla(var(--text-secondary)] font-semibold">
|
|
Own your model configurations, use at your own risk.
|
|
Misconfigurations may result in lower quality or unexpected
|
|
outputs.
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
}
|
|
/>
|
|
)
|
|
}
|
|
|
|
export default ImportingModelModal
|