Skip to content

Commit

Permalink
fix(chat): fix initialization of recent models (Issue #2881) (#2897)
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyaBondar authored Jan 3, 2025
1 parent c467fe8 commit 2b64409
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
15 changes: 13 additions & 2 deletions apps/chat-e2e/src/tests/overlay/modelIdFeature.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { GeneratorUtil, ModelsUtil } from '@/src/utils';
import { expect } from '@playwright/test';

const expectedModelId = 'gpt-4';
const fallbackModelId = 'gpt-35-turbo';

dialOverlayTest(
`[Overlay] Defaults set in the code: modelID is used for new conversation.\n` +
Expand All @@ -25,12 +26,22 @@ dialOverlayTest(
overlayAgentInfoAssertion,
talkToAgentDialogAssertion,
setTestIds,
localStorageManager,
}) => {
setTestIds('EPMRTC-3781', 'EPMRTC-4693');
const randomAgentRequest = 'test';
const randomModelId = GeneratorUtil.randomArrayElement(
ModelsUtil.getRecentModelIds().filter((m) => m !== expectedModelId),
const recentModelIds = ModelsUtil.getRecentModelIds().filter(
(m) => m !== expectedModelId,
);
if (!recentModelIds.length) {
// recentModelIds can be empty
await localStorageManager.setRecentModelsIds(
ModelsUtil.getModel(fallbackModelId)!,
);
}
const randomModelId = recentModelIds.length
? GeneratorUtil.randomArrayElement(recentModelIds)
: fallbackModelId;
const randomModel = ModelsUtil.getOpenAIEntity(randomModelId)!;

const expectedModel = ModelsUtil.getModel(expectedModelId)!;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export const AddonsDialog: FC<Props> = ({
dataQa="addons-dialog"
portalId="chat"
onClose={onClose}
overlayClassName="fixed inset-0 top-[48px] !items-start"
overlayClassName="fixed inset-0 top-[48px]"
state={isOpen ? ModalState.OPENED : ModalState.CLOSED}
hideClose
containerClassName="flex h-fit max-h-full h-[700px] w-full grow justify-between flex-col gap-4 divide-tertiary py-4 md:grow-0 xl:max-w-[720px] 2xl:max-w-[780px]"
Expand Down
2 changes: 1 addition & 1 deletion apps/chat/src/store/models/models.reducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export const modelsSlice = createSlice({
({ id }) => id === payload.defaultModelId,
);

if (payload.localStorageRecentModelsIds?.length) {
if (payload.localStorageRecentModelsIds) {
state.recentModelsIds = payload.localStorageRecentModelsIds;
} else if (payload.defaultRecentModelsIds.length) {
state.recentModelsIds = payload.defaultRecentModelsIds;
Expand Down

0 comments on commit 2b64409

Please sign in to comment.