Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(chat): fix conversation requests during message generation (Issue #3031) #3032

Merged
merged 4 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class ConversationToCompare extends BaseElement {

public async selectCompareConversation(
name: string,
{ isHttpMethodTriggered = true }: { isHttpMethodTriggered?: boolean } = {},
{ isHttpMethodTriggered = false }: { isHttpMethodTriggered?: boolean } = {},
) {
if (isHttpMethodTriggered) {
const respPromise = this.page.waitForResponse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export class BaseSideBarConversationTree extends SideBarEntitiesTree {
public async selectConversation(
name: string,
indexOrOptions?: number | { exactMatch: boolean; index?: number },
{ isHttpMethodTriggered = true }: { isHttpMethodTriggered?: boolean } = {},
{ isHttpMethodTriggered = false }: { isHttpMethodTriggered?: boolean } = {},
) {
const conversationToSelect = this.getTreeEntity(name, indexOrOptions);
if (isApiStorageType && isHttpMethodTriggered) {
Expand Down
37 changes: 28 additions & 9 deletions apps/chat/src/store/conversations/conversations.epics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3092,6 +3092,10 @@ const updateLastConversationSettingsEpic: AppEpic = (action$, state$) =>
})),
switchMap(({ lastConversation }) =>
forkJoin({
oldTemperature: of((lastConversation as Conversation)?.temperature),
wasAlreadyUploaded: of(
lastConversation?.status === UploadStatus.LOADED,
),
lastConversation:
lastConversation &&
lastConversation.status !== UploadStatus.LOADED &&
Expand All @@ -3108,15 +3112,30 @@ const updateLastConversationSettingsEpic: AppEpic = (action$, state$) =>
: of(lastConversation as Conversation),
}),
),
switchMap(({ lastConversation }) => {
// don't save for temp empty conversation to be able to reset settings by "New conversation"
return lastConversation && !isEntityIdLocal(lastConversation)
? of(
ConversationsActions.setLastConversationSettings({
temperature: lastConversation.temperature,
}),
)
: EMPTY;
switchMap(({ lastConversation, oldTemperature, wasAlreadyUploaded }) => {
if (
!lastConversation ||
// don't save for temp empty conversation to be able to reset settings by "New conversation"
isEntityIdLocal(lastConversation) ||
// don't save if already uploaded and nothing changed
(wasAlreadyUploaded && oldTemperature === lastConversation.temperature)
) {
return EMPTY;
}

return concat(
of(
ConversationsActions.setLastConversationSettings({
temperature: lastConversation.temperature,
}),
),
of(
ConversationsActions.uploadConversationsByIdsSuccess({
setIds: new Set(lastConversation.id),
conversations: [lastConversation],
}),
),
);
}),
);

Expand Down
Loading