Merge pull request #3997 from janhq/fix/model-import-name
fix: remove cuda toolkit error message and bring back incremental model import
This commit is contained in:
commit
20c467e615
@ -29,7 +29,7 @@ export default function useDropModelBinaries() {
|
|||||||
const importingModels: ImportingModel[] = supportedFiles.map((file) => ({
|
const importingModels: ImportingModel[] = supportedFiles.map((file) => ({
|
||||||
importId: uuidv4(),
|
importId: uuidv4(),
|
||||||
modelId: undefined,
|
modelId: undefined,
|
||||||
name: file.name.replace('.gguf', ''),
|
name: file.name.replace(/ /g, '').replace('.gguf', ''),
|
||||||
description: '',
|
description: '',
|
||||||
path: file.path,
|
path: file.path,
|
||||||
tags: [],
|
tags: [],
|
||||||
|
|||||||
@ -12,7 +12,7 @@ import {
|
|||||||
baseName,
|
baseName,
|
||||||
} from '@janhq/core'
|
} from '@janhq/core'
|
||||||
|
|
||||||
import { atom, useSetAtom } from 'jotai'
|
import { atom, useAtomValue, useSetAtom } from 'jotai'
|
||||||
|
|
||||||
import { v4 as uuidv4 } from 'uuid'
|
import { v4 as uuidv4 } from 'uuid'
|
||||||
|
|
||||||
@ -23,6 +23,7 @@ import { FilePathWithSize } from '@/utils/file'
|
|||||||
import { extensionManager } from '@/extension'
|
import { extensionManager } from '@/extension'
|
||||||
import {
|
import {
|
||||||
addDownloadingModelAtom,
|
addDownloadingModelAtom,
|
||||||
|
downloadedModelsAtom,
|
||||||
importingModelsAtom,
|
importingModelsAtom,
|
||||||
removeDownloadingModelAtom,
|
removeDownloadingModelAtom,
|
||||||
} from '@/helpers/atoms/Model.atom'
|
} from '@/helpers/atoms/Model.atom'
|
||||||
@ -58,11 +59,24 @@ const useImportModel = () => {
|
|||||||
const setImportingModels = useSetAtom(importingModelsAtom)
|
const setImportingModels = useSetAtom(importingModelsAtom)
|
||||||
const addDownloadingModel = useSetAtom(addDownloadingModelAtom)
|
const addDownloadingModel = useSetAtom(addDownloadingModelAtom)
|
||||||
const removeDownloadingModel = useSetAtom(removeDownloadingModelAtom)
|
const removeDownloadingModel = useSetAtom(removeDownloadingModelAtom)
|
||||||
|
const downloadedModels = useAtomValue(downloadedModelsAtom)
|
||||||
|
|
||||||
|
const incrementalModelName = useCallback(
|
||||||
|
(name: string, startIndex: number = 0): string => {
|
||||||
|
const newModelName = startIndex ? `${name}-${startIndex}` : name
|
||||||
|
if (downloadedModels.some((model) => model.id === newModelName)) {
|
||||||
|
return incrementalModelName(name, startIndex + 1)
|
||||||
|
} else {
|
||||||
|
return newModelName
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[downloadedModels]
|
||||||
|
)
|
||||||
|
|
||||||
const importModels = useCallback(
|
const importModels = useCallback(
|
||||||
(models: ImportingModel[], optionType: OptionType) => {
|
(models: ImportingModel[], optionType: OptionType) => {
|
||||||
models.map(async (model) => {
|
models.map(async (model) => {
|
||||||
const modelId = model.modelId ?? (await baseName(model.path))
|
const modelId = model.modelId ?? incrementalModelName(model.name)
|
||||||
if (modelId) {
|
if (modelId) {
|
||||||
addDownloadingModel(modelId)
|
addDownloadingModel(modelId)
|
||||||
extensionManager
|
extensionManager
|
||||||
@ -78,7 +92,7 @@ const useImportModel = () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
[addDownloadingModel, removeDownloadingModel]
|
[addDownloadingModel, incrementalModelName, removeDownloadingModel]
|
||||||
)
|
)
|
||||||
|
|
||||||
const updateModelInfo = useCallback(
|
const updateModelInfo = useCallback(
|
||||||
@ -100,7 +114,7 @@ const useImportModel = () => {
|
|||||||
({ path, name, size }: FilePathWithSize) => ({
|
({ path, name, size }: FilePathWithSize) => ({
|
||||||
importId: uuidv4(),
|
importId: uuidv4(),
|
||||||
modelId: undefined,
|
modelId: undefined,
|
||||||
name: name.replace('.gguf', ''),
|
name: name.replace(/ /g, '').replace('.gguf', ''),
|
||||||
description: '',
|
description: '',
|
||||||
path: path,
|
path: path,
|
||||||
tags: [],
|
tags: [],
|
||||||
|
|||||||
@ -64,49 +64,6 @@ const LoadModelError = () => {
|
|||||||
to continue using it.
|
to continue using it.
|
||||||
</p>
|
</p>
|
||||||
)
|
)
|
||||||
} else if (
|
|
||||||
settings &&
|
|
||||||
settings.run_mode === 'gpu' &&
|
|
||||||
!settings.vulkan &&
|
|
||||||
(!settings.nvidia_driver?.exist || !settings.cuda?.exist)
|
|
||||||
) {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
{!settings?.cuda.exist ? (
|
|
||||||
<p>
|
|
||||||
The CUDA toolkit may be unavailable. Please use the{' '}
|
|
||||||
<span
|
|
||||||
className="cursor-pointer font-medium text-[hsla(var(--app-link))]"
|
|
||||||
onClick={() => {
|
|
||||||
setMainState(MainViewState.Settings)
|
|
||||||
if (activeThread?.assistants[0]?.model.engine) {
|
|
||||||
const engine = EngineManager.instance().get(
|
|
||||||
activeThread.assistants[0].model.engine
|
|
||||||
)
|
|
||||||
engine?.name && setSelectedSettingScreen(engine.name)
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Install Additional Dependencies
|
|
||||||
</span>{' '}
|
|
||||||
setting to proceed with the download / installation process.
|
|
||||||
</p>
|
|
||||||
) : (
|
|
||||||
<div>
|
|
||||||
Problem with Nvidia drivers. Please follow the{' '}
|
|
||||||
<a
|
|
||||||
className="font-medium text-[hsla(var(--app-link))]"
|
|
||||||
href="https://www.nvidia.com/Download/index.aspx"
|
|
||||||
target="_blank"
|
|
||||||
>
|
|
||||||
Nvidia Drivers guideline
|
|
||||||
</a>{' '}
|
|
||||||
to access installation instructions and ensure proper functioning
|
|
||||||
of the application.
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user