Skip to content

Commit

Permalink
Merge pull request #4156 from janhq/fix/remote-model
Browse files Browse the repository at this point in the history
fix: remove filter on recommend model
  • Loading branch information
louis-jan authored Nov 28, 2024
2 parents 8657e03 + 9a3a8d1 commit 0c37be3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
14 changes: 6 additions & 8 deletions web/hooks/useRecommendedModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
8 changes: 6 additions & 2 deletions web/screens/Thread/ThreadLeftPanel/index.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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])
}
Expand Down

0 comments on commit 0c37be3

Please sign in to comment.