Skip to content

Commit

Permalink
feat(chat): token limit listing (Issue epam#239, epam#525, epam#782, e…
Browse files Browse the repository at this point in the history
  • Loading branch information
mikitabut authored Mar 4, 2024
1 parent 4427a83 commit b4cd64c
Show file tree
Hide file tree
Showing 99 changed files with 1,031 additions and 978 deletions.
4 changes: 2 additions & 2 deletions apps/chat-e2e/src/testData/api/iconApiHelper.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { OpenAIEntityModel } from '@/chat/types/openai';
import { DialAIEntityModel } from '@/chat/types/models';
import { API } from '@/src/testData';
import { BaseApiHelper } from '@/src/testData/api/baseApiHelper';
import { Tags } from '@/src/ui/domData';
Expand All @@ -9,7 +9,7 @@ export class IconApiHelper extends BaseApiHelper {
return this.formatIconResponse(response.text());
}

public async getEntityIcon(entity: OpenAIEntityModel) {
public async getEntityIcon(entity: DialAIEntityModel) {
let icon;
if (entity.iconUrl && entity.iconUrl.includes(Tags.svg)) {
const response = await this.request.get(entity.iconUrl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
DEFAULT_CONVERSATION_NAME,
DEFAULT_SYSTEM_PROMPT,
DEFAULT_TEMPERATURE,
} from '@/chat/constants/default-settings';
} from '@/chat/constants/default-ui-settings';
import { defaultReplay } from '@/chat/constants/replay';
import {
Conversation,
Expand Down
57 changes: 39 additions & 18 deletions apps/chat-e2e/src/testData/conversationHistory/conversationData.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defaultReplay } from '@/chat/constants/replay';
import { Message, Role, Stage } from '@/chat/types/chat';
import { Message, MessageSettings, Role, Stage } from '@/chat/types/chat';
import { FolderType } from '@/chat/types/folder';
import { OpenAIEntityModel } from '@/chat/types/openai';
import { DialAIEntityModel } from '@/chat/types/models';
import {
ConversationBuilder,
ExpectedConstants,
Expand Down Expand Up @@ -35,7 +35,7 @@ export class ConversationData extends FolderData {
}

public prepareDefaultConversation(
model?: OpenAIEntityModel | string,
model?: DialAIEntityModel | string,
name?: string,
) {
const modelToUse = model
Expand Down Expand Up @@ -63,9 +63,17 @@ export class ConversationData extends FolderData {
temp: number,
sysPrompt: string,
addons: string[],
model?: OpenAIEntityModel | string,
model?: DialAIEntityModel | string,
) {
const basicConversation = this.prepareDefaultConversation(model);
const messageSettings: MessageSettings = {
prompt: sysPrompt,
temperature: temp,
selectedAddons: addons,
};
basicConversation.messages.forEach(
(message) => (message.settings = messageSettings),
);
this.conversationBuilder.setConversation(basicConversation);
return this.conversationBuilder
.withTemperature(temp)
Expand All @@ -75,7 +83,7 @@ export class ConversationData extends FolderData {
}

public prepareModelConversationBasedOnRequests(
model: OpenAIEntityModel | string,
model: DialAIEntityModel | string,
requests: string[],
name?: string,
) {
Expand All @@ -96,7 +104,7 @@ export class ConversationData extends FolderData {
return this.conversationBuilder.build();
}

public prepareConversationWithDifferentModels(models: OpenAIEntityModel[]) {
public prepareConversationWithDifferentModels(models: DialAIEntityModel[]) {
const requests: string[] = new Array(models.length);
for (let i = 0; i < requests.length; i++) {
requests[i] = `${i} + ${i + 1} =`;
Expand All @@ -115,7 +123,7 @@ export class ConversationData extends FolderData {
}

public prepareEmptyConversation(
model?: OpenAIEntityModel | string,
model?: DialAIEntityModel | string,
name?: string,
) {
const conversation = this.prepareDefaultConversation(model, name);
Expand All @@ -124,7 +132,7 @@ export class ConversationData extends FolderData {
}

public prepareErrorResponseConversation(
model?: OpenAIEntityModel,
model?: DialAIEntityModel,
name?: string,
) {
const defaultConversation = this.prepareDefaultConversation(model, name);
Expand Down Expand Up @@ -173,16 +181,23 @@ export class ConversationData extends FolderData {
}

public prepareAddonsConversation(
model: OpenAIEntityModel,
model: DialAIEntityModel,
addons: string[],
request?: string,
) {
const conversation = this.conversationBuilder.getConversation();
conversation.model = { id: model.id };
conversation.selectedAddons = addons;
const messageSettings: MessageSettings = {
prompt: conversation.prompt,
temperature: conversation.temperature,
selectedAddons: addons,
};
const userMessage: Message = {
role: Role.User,
content: request ?? 'what is epam? what is epam revenue in 2020?',
model: { id: conversation.model.id },
settings: messageSettings,
};
const assistantMessage: Message = {
role: Role.Assistant,
Expand All @@ -208,20 +223,25 @@ export class ConversationData extends FolderData {
invocations: [{ index: 0, request: 'request', response: 'response' }],
},
},
settings: messageSettings,
};
conversation.messages.push(userMessage, assistantMessage);
return this.conversationBuilder.build();
}

public prepareAssistantConversation(
assistant: OpenAIEntityModel,
assistant: DialAIEntityModel,
addons: string[],
assistantModel?: OpenAIEntityModel,
assistantModel?: DialAIEntityModel,
) {
const conversation = this.prepareAddonsConversation(assistant, addons);
conversation.assistantModelId = assistantModel
? assistantModel.id
: ModelIds.GPT_4;
conversation.messages.forEach(
(message) =>
(message.settings!.assistantModelId = conversation.assistantModelId),
);
return conversation;
}

Expand Down Expand Up @@ -255,7 +275,7 @@ export class ConversationData extends FolderData {
}

public prepareDefaultConversationInFolder(
model?: OpenAIEntityModel,
model?: DialAIEntityModel,
name?: string,
): FolderConversation {
const conversation = this.prepareDefaultConversation(model, name);
Expand All @@ -265,30 +285,30 @@ export class ConversationData extends FolderData {
}

public prepareYesterdayConversation(
model?: OpenAIEntityModel,
model?: DialAIEntityModel,
name?: string,
) {
const conversation = this.prepareDefaultConversation(model, name);
conversation.lastActivityDate = DateUtil.getYesterdayDate();
return conversation;
}

public prepareLastWeekConversation(model?: OpenAIEntityModel, name?: string) {
public prepareLastWeekConversation(model?: DialAIEntityModel, name?: string) {
const conversation = this.prepareDefaultConversation(model, name);
conversation.lastActivityDate = DateUtil.getLastWeekDate();
return conversation;
}

public prepareLastMonthConversation(
model?: OpenAIEntityModel,
model?: DialAIEntityModel,
name?: string,
) {
const conversation = this.prepareDefaultConversation(model, name);
conversation.lastActivityDate = DateUtil.getLastMonthDate();
return conversation;
}

public prepareOlderConversation(model?: OpenAIEntityModel, name?: string) {
public prepareOlderConversation(model?: DialAIEntityModel, name?: string) {
const conversation = this.prepareDefaultConversation(model, name);
conversation.lastActivityDate = DateUtil.getOlderDate();
return conversation;
Expand Down Expand Up @@ -324,7 +344,7 @@ export class ConversationData extends FolderData {

public prepareConversationWithAttachmentInRequest(
attachmentUrl: string,
model: OpenAIEntityModel | string,
model: DialAIEntityModel | string,
hasRequest?: boolean,
) {
const filename = FileApiHelper.extractFilename(attachmentUrl);
Expand All @@ -341,6 +361,7 @@ export class ConversationData extends FolderData {
},
],
},
model: modelToUse,
};
const assistantMessage: Message = {
role: Role.Assistant,
Expand All @@ -357,7 +378,7 @@ export class ConversationData extends FolderData {

public prepareConversationWithAttachmentInResponse(
attachmentUrl: string,
model: OpenAIEntityModel | string,
model: DialAIEntityModel | string,
) {
const filename = FileApiHelper.extractFilename(attachmentUrl);
const modelToUse = { id: typeof model === 'string' ? model : model.id };
Expand Down
2 changes: 1 addition & 1 deletion apps/chat-e2e/src/tests/announcementBanner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ dialTest(
);
const bannerIcon = await banner.bannerIcon;
expect
.soft(bannerIcon.length > 0, ExpectedMessages.entityIconIsValid)
.soft(bannerIcon.isVisible(), ExpectedMessages.entityIconIsValid)
.toBeTruthy();

chatBarBounding = await chatBar.getElementBoundingBox();
Expand Down
32 changes: 12 additions & 20 deletions apps/chat-e2e/src/tests/chatBarConversation.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { OpenAIEntityModel } from '@/chat/types/openai';
import { DialAIEntityModel } from '@/chat/types/models';
import dialTest from '@/src/core/dialFixtures';
import { isApiStorageType } from '@/src/hooks/global-setup';
import {
Expand All @@ -15,9 +15,9 @@ import { GeneratorUtil } from '@/src/utils';
import { ModelsUtil } from '@/src/utils/modelsUtil';
import { expect } from '@playwright/test';

let gpt35Model: OpenAIEntityModel;
let gpt4Model: OpenAIEntityModel;
let bisonModel: OpenAIEntityModel;
let gpt35Model: DialAIEntityModel;
let gpt4Model: DialAIEntityModel;
let bisonModel: DialAIEntityModel;

const request = 'What is epam official name';
const notMatchingSearchTerm = 'abc';
Expand Down Expand Up @@ -370,15 +370,12 @@ dialTest(
);
await conversationDropdownMenu.selectMenuOption(MenuOptions.delete);
await confirmationDialog.confirm({ triggeredHttpMethod: 'DELETE' });
expect
.soft(
await folderConversations.isFolderEntityVisible(
conversationInFolder.folders.name,
conversationInFolder.conversations[0].name,
),
ExpectedMessages.folderConversationDeleted,
await folderConversations
.getFolderEntity(
conversationInFolder.folders.name,
conversationInFolder.conversations[0].name,
)
.toBeFalsy();
.waitFor({ state: 'hidden' });
},
);

Expand All @@ -404,14 +401,9 @@ dialTest(
await conversations.openConversationDropdownMenu(conversation.name);
await conversationDropdownMenu.selectMenuOption(MenuOptions.delete);
await confirmationDialog.confirm({ triggeredHttpMethod: 'DELETE' });
expect
.soft(
await conversations
.getConversationByName(conversation.name)
.isVisible(),
ExpectedMessages.conversationDeleted,
)
.toBeFalsy();
await conversations
.getConversationByName(conversation.name)
.waitFor({ state: 'hidden' });
},
);

Expand Down
6 changes: 3 additions & 3 deletions apps/chat-e2e/src/tests/chatExportImport.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { OpenAIEntityModel } from '@/chat/types/openai';
import { DialAIEntityModel } from '@/chat/types/models';
import dialTest from '@/src/core/dialFixtures';
import { isApiStorageType } from '@/src/hooks/global-setup';
import {
Expand Down Expand Up @@ -26,8 +26,8 @@ let newFolderConversationData: UploadDownloadData;
let threeConversationsData: UploadDownloadData;
const exportedConversations: UploadDownloadData[] = [];
const updatedExportedConversations: UploadDownloadData[] = [];
let gpt35Model: OpenAIEntityModel;
let gpt4Model: OpenAIEntityModel;
let gpt35Model: DialAIEntityModel;
let gpt4Model: DialAIEntityModel;

dialTest.beforeAll(async () => {
gpt35Model = ModelsUtil.getDefaultModel()!;
Expand Down
8 changes: 4 additions & 4 deletions apps/chat-e2e/src/tests/chatHeader.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { OpenAIEntityModel } from '@/chat/types/openai';
import { DialAIEntityModel } from '@/chat/types/models';
import dialTest from '@/src/core/dialFixtures';
import { ExpectedMessages, TestConversation } from '@/src/testData';
import { ModelsUtil } from '@/src/utils';
import { expect } from '@playwright/test';

let allAddons: OpenAIEntityModel[];
let allAddons: DialAIEntityModel[];
let addonIds: string[];
let defaultModel: OpenAIEntityModel;
let defaultModel: DialAIEntityModel;

dialTest.beforeAll(async () => {
allAddons = ModelsUtil.getAddons();
Expand Down Expand Up @@ -116,7 +116,7 @@ dialTest(
'Hover over chat header and verify chat settings are correct on tooltip',
async () => {
await errorPopup.cancelPopup();
await chatHeader.hoverOverChatModel(defaultModel.iconUrl);
await chatHeader.hoverOverChatModel();
const modelInfo = await chatInfoTooltip.getModelInfo();
expect
.soft(modelInfo, ExpectedMessages.chatInfoModelIsValid)
Expand Down
4 changes: 2 additions & 2 deletions apps/chat-e2e/src/tests/chatHeaderSettings.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { OpenAIEntityModel } from '@/chat/types/openai';
import { DialAIEntityModel } from '@/chat/types/models';
import dialTest from '@/src/core/dialFixtures';
import { ExpectedMessages, TestConversation } from '@/src/testData';
import { GeneratorUtil, ModelsUtil } from '@/src/utils';
import { expect } from '@playwright/test';

let defaultModel: OpenAIEntityModel;
let defaultModel: DialAIEntityModel;

dialTest.beforeAll(async () => {
defaultModel = ModelsUtil.getDefaultModel()!;
Expand Down
Loading

0 comments on commit b4cd64c

Please sign in to comment.