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 downloadedModels = useAtomValue(downloadedModelsAtom)
|
||||||
|
|
||||||
const getAndSortDownloadedModels = useCallback(async (): Promise<Model[]> => {
|
const getAndSortDownloadedModels = useCallback(async (): Promise<Model[]> => {
|
||||||
const models = downloadedModels.sort((a, b) =>
|
const models = downloadedModels
|
||||||
a.engine !== InferenceEngine.nitro && b.engine === InferenceEngine.nitro
|
.filter((model) => model.engine === InferenceEngine.cortex_llamacpp)
|
||||||
? 1
|
.sort((a, b) =>
|
||||||
: -1
|
a.engine !== InferenceEngine.cortex_llamacpp &&
|
||||||
)
|
b.engine === InferenceEngine.cortex_llamacpp
|
||||||
|
? 1
|
||||||
|
: -1
|
||||||
|
)
|
||||||
setSortedModels(models)
|
setSortedModels(models)
|
||||||
return models
|
return models
|
||||||
}, [downloadedModels])
|
}, [downloadedModels])
|
||||||
@ -43,6 +46,7 @@ export default function useRecommendedModel() {
|
|||||||
Model | undefined
|
Model | undefined
|
||||||
> => {
|
> => {
|
||||||
const models = await getAndSortDownloadedModels()
|
const models = await getAndSortDownloadedModels()
|
||||||
|
|
||||||
if (!activeThread) return
|
if (!activeThread) return
|
||||||
const modelId = activeThread.assistants[0]?.model.id
|
const modelId = activeThread.assistants[0]?.model.id
|
||||||
const model = models.find((model) => model.id === modelId)
|
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
|
* This will create a new thread if there are assistants available
|
||||||
* and there are no threads available
|
* and there are no threads available
|
||||||
*/
|
*/
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (
|
if (
|
||||||
threadDataReady &&
|
threadDataReady &&
|
||||||
assistants.length > 0 &&
|
assistants.length > 0 &&
|
||||||
threads.length === 0 &&
|
threads.length === 0 &&
|
||||||
(downloadedModels[0] || recommendedModel)
|
downloadedModels.length > 0
|
||||||
) {
|
) {
|
||||||
const model = downloadedModels[0] || recommendedModel
|
requestCreateNewThread(assistants[0], recommendedModel)
|
||||||
requestCreateNewThread(assistants[0], model)
|
|
||||||
} else if (threadDataReady && !activeThreadId) {
|
} else if (threadDataReady && !activeThreadId) {
|
||||||
setActiveThread(threads[0])
|
setActiveThread(threads[0])
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user