feat: users should be able to switch models mid-thread (#1226)

## Problem
Right now users have to start a new thread to use another model which causes a lot of confusion to our users.

fixes #1201
This commit is contained in:
Louis 2023-12-27 15:35:27 +07:00 committed by GitHub
parent 150af523e1
commit a7f186cc5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 51 additions and 62 deletions

View File

@ -72,16 +72,10 @@ export default function DropdownListSidebar() {
if (!activeThread) { if (!activeThread) {
return null return null
} }
const finishInit = threadStates[activeThread.id].isFinishInit ?? true
return ( return (
<Tooltip> <>
<TooltipTrigger className="w-full"> <Select value={selected?.id} onValueChange={onValueSelected}>
<Select
disabled={finishInit}
value={selected?.id}
onValueChange={finishInit ? undefined : onValueSelected}
>
<SelectTrigger className="w-full"> <SelectTrigger className="w-full">
<SelectValue placeholder="Choose model to start"> <SelectValue placeholder="Choose model to start">
{downloadedModels.filter((x) => x.id === selected?.id)[0]?.name} {downloadedModels.filter((x) => x.id === selected?.id)[0]?.name}
@ -127,14 +121,6 @@ export default function DropdownListSidebar() {
</div> </div>
</SelectContent> </SelectContent>
</Select> </Select>
</TooltipTrigger>
{finishInit && (
<TooltipContent sideOffset={10}>
<span>Start a new thread to change the model</span>
<TooltipArrow />
</TooltipContent>
)}
{selected?.engine === InferenceEngine.openai && ( {selected?.engine === InferenceEngine.openai && (
<div className="mt-4"> <div className="mt-4">
@ -154,6 +140,6 @@ export default function DropdownListSidebar() {
/> />
</div> </div>
)} )}
</Tooltip> </>
) )
} }

View File

@ -138,7 +138,10 @@ export default function useSendChatMessage() {
const activeThreadState = threadStates[activeThread.id] const activeThreadState = threadStates[activeThread.id]
// if the thread is not initialized, we need to initialize it first // if the thread is not initialized, we need to initialize it first
if (!activeThreadState.isFinishInit) { if (
!activeThreadState.isFinishInit ||
activeThread.assistants[0].model.id !== selectedModel?.id
) {
if (!selectedModel) { if (!selectedModel) {
toaster({ title: 'Please select a model' }) toaster({ title: 'Please select a model' })
return return