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:
parent
fd45e7e47f
commit
0271774773
@ -23,6 +23,7 @@ import { isLocalEngine } from '@/utils/modelEngine'
|
|||||||
|
|
||||||
import { useActiveModel } from './useActiveModel'
|
import { useActiveModel } from './useActiveModel'
|
||||||
|
|
||||||
|
import useRecommendedModel from './useRecommendedModel'
|
||||||
import useSetActiveThread from './useSetActiveThread'
|
import useSetActiveThread from './useSetActiveThread'
|
||||||
|
|
||||||
import { extensionManager } from '@/extension'
|
import { extensionManager } from '@/extension'
|
||||||
@ -73,6 +74,8 @@ export const useCreateNewThread = () => {
|
|||||||
const threads = useAtomValue(threadsAtom)
|
const threads = useAtomValue(threadsAtom)
|
||||||
const { stopInference } = useActiveModel()
|
const { stopInference } = useActiveModel()
|
||||||
|
|
||||||
|
const { recommendedModel } = useRecommendedModel()
|
||||||
|
|
||||||
const requestCreateNewThread = async (
|
const requestCreateNewThread = async (
|
||||||
assistant: (ThreadAssistantInfo & { id: string; name: string }) | Assistant,
|
assistant: (ThreadAssistantInfo & { id: string; name: string }) | Assistant,
|
||||||
model?: Model | undefined
|
model?: Model | undefined
|
||||||
@ -81,7 +84,7 @@ export const useCreateNewThread = () => {
|
|||||||
setIsGeneratingResponse(false)
|
setIsGeneratingResponse(false)
|
||||||
stopInference()
|
stopInference()
|
||||||
|
|
||||||
const defaultModel = model
|
const defaultModel = model || recommendedModel
|
||||||
|
|
||||||
if (!model) {
|
if (!model) {
|
||||||
// if we have model, which means user wants to create new thread from Model hub. Allow them.
|
// if we have model, which means user wants to create new thread from Model hub. Allow them.
|
||||||
|
|||||||
@ -67,6 +67,7 @@ export default function useRecommendedModel() {
|
|||||||
if (models.length === 0) {
|
if (models.length === 0) {
|
||||||
// if we have no downloaded models, then can't recommend anything
|
// if we have no downloaded models, then can't recommend anything
|
||||||
console.debug("No downloaded models, can't recommend anything")
|
console.debug("No downloaded models, can't recommend anything")
|
||||||
|
setRecommendedModel(undefined)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -188,9 +188,8 @@ const ChatInput = () => {
|
|||||||
</Button>
|
</Button>
|
||||||
}
|
}
|
||||||
disabled={
|
disabled={
|
||||||
!isModelSupportRagAndTools &&
|
!isModelSupportRagAndTools ||
|
||||||
activeAssistant?.tools &&
|
(activeAssistant?.tools && activeAssistant?.tools[0]?.enabled)
|
||||||
activeAssistant?.tools[0]?.enabled
|
|
||||||
}
|
}
|
||||||
content={
|
content={
|
||||||
<>
|
<>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user