fix/revalidate-model-gguf
This commit is contained in:
parent
ea354ce621
commit
272ef9f8b8
@ -10,7 +10,7 @@ import {
|
|||||||
import { Button } from '@/components/ui/button'
|
import { Button } from '@/components/ui/button'
|
||||||
import { Switch } from '@/components/ui/switch'
|
import { Switch } from '@/components/ui/switch'
|
||||||
import { useServiceHub } from '@/hooks/useServiceHub'
|
import { useServiceHub } from '@/hooks/useServiceHub'
|
||||||
import { useState } from 'react'
|
import { useState, useEffect, useCallback } from 'react'
|
||||||
import { toast } from 'sonner'
|
import { toast } from 'sonner'
|
||||||
import {
|
import {
|
||||||
IconLoader2,
|
IconLoader2,
|
||||||
@ -44,7 +44,7 @@ export const ImportVisionModelDialog = ({
|
|||||||
>(null)
|
>(null)
|
||||||
const [isValidatingMmproj, setIsValidatingMmproj] = useState(false)
|
const [isValidatingMmproj, setIsValidatingMmproj] = useState(false)
|
||||||
|
|
||||||
const validateGgufFile = async (
|
const validateGgufFile = useCallback(async (
|
||||||
filePath: string,
|
filePath: string,
|
||||||
fileType: 'model' | 'mmproj'
|
fileType: 'model' | 'mmproj'
|
||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
@ -158,15 +158,15 @@ export const ImportVisionModelDialog = ({
|
|||||||
setIsValidatingMmproj(false)
|
setIsValidatingMmproj(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}, [modelName, serviceHub])
|
||||||
|
|
||||||
const validateModelFile = async (filePath: string): Promise<void> => {
|
const validateModelFile = useCallback(async (filePath: string): Promise<void> => {
|
||||||
await validateGgufFile(filePath, 'model')
|
await validateGgufFile(filePath, 'model')
|
||||||
}
|
}, [validateGgufFile])
|
||||||
|
|
||||||
const validateMmprojFile = async (filePath: string): Promise<void> => {
|
const validateMmprojFile = useCallback(async (filePath: string): Promise<void> => {
|
||||||
await validateGgufFile(filePath, 'mmproj')
|
await validateGgufFile(filePath, 'mmproj')
|
||||||
}
|
}, [validateGgufFile])
|
||||||
|
|
||||||
const handleFileSelect = async (type: 'model' | 'mmproj') => {
|
const handleFileSelect = async (type: 'model' | 'mmproj') => {
|
||||||
const selectedFile = await serviceHub.dialog().open({
|
const selectedFile = await serviceHub.dialog().open({
|
||||||
@ -272,6 +272,13 @@ export const ImportVisionModelDialog = ({
|
|||||||
setIsValidatingMmproj(false)
|
setIsValidatingMmproj(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Re-validate MMProj file when model name changes
|
||||||
|
useEffect(() => {
|
||||||
|
if (mmProjFile && modelName && isVisionModel) {
|
||||||
|
validateMmprojFile(mmProjFile)
|
||||||
|
}
|
||||||
|
}, [modelName, mmProjFile, isVisionModel, validateMmprojFile])
|
||||||
|
|
||||||
const handleOpenChange = (newOpen: boolean) => {
|
const handleOpenChange = (newOpen: boolean) => {
|
||||||
if (!importing) {
|
if (!importing) {
|
||||||
setOpen(newOpen)
|
setOpen(newOpen)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user