fix: default local model from starter screen (#4151)
* fix: default local model starter screen * chore: update logic recommend model * chore: cleanup import
This commit is contained in:
parent
cd1a2746ce
commit
7bd59f0c84
@ -30,11 +30,14 @@ export default function useRecommendedModel() {
|
||||
const downloadedModels = useAtomValue(downloadedModelsAtom)
|
||||
|
||||
const getAndSortDownloadedModels = useCallback(async (): Promise<Model[]> => {
|
||||
const models = downloadedModels.sort((a, b) =>
|
||||
a.engine !== InferenceEngine.nitro && b.engine === InferenceEngine.nitro
|
||||
? 1
|
||||
: -1
|
||||
)
|
||||
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
|
||||
)
|
||||
setSortedModels(models)
|
||||
return models
|
||||
}, [downloadedModels])
|
||||
@ -43,6 +46,7 @@ export default function useRecommendedModel() {
|
||||
Model | undefined
|
||||
> => {
|
||||
const models = await getAndSortDownloadedModels()
|
||||
|
||||
if (!activeThread) return
|
||||
const modelId = activeThread.assistants[0]?.model.id
|
||||
const model = models.find((model) => model.id === modelId)
|
||||
|
||||
@ -63,15 +63,15 @@ const ThreadLeftPanel = () => {
|
||||
* This will create a new thread if there are assistants available
|
||||
* and there are no threads available
|
||||
*/
|
||||
|
||||
useEffect(() => {
|
||||
if (
|
||||
threadDataReady &&
|
||||
assistants.length > 0 &&
|
||||
threads.length === 0 &&
|
||||
(downloadedModels[0] || recommendedModel)
|
||||
downloadedModels.length > 0
|
||||
) {
|
||||
const model = downloadedModels[0] || recommendedModel
|
||||
requestCreateNewThread(assistants[0], model)
|
||||
requestCreateNewThread(assistants[0], recommendedModel)
|
||||
} else if (threadDataReady && !activeThreadId) {
|
||||
setActiveThread(threads[0])
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user