enhancement: set recommend model to undefined if no model available (#4296)

* enhancement: set recommend model to undefined if not lastUsedModel

* chore: update logic
This commit is contained in:
Faisal Amir 2024-12-19 15:14:42 +08:00 committed by GitHub
parent fd45e7e47f
commit 0271774773
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 4 deletions

View File

@ -23,6 +23,7 @@ import { isLocalEngine } from '@/utils/modelEngine'
import { useActiveModel } from './useActiveModel'
import useRecommendedModel from './useRecommendedModel'
import useSetActiveThread from './useSetActiveThread'
import { extensionManager } from '@/extension'
@ -73,6 +74,8 @@ export const useCreateNewThread = () => {
const threads = useAtomValue(threadsAtom)
const { stopInference } = useActiveModel()
const { recommendedModel } = useRecommendedModel()
const requestCreateNewThread = async (
assistant: (ThreadAssistantInfo & { id: string; name: string }) | Assistant,
model?: Model | undefined
@ -81,7 +84,7 @@ export const useCreateNewThread = () => {
setIsGeneratingResponse(false)
stopInference()
const defaultModel = model
const defaultModel = model || recommendedModel
if (!model) {
// if we have model, which means user wants to create new thread from Model hub. Allow them.

View File

@ -67,6 +67,7 @@ export default function useRecommendedModel() {
if (models.length === 0) {
// if we have no downloaded models, then can't recommend anything
console.debug("No downloaded models, can't recommend anything")
setRecommendedModel(undefined)
return
}

View File

@ -188,9 +188,8 @@ const ChatInput = () => {
</Button>
}
disabled={
!isModelSupportRagAndTools &&
activeAssistant?.tools &&
activeAssistant?.tools[0]?.enabled
!isModelSupportRagAndTools ||
(activeAssistant?.tools && activeAssistant?.tools[0]?.enabled)
}
content={
<>