mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-07 22:10:21 +08:00
fix: memorize assistant with model (#5701)
This commit is contained in:
parent
89e403ae61
commit
c0c6435fc5
@ -43,13 +43,15 @@ export function useAssistant(id: string) {
|
|||||||
const dispatch = useAppDispatch()
|
const dispatch = useAppDispatch()
|
||||||
const { defaultModel } = useDefaultModel()
|
const { defaultModel } = useDefaultModel()
|
||||||
|
|
||||||
const model = assistant?.model ?? assistant?.defaultModel ?? defaultModel
|
const model = useMemo(() => assistant?.model ?? assistant?.defaultModel ?? defaultModel, [assistant, defaultModel])
|
||||||
if (!model) {
|
if (!model) {
|
||||||
throw new Error(`Assistant model is not set for assistant with name: ${assistant?.name ?? 'unknown'}`)
|
throw new Error(`Assistant model is not set for assistant with name: ${assistant?.name ?? 'unknown'}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const assistantWithModel = useMemo(() => ({ ...assistant, model }), [assistant, model])
|
||||||
|
|
||||||
return {
|
return {
|
||||||
assistant: { ...assistant, model },
|
assistant: assistantWithModel,
|
||||||
model,
|
model,
|
||||||
addTopic: (topic: Topic) => dispatch(addTopic({ assistantId: assistant.id, topic })),
|
addTopic: (topic: Topic) => dispatch(addTopic({ assistantId: assistant.id, topic })),
|
||||||
removeTopic: (topic: Topic) => {
|
removeTopic: (topic: Topic) => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user