fix: remove filter on recommend model

This commit is contained in:
Faisal Amir 2024-11-28 21:46:30 +07:00
parent 8657e032a7
commit 9a3a8d1464
2 changed files with 12 additions and 10 deletions

View File

@ -30,14 +30,12 @@ export default function useRecommendedModel() {
const downloadedModels = useAtomValue(downloadedModelsAtom)
const getAndSortDownloadedModels = useCallback(async (): Promise<Model[]> => {
const models = downloadedModels
.filter((model) => model.engine === InferenceEngine.cortex_llamacpp)
.sort((a, b) =>
a.engine !== InferenceEngine.cortex_llamacpp &&
b.engine === InferenceEngine.cortex_llamacpp
? 1
: -1
)
const models = downloadedModels.sort((a, b) =>
a.engine !== InferenceEngine.cortex_llamacpp &&
b.engine === InferenceEngine.cortex_llamacpp
? 1
: -1
)
setSortedModels(models)
return models
}, [downloadedModels])

View File

@ -1,6 +1,6 @@
import { useCallback, useEffect, useState } from 'react'
import { Thread } from '@janhq/core'
import { InferenceEngine, Thread } from '@janhq/core'
import { Button } from '@janhq/joi'
import { useAtomValue, useSetAtom } from 'jotai'
@ -71,7 +71,11 @@ const ThreadLeftPanel = () => {
threads.length === 0 &&
downloadedModels.length > 0
) {
requestCreateNewThread(assistants[0], recommendedModel)
const model = downloadedModels.filter(
(model) => model.engine === InferenceEngine.cortex_llamacpp
)
const selectedModel = model[0] || recommendedModel
requestCreateNewThread(assistants[0], selectedModel)
} else if (threadDataReady && !activeThreadId) {
setActiveThread(threads[0])
}