* 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>
92 lines
2.8 KiB
TypeScript
92 lines
2.8 KiB
TypeScript
import React, { useCallback, useRef, useState } from 'react'
|
|
|
|
import { ModelImportOption } from '@janhq/core'
|
|
import { Button, Modal, ModalClose } from '@janhq/joi'
|
|
import { useAtomValue, useSetAtom } from 'jotai'
|
|
|
|
import useImportModel, {
|
|
getImportModelStageAtom,
|
|
setImportModelStageAtom,
|
|
} from '@/hooks/useImportModel'
|
|
|
|
import ImportModelOptionSelection from './ImportModelOptionSelection'
|
|
|
|
import { importingModelsAtom } from '@/helpers/atoms/Model.atom'
|
|
|
|
const importOptions: ModelImportOption[] = [
|
|
{
|
|
type: 'SYMLINK',
|
|
title: 'Keep Original Files & Symlink',
|
|
description:
|
|
'You maintain your model files outside of Jan. Keeping your files where they are, and Jan will create a smart link to them.',
|
|
},
|
|
// {
|
|
// type: 'MOVE_BINARY_FILE',
|
|
// title: 'Move model binary file',
|
|
// description:
|
|
// 'Jan will move your model binary file from your current folder into Jan Data Folder.',
|
|
// },
|
|
]
|
|
|
|
const ImportModelOptionModal = () => {
|
|
const importingModels = useAtomValue(importingModelsAtom)
|
|
const importStage = useAtomValue(getImportModelStageAtom)
|
|
const setImportStage = useSetAtom(setImportModelStageAtom)
|
|
const { importModels } = useImportModel()
|
|
|
|
const [importOption, setImportOption] = useState(importOptions[0])
|
|
const destinationModal = useRef<'NONE' | 'IMPORTING_MODEL'>('NONE')
|
|
|
|
const onCancelClick = useCallback(() => {
|
|
setImportStage('NONE')
|
|
}, [setImportStage])
|
|
|
|
const onContinueClick = useCallback(() => {
|
|
importModels(importingModels, importOption.type)
|
|
setImportStage('IMPORTING_MODEL')
|
|
}, [importingModels, importOption, setImportStage, importModels])
|
|
|
|
return (
|
|
<Modal
|
|
open={importStage === 'MODEL_SELECTED'}
|
|
onOpenChange={() => {
|
|
if (destinationModal.current === 'NONE') {
|
|
setImportStage('NONE')
|
|
} else {
|
|
onContinueClick()
|
|
}
|
|
}}
|
|
title="How would you like Jan to handle your models?"
|
|
content={
|
|
<div className="mt-4">
|
|
{importOptions.map((option) => (
|
|
<ImportModelOptionSelection
|
|
key={option.type}
|
|
option={option}
|
|
checked={importOption.type === option.type}
|
|
setSelectedOptionType={() => setImportOption(option)}
|
|
/>
|
|
))}
|
|
<div className="mt-4 flex justify-end gap-x-2">
|
|
<ModalClose asChild onClick={onCancelClick}>
|
|
<Button theme="ghost">Cancel</Button>
|
|
</ModalClose>
|
|
<ModalClose asChild>
|
|
<Button
|
|
autoFocus
|
|
onClick={() => {
|
|
destinationModal.current = 'IMPORTING_MODEL'
|
|
}}
|
|
>
|
|
Continue Importing
|
|
</Button>
|
|
</ModalClose>
|
|
</div>
|
|
</div>
|
|
}
|
|
/>
|
|
)
|
|
}
|
|
|
|
export default ImportModelOptionModal
|