Skip to content

Commit

Permalink
fix(chat): use latest used model (Issue #1672) (#1711)
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyaBondar authored Jul 3, 2024
1 parent 7628f9f commit 9ea9ebe
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ dist
.github
helm
apps/chat-e2e/html-report
apps/chat-e2e/chat-html-report
apps/chat-e2e/overlay-html-report
5 changes: 5 additions & 0 deletions apps/chat/src/store/conversations/conversations.epics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,11 @@ const createNewConversationsEpic: AppEpic = (action$, state$) =>
const models = ModelsSelectors.selectModels(state);
return models.filter((i) => i?.id === isolatedModelId);
}
if (lastConversation?.model.id) {
const lastModelId = lastConversation.model.id;
const models = ModelsSelectors.selectModels(state);
return models.filter((i) => i?.id === lastModelId);
}
return ModelsSelectors.selectRecentModels(state);
}),
filter((models) => models && models.length > 0),
Expand Down
19 changes: 14 additions & 5 deletions apps/chat/src/store/conversations/conversations.selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ export const selectConversations = createSelector(
(state) => state.conversations,
);

export const selectNotExternalConversations = createSelector(
[(state: RootState) => state, selectConversations],
(state, conversations) =>
conversations.filter(
(conversation) =>
!isEntityOrParentsExternal(state, conversation, FeatureType.Chat),
),
);

export const selectPublishedOrSharedByMeConversations = createSelector(
[selectConversations],
(conversations) => conversations.filter((c) => c.isShared || c.isPublished),
Expand Down Expand Up @@ -84,7 +93,7 @@ export const selectFilteredConversations = createSelector(
export const selectFolders = createSelector(
[rootSelector],
(state: ConversationsState) => {
return state.folders;
return state.folders || [];
},
);

Expand Down Expand Up @@ -137,10 +146,10 @@ export const selectFilteredFolders = createSelector(
);

export const selectLastConversation = createSelector(
[selectConversations],
(conversations): ConversationInfo | undefined => {
if (!conversations.length) return undefined;
return sortByDateAndName([...conversations])[0];
[selectNotExternalConversations],
(ownConversations): ConversationInfo | undefined => {
if (!ownConversations.length) return undefined;
return sortByDateAndName(ownConversations)[0];
},
);
export const selectConversation = createSelector(
Expand Down

0 comments on commit 9ea9ebe

Please sign in to comment.