Merge pull request #4156 from janhq/fix/remote-model

fix: remove filter on recommend model
This commit is contained in:
Louis 2024-11-28 22:25:44 +07:00 committed by GitHub
commit 0c37be302c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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])
}