fix: create new thread with default assistant
This commit is contained in:
parent
bdcc3ef48c
commit
4cd0e63029
@ -4,15 +4,9 @@ import { atomWithStorage } from 'jotai/utils'
|
||||
|
||||
export const assistantsAtom = atom<Assistant[]>([])
|
||||
|
||||
export const cachedAssistantAtom = atomWithStorage<
|
||||
ThreadAssistantInfo | undefined
|
||||
>('activeAssistant', undefined, undefined, { getOnInit: true })
|
||||
/**
|
||||
* Get the current active assistant
|
||||
*/
|
||||
export const activeAssistantAtom = atom(
|
||||
(get) => get(cachedAssistantAtom) ?? get(assistantsAtom)[0],
|
||||
(_get, set, newAssistant: ThreadAssistantInfo) => {
|
||||
set(cachedAssistantAtom, newAssistant)
|
||||
}
|
||||
)
|
||||
export const activeAssistantAtom = atomWithStorage<
|
||||
ThreadAssistantInfo | undefined
|
||||
>('activeAssistant', undefined, undefined, { getOnInit: true })
|
||||
|
||||
@ -88,9 +88,7 @@ const MessageContainer: React.FC<
|
||||
>
|
||||
{isUser
|
||||
? props.role
|
||||
: 'assistant_name' in activeAssistant
|
||||
? activeAssistant?.assistant_name
|
||||
: props.role}
|
||||
: (activeAssistant?.assistant_name ?? props.role)}
|
||||
</div>
|
||||
<p className="text-xs font-medium text-gray-400">
|
||||
{props.created_at && displayDate(props.created_at ?? new Date())}
|
||||
|
||||
@ -71,7 +71,6 @@ const ThreadLeftPanel = () => {
|
||||
useEffect(() => {
|
||||
if (
|
||||
threadDataReady &&
|
||||
activeAssistant &&
|
||||
assistants.length > 0 &&
|
||||
threads.length === 0 &&
|
||||
downloadedModels.length > 0
|
||||
@ -81,7 +80,9 @@ const ThreadLeftPanel = () => {
|
||||
)
|
||||
const selectedModel = model[0] || recommendedModel
|
||||
requestCreateNewThread(
|
||||
{ ...assistants[0], ...activeAssistant },
|
||||
activeAssistant
|
||||
? { ...assistants[0], ...activeAssistant }
|
||||
: assistants[0],
|
||||
selectedModel
|
||||
)
|
||||
} else if (threadDataReady && !activeThreadId) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user