Skip to content

Commit 25fa490

Browse files
authored
Merge pull request #5997 from menloresearch/release/v0.6.6
Sync Release/v0.6.6 into dev
2 parents e48b8c9 + 76bcf33 commit 25fa490

File tree

8 files changed

+237
-157
lines changed

8 files changed

+237
-157
lines changed

extensions/llamacpp-extension/src/index.ts

Lines changed: 62 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -866,65 +866,69 @@ export default class llamacpp_extension extends AIEngine {
866866

867867
const files = await fs.readdirSync(currentDir)
868868
for (const child of files) {
869-
const childPath = await joinPath([currentDir, child])
870-
const stat = await fs.fileStat(childPath)
871-
if (
872-
files.some((e) => e.endsWith('model.yml')) &&
873-
!child.endsWith('model.yml')
874-
)
875-
continue
876-
if (!stat.isDirectory && child.endsWith('.yml')) {
877-
// check if model.yml exists
878-
const modelConfigPath = child
879-
if (await fs.existsSync(modelConfigPath)) {
880-
const legacyModelConfig = await invoke<{
881-
files: string[]
882-
model: string
883-
}>('read_yaml', {
884-
path: modelConfigPath,
885-
})
886-
const legacyModelPath = legacyModelConfig.files?.[0]
887-
if (!legacyModelPath) continue
888-
// +1 to remove the leading slash
889-
// NOTE: this does not handle Windows path \\
890-
let modelId = currentDir.slice(modelsDir.length + 1)
891-
892-
modelId =
893-
modelId !== 'imported'
894-
? modelId.replace(/^(cortex\.so|huggingface\.co)[\/\\]/, '')
895-
: (await basename(child)).replace('.yml', '')
896-
897-
const modelName = legacyModelConfig.model ?? modelId
898-
const configPath = await joinPath([
899-
await this.getProviderPath(),
900-
'models',
901-
modelId,
902-
'model.yml',
903-
])
904-
if (await fs.existsSync(configPath)) continue // Don't reimport
905-
906-
// this is relative to Jan's data folder
907-
const modelDir = `${this.providerId}/models/${modelId}`
908-
909-
let size_bytes = (
910-
await fs.fileStat(
911-
await joinPath([janDataFolderPath, legacyModelPath])
912-
)
913-
).size
914-
915-
const modelConfig = {
916-
model_path: legacyModelPath,
917-
mmproj_path: undefined, // legacy models do not have mmproj
918-
name: modelName,
919-
size_bytes,
920-
} as ModelConfig
921-
await fs.mkdir(await joinPath([janDataFolderPath, modelDir]))
922-
await invoke<void>('write_yaml', {
923-
data: modelConfig,
924-
savePath: configPath,
925-
})
869+
try {
870+
const childPath = await joinPath([currentDir, child])
871+
const stat = await fs.fileStat(childPath)
872+
if (
873+
files.some((e) => e.endsWith('model.yml')) &&
874+
!child.endsWith('model.yml')
875+
)
926876
continue
877+
if (!stat.isDirectory && child.endsWith('.yml')) {
878+
// check if model.yml exists
879+
const modelConfigPath = child
880+
if (await fs.existsSync(modelConfigPath)) {
881+
const legacyModelConfig = await invoke<{
882+
files: string[]
883+
model: string
884+
}>('read_yaml', {
885+
path: modelConfigPath,
886+
})
887+
const legacyModelPath = legacyModelConfig.files?.[0]
888+
if (!legacyModelPath) continue
889+
// +1 to remove the leading slash
890+
// NOTE: this does not handle Windows path \\
891+
let modelId = currentDir.slice(modelsDir.length + 1)
892+
893+
modelId =
894+
modelId !== 'imported'
895+
? modelId.replace(/^(cortex\.so|huggingface\.co)[\/\\]/, '')
896+
: (await basename(child)).replace('.yml', '')
897+
898+
const modelName = legacyModelConfig.model ?? modelId
899+
const configPath = await joinPath([
900+
await this.getProviderPath(),
901+
'models',
902+
modelId,
903+
'model.yml',
904+
])
905+
if (await fs.existsSync(configPath)) continue // Don't reimport
906+
907+
// this is relative to Jan's data folder
908+
const modelDir = `${this.providerId}/models/${modelId}`
909+
910+
let size_bytes = (
911+
await fs.fileStat(
912+
await joinPath([janDataFolderPath, legacyModelPath])
913+
)
914+
).size
915+
916+
const modelConfig = {
917+
model_path: legacyModelPath,
918+
mmproj_path: undefined, // legacy models do not have mmproj
919+
name: modelName,
920+
size_bytes,
921+
} as ModelConfig
922+
await fs.mkdir(await joinPath([janDataFolderPath, modelDir]))
923+
await invoke<void>('write_yaml', {
924+
data: modelConfig,
925+
savePath: configPath,
926+
})
927+
continue
928+
}
927929
}
930+
} catch (error) {
931+
console.error(`Error migrating model ${child}:`, error)
928932
}
929933
}
930934

@@ -1093,9 +1097,7 @@ export default class llamacpp_extension extends AIEngine {
10931097
attempts++
10941098
}
10951099

1096-
throw new Error(
1097-
'Failed to find an available port for the model to load'
1098-
)
1100+
throw new Error('Failed to find an available port for the model to load')
10991101
}
11001102

11011103
private async sleep(ms: number): Promise<void> {

web-app/src/containers/LeftPanel.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import { toast } from 'sonner'
4242
import { DownloadManagement } from '@/containers/DownloadManegement'
4343
import { useSmallScreen } from '@/hooks/useMediaQuery'
4444
import { useClickOutside } from '@/hooks/useClickOutside'
45+
import { useDownloadStore } from '@/hooks/useDownloadStore'
4546

4647
const mainMenus = [
4748
{
@@ -171,6 +172,8 @@ const LeftPanel = () => {
171172
}
172173
}, [isSmallScreen, open])
173174

175+
const { downloads, localDownloadingModels } = useDownloadStore()
176+
174177
return (
175178
<>
176179
{/* Backdrop overlay for small screens */}
@@ -253,7 +256,14 @@ const LeftPanel = () => {
253256
</div>
254257

255258
<div className="flex flex-col justify-between overflow-hidden mt-0 !h-[calc(100%-42px)]">
256-
<div className="flex flex-col !h-[calc(100%-140px)]">
259+
<div
260+
className={cn(
261+
'flex flex-col',
262+
Object.keys(downloads).length > 0 || localDownloadingModels.size > 0
263+
? 'h-[calc(100%-200px)]'
264+
: 'h-[calc(100%-140px)]'
265+
)}
266+
>
257267
{IS_MACOS && (
258268
<div
259269
ref={searchContainerMacRef}
@@ -486,8 +496,8 @@ const LeftPanel = () => {
486496
</Link>
487497
)
488498
})}
499+
<DownloadManagement />
489500
</div>
490-
<DownloadManagement />
491501
</div>
492502
</aside>
493503
</>

web-app/src/containers/dialogs/LoadModelErrorDialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export default function LoadModelErrorDialog() {
5252
<div>
5353
<DialogTitle>{t('common:error')}</DialogTitle>
5454
<DialogDescription className="mt-1 text-main-view-fg/70">
55-
Failed to load model
55+
Something went wrong
5656
</DialogDescription>
5757
</div>
5858
</div>

web-app/src/hooks/useChat.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,7 @@ export const useChat = () => {
247247
messages,
248248
currentAssistant?.instructions
249249
)
250-
251-
builder.addUserMessage(message)
250+
if (troubleshooting) builder.addUserMessage(message)
252251

253252
let isCompleted = false
254253

0 commit comments

Comments
 (0)