Skip to content

Commit

Permalink
fix(chat): use model.reference instead of model.id everywhere in …
Browse files Browse the repository at this point in the history
…`conversation.model.id` (Error 412) (#2091)
  • Loading branch information
IlyaBondar authored Sep 10, 2024
1 parent 4ac54ba commit 9fb9a15
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
7 changes: 5 additions & 2 deletions apps/chat/src/components/Chat/ModelList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||
Expand All @@ -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,
},
},
}),
);
Expand Down
2 changes: 1 addition & 1 deletion apps/chat/src/store/conversations/conversations.epics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ const createNewConversationsEpic: AppEpic = (action$, state$) =>
),
messages: [],
model: {
id: model.id,
id: model.reference,
},
prompt: DEFAULT_SYSTEM_PROMPT,
temperature:
Expand Down
11 changes: 7 additions & 4 deletions apps/chat/src/store/overlay/overlay.epics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
}),
),
Expand Down

0 comments on commit 9fb9a15

Please sign in to comment.