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