Skip to content

Commit

Permalink
fix import on windows
Browse files Browse the repository at this point in the history
Signed-off-by: James <[email protected]>
  • Loading branch information
namchuai committed Aug 1, 2024
1 parent 8ce640f commit a52a503
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 36 deletions.
7 changes: 4 additions & 3 deletions electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ Object.assign(console, log.functions)
app
.whenReady()
.then(() => {
log.info('Starting cortex with path:', cortexPath)
const command = `${cortexPath} -a 127.0.0.1 -p 1337`

log.info('Starting cortex with command:', command)
// init cortex
// running shell command cortex init -s
exec(`${cortexPath}`, (error, stdout, stderr) => {
exec(`${command}`, (error, stdout, stderr) => {
if (error) {
log.error(`error: ${error.message}`)
return
Expand Down
1 change: 1 addition & 0 deletions web/containers/Providers/DownloadEventListener.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const DownloadEventListener: React.FC = () => {
const localImportEvents: DownloadState2[] = []
// filter out the import local events
for (const event of downloadEvents) {
console.debug('Receiving event', event)
if (
isAbsolutePath(event.id) &&
event.type === 'model' &&
Expand Down
12 changes: 6 additions & 6 deletions web/hooks/useCortex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,12 +321,12 @@ const useCortex = () => {

const isSystemAlive = useCallback(async () => {
try {
await cortex.system.status();
return true;
} catch {
return false;
await cortex.system.status()
return true
} catch {
return false
}
}, [host])
}, [cortex.system])

return {
fetchAssistants,
Expand Down Expand Up @@ -354,7 +354,7 @@ const useCortex = () => {
createModel,
initializeEngine,
getEngineStatuses,
isSystemAlive
isSystemAlive,
}
}

Expand Down
28 changes: 17 additions & 11 deletions web/hooks/useDropModelBinaries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,23 @@ export default function useDropModelBinaries() {
)
const supportedFiles = files.filter((file) => file.path.endsWith('.gguf'))

const importingModels: ImportingModel[] = supportedFiles.map((file) => ({
importId: file.path,
modelId: undefined,
name: file.name.replace('.gguf', ''),
description: '',
path: file.path,
tags: [],
size: file.size,
status: 'PREPARING',
format: 'gguf',
}))
const importingModels: ImportingModel[] = supportedFiles.map((file) => {
const normalizedPath = isWindows
? file.path.replace(/\\/g, '/')
: file.path

return {
importId: normalizedPath,
modelId: undefined,
name: normalizedPath.replace('.gguf', ''),
description: '',
path: file.path,
tags: [],
size: file.size,
status: 'PREPARING',
format: 'gguf',
}
})
if (unsupportedFiles.length > 0) {
snackbar({
description: `Only files with .gguf extension can be imported.`,
Expand Down
2 changes: 1 addition & 1 deletion web/screens/Settings/ImportSuccessIcon/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const ImportSuccessIcon: React.FC<Props> = ({ onEditModelClick }) => {
}

const SuccessIcon = React.memo(() => (
<div className="bg-primary flex h-8 w-8 items-center justify-center rounded-full text-white">
<div className="bg-primary flex h-8 w-8 items-center justify-center rounded-full">
<Check size={20} />
</div>
))
Expand Down
34 changes: 19 additions & 15 deletions web/screens/Settings/SelectingModelModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ const SelectingModelModal: React.FC = () => {
const importModelStage = useAtomValue(getImportModelStageAtom)
const { onDropModels } = useDropModelBinaries()
const onSelectFileClick = useCallback(async () => {
if (isWindows) {
setImportModelStage('CHOOSE_WHAT_TO_IMPORT')
return
}
// if (isWindows) {
// setImportModelStage('CHOOSE_WHAT_TO_IMPORT')
// return
// }
const options: SelectFileOption = {
title: 'Select model folders',
buttonLabel: 'Select',
Expand All @@ -38,17 +38,21 @@ const SelectingModelModal: React.FC = () => {

const importingModels: ImportingModel[] = filePaths
.filter((path) => path.endsWith('.gguf'))
.map((path) => ({
importId: path,
modelId: undefined,
name: path.replace('.gguf', ''),
description: '',
path: path,
tags: [],
size: 0,
status: 'PREPARING',
format: 'gguf',
}))
.map((path) => {
const normalizedPath = isWindows ? path.replace(/\\/g, '/') : path

return {
importId: normalizedPath,
modelId: undefined,
name: normalizedPath.replace('.gguf', ''),
description: '',
path: path,
tags: [],
size: 0,
status: 'PREPARING',
format: 'gguf',
}
})
if (importingModels.length < 1) {
snackbar({
description: `Only files with .gguf extension can be imported.`,
Expand Down

0 comments on commit a52a503

Please sign in to comment.