From 9fb9a1534d6745bab6e6869943940a2900108742 Mon Sep 17 00:00:00 2001 From: Ilya Bondar Date: Tue, 10 Sep 2024 18:04:29 +0200 Subject: [PATCH] fix(chat): use `model.reference` instead of `model.id` everywhere in `conversation.model.id` (Error 412) (#2091) --- apps/chat/src/components/Chat/ModelList.tsx | 7 +++++-- .../src/store/conversations/conversations.epics.ts | 2 +- apps/chat/src/store/overlay/overlay.epics.ts | 11 +++++++---- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/apps/chat/src/components/Chat/ModelList.tsx b/apps/chat/src/components/Chat/ModelList.tsx index 3f92fea5f8..2a1f73736b 100644 --- a/apps/chat/src/components/Chat/ModelList.tsx +++ b/apps/chat/src/components/Chat/ModelList.tsx @@ -365,7 +365,7 @@ export const ModelList = ({ const modelsMapKeys = Object.keys(modelsMap); - onSelect(recentModelsIds[1] ?? modelsMap[modelsMapKeys[0]]); + onSelect(recentModelsIds[1] ?? modelsMap[modelsMapKeys[0]]?.reference); selectedConversations.forEach((conv) => { if ( conv.model.id === currentEntity?.reference || @@ -375,7 +375,10 @@ export const ModelList = ({ ConversationsActions.updateConversation({ id: conv.id, values: { - model: { id: recentModelsIds[1] ?? modelsMap[modelsMapKeys[0]] }, + model: { + id: + recentModelsIds[1] ?? modelsMap[modelsMapKeys[0]]?.reference, + }, }, }), ); diff --git a/apps/chat/src/store/conversations/conversations.epics.ts b/apps/chat/src/store/conversations/conversations.epics.ts index c9c477d784..a569cfeab2 100644 --- a/apps/chat/src/store/conversations/conversations.epics.ts +++ b/apps/chat/src/store/conversations/conversations.epics.ts @@ -409,7 +409,7 @@ const createNewConversationsEpic: AppEpic = (action$, state$) => ), messages: [], model: { - id: model.id, + id: model.reference, }, prompt: DEFAULT_SYSTEM_PROMPT, temperature: diff --git a/apps/chat/src/store/overlay/overlay.epics.ts b/apps/chat/src/store/overlay/overlay.epics.ts index ec28b859a1..aad8a39549 100644 --- a/apps/chat/src/store/overlay/overlay.epics.ts +++ b/apps/chat/src/store/overlay/overlay.epics.ts @@ -286,16 +286,19 @@ const setOverlayOptionsEpic: AppEpic = (action$, state$) => if (currentConversation) { const models = ModelsSelectors.selectModels(state$.value); - const newAiEntity = models.find(({ id }) => id === finalModelId) as - | DialAIEntityModel - | undefined; + const newAiEntity = models.find( + ({ reference, id }) => + id === finalModelId || reference === finalModelId, + ) as DialAIEntityModel | undefined; actions.push( of( ConversationsActions.updateConversation({ id: currentConversation.id, values: { - model: { id: finalModelId }, + model: { + id: newAiEntity?.reference ?? finalModelId, + }, }, }), ),