diff --git a/README.md b/README.md index fece23b60e..b39d128741 100644 --- a/README.md +++ b/README.md @@ -12,13 +12,13 @@ This repository is managed as monorepo by [NX](https://nx.dev/) tools. ## Docs -* `DIAL Chat` documentation placed [here](./apps/chat/README.md). -* `DIAL Chat Theming` documentation is placed [here](./docs/THEME-CUSTOMIZATION.md). -* `DIAL Overlay` documentation is placed [here](./libs/overlay/README.md). -* `DIAL Chat Visualizer Connector` documentation is placed [here](./libs/chat-visualizer-connector/README.md). -* `DIAL Visualizer Connector` documentation is placed [here](./libs/visualizer-connector/README.md). +- `DIAL Chat` documentation placed [here](./apps/chat/README.md). +- `DIAL Chat Theming` documentation is placed [here](./docs/THEME-CUSTOMIZATION.md). +- `DIAL Overlay` documentation is placed [here](./libs/overlay/README.md). +- `DIAL Chat Visualizer Connector` documentation is placed [here](./libs/chat-visualizer-connector/README.md). +- `DIAL Visualizer Connector` documentation is placed [here](./libs/visualizer-connector/README.md). -> In [AI DIAL repository](https://github.com/epam/ai-dial/blob/main/docs/user-guide.md), you can find a user guide for the AI DIAL Chat application. +> In [AI DIAL repository](https://github.com/epam/ai-dial/blob/main/docs/user-guide.md), you can find a user guide for the AI DIAL Chat application. ## Development diff --git a/apps/chat-e2e/src/assertions/agentInfoAssertion.ts b/apps/chat-e2e/src/assertions/agentInfoAssertion.ts new file mode 100644 index 0000000000..01c5553dec --- /dev/null +++ b/apps/chat-e2e/src/assertions/agentInfoAssertion.ts @@ -0,0 +1,27 @@ +import { BaseAssertion } from '@/src/assertions/baseAssertion'; +import { ExpectedMessages } from '@/src/testData'; +import { AgentInfo } from '@/src/ui/webElements'; +import { expect } from '@playwright/test'; + +export class AgentInfoAssertion extends BaseAssertion { + readonly agentInfo: AgentInfo; + + constructor(agentInfo: AgentInfo) { + super(); + this.agentInfo = agentInfo; + } + + public async assertAgentIcon(expectedIcon: string) { + await super.assertEntityIcon( + await this.agentInfo.getAgentIcon(), + expectedIcon, + ); + } + + public async assertDescription(expectedDescription?: string) { + const description = await this.agentInfo.getAgentDescription(); + expect + .soft(description, ExpectedMessages.agentDescriptionIsValid) + .toBe(expectedDescription ?? ''); + } +} diff --git a/apps/chat-e2e/src/assertions/index.ts b/apps/chat-e2e/src/assertions/index.ts index e68a2b4419..e1da92ebb3 100644 --- a/apps/chat-e2e/src/assertions/index.ts +++ b/apps/chat-e2e/src/assertions/index.ts @@ -34,7 +34,7 @@ export * from './manageAttachmentsAssertion'; export * from './selectFolderModalAssertion'; export * from './baseAssertion'; export * from './conversationInfoTooltipAssertion'; -export * from './isolatedViewAssertion'; +export * from './agentInfoAssertion'; export * from './addonsDialogAssertion'; export * from './marketplaceApplicationsAssertion'; export * from './conversationToCompareAssertion'; diff --git a/apps/chat-e2e/src/assertions/isolatedViewAssertion.ts b/apps/chat-e2e/src/assertions/isolatedViewAssertion.ts deleted file mode 100644 index e2c1fcbf85..0000000000 --- a/apps/chat-e2e/src/assertions/isolatedViewAssertion.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { BaseAssertion } from '@/src/assertions/baseAssertion'; -import { MoreInfo } from '@/src/ui/webElements'; - -export class IsolatedViewAssertion extends BaseAssertion { - readonly isolatedView: MoreInfo; - - constructor(isolatedView: MoreInfo) { - super(); - this.isolatedView = isolatedView; - } - - public async assertModelIcon(expectedIcon: string) { - await super.assertEntityIcon( - await this.isolatedView.getEntityIcon(), - expectedIcon, - ); - } -} diff --git a/apps/chat-e2e/src/core/dialFixtures.ts b/apps/chat-e2e/src/core/dialFixtures.ts index 395f62b2ee..87dbd71868 100644 --- a/apps/chat-e2e/src/core/dialFixtures.ts +++ b/apps/chat-e2e/src/core/dialFixtures.ts @@ -1,6 +1,7 @@ import config from '../../config/chat.playwright.config'; import { DialHomePage, MarketplacePage } from '../ui/pages'; import { + AgentInfo, AttachFilesModal, Chat, ChatBar, @@ -10,7 +11,6 @@ import { ConversationSettings, ConversationToCompare, EntitySelector, - MoreInfo, PromptBar, SelectFolderModal, SendMessage, @@ -18,6 +18,7 @@ import { import { AccountSettingsAssertion, + AgentInfoAssertion, ApiAssertion, ChatAssertion, ChatHeaderAssertion, @@ -31,7 +32,6 @@ import { ErrorToastAssertion, FolderAssertion, FooterAssertion, - IsolatedViewAssertion, MarketplaceApplicationsAssertion, MenuAssertion, PlaybackAssertion, @@ -169,7 +169,7 @@ const dialTest = test.extend< temperatureSlider: TemperatureSlider; addons: Addons; addonsDialog: AddonsDialog; - isolatedView: MoreInfo; + agentInfo: AgentInfo; conversationData: ConversationData; promptData: PromptData; conversationDropdownMenu: DropdownMenu; @@ -179,7 +179,6 @@ const dialTest = test.extend< promptModalDialog: PromptModalDialog; variableModalDialog: VariableModalDialog; chatHeader: ChatHeader; - moreInfo: MoreInfo; chatInfoTooltip: ChatInfoTooltip; compare: Compare; compareConversation: ConversationToCompare; @@ -267,7 +266,7 @@ const dialTest = test.extend< selectFoldersAssertion: FolderAssertion; selectFolderModalAssertion: SelectFolderModalAssertion; conversationInfoTooltipAssertion: ConversationInfoTooltipAssertion; - isolatedViewAssertion: IsolatedViewAssertion; + agentInfoAssertion: AgentInfoAssertion; addonsDialogAssertion: AddonsDialogAssertion; marketplaceApplicationsAssertion: MarketplaceApplicationsAssertion; conversationToCompareAssertion: ConversationToCompareAssertion; @@ -474,9 +473,9 @@ const dialTest = test.extend< const addonsDialog = addons.getAddonsDialog(); await use(addonsDialog); }, - isolatedView: async ({ chat }, use) => { - const isolatedView = chat.getIsolatedView(); - await use(isolatedView); + agentInfo: async ({ chat }, use) => { + const agentInfo = chat.getAgentInfo(); + await use(agentInfo); }, modelSelector: async ({ entitySettings }, use) => { const modelSelector = entitySettings.getModelSelector(); @@ -506,10 +505,6 @@ const dialTest = test.extend< const variableModalDialog = new VariableModalDialog(page); await use(variableModalDialog); }, - moreInfo: async ({ entitySettings }, use) => { - const moreInfo = entitySettings.getMoreInfo(); - await use(moreInfo); - }, chatHeader: async ({ chat }, use) => { const chatHeader = chat.getChatHeader(); await use(chatHeader); @@ -919,9 +914,9 @@ const dialTest = test.extend< new ConversationInfoTooltipAssertion(chatInfoTooltip); await use(conversationInfoTooltipAssertion); }, - isolatedViewAssertion: async ({ isolatedView }, use) => { - const isolatedViewAssertion = new IsolatedViewAssertion(isolatedView); - await use(isolatedViewAssertion); + agentInfoAssertion: async ({ agentInfo }, use) => { + const agentInfoAssertion = new AgentInfoAssertion(agentInfo); + await use(agentInfoAssertion); }, addonsDialogAssertion: async ({ addonsDialog }, use) => { const addonsDialogAssertion = new AddonsDialogAssertion(addonsDialog); diff --git a/apps/chat-e2e/src/core/dialOverlayFixtures.ts b/apps/chat-e2e/src/core/dialOverlayFixtures.ts index dec497d711..d8381a2d53 100644 --- a/apps/chat-e2e/src/core/dialOverlayFixtures.ts +++ b/apps/chat-e2e/src/core/dialOverlayFixtures.ts @@ -1,4 +1,5 @@ import { + AgentInfo, Chat, ChatHeader, ChatMessages, @@ -7,7 +8,9 @@ import { } from '../ui/webElements'; import { + AgentInfoAssertion, ApiAssertion, + BaseAssertion, ChatHeaderAssertion, ChatMessagesAssertion, EntitySettingAssertion, @@ -30,6 +33,7 @@ const dialOverlayTest = base.extend<{ overlayHomePage: OverlayHomePage; overlayContainer: AppContainer; overlayChat: Chat; + overlayAgentInfo: AgentInfo; overlayHeader: Header; overlayChatHeader: ChatHeader; overlayChatMessages: ChatMessages; @@ -39,6 +43,8 @@ const dialOverlayTest = base.extend<{ overlayIconApiHelper: IconApiHelper; overlayApiInjector: ApiInjector; overlayDataInjector: DataInjectorInterface; + overlayBaseAssertion: BaseAssertion; + overlayAgentInfoAssertion: AgentInfoAssertion; overlayChatHeaderAssertion: ChatHeaderAssertion; overlayChatMessagesAssertion: ChatMessagesAssertion; overlayApiAssertion: ApiAssertion; @@ -68,6 +74,10 @@ const dialOverlayTest = base.extend<{ const overlayChat = overlayContainer.getChat(); await use(overlayChat); }, + overlayAgentInfo: async ({ overlayChat }, use) => { + const overlayAgentInfo = overlayChat.getAgentInfo(); + await use(overlayAgentInfo); + }, overlayHeader: async ({ overlayContainer }, use) => { const overlayHeader = overlayContainer.getHeader(); await use(overlayHeader); @@ -105,6 +115,15 @@ const dialOverlayTest = base.extend<{ overlayDataInjector: async ({ overlayApiInjector }, use) => { await use(overlayApiInjector); }, + // eslint-disable-next-line no-empty-pattern + overlayBaseAssertion: async ({}, use) => { + const baseAssertion = new BaseAssertion(); + await use(baseAssertion); + }, + overlayAgentInfoAssertion: async ({ overlayAgentInfo }, use) => { + const overlayAgentInfoAssertion = new AgentInfoAssertion(overlayAgentInfo); + await use(overlayAgentInfoAssertion); + }, overlayChatHeaderAssertion: async ({ overlayChatHeader }, use) => { const chatHeaderAssertion = new ChatHeaderAssertion(overlayChatHeader); await use(chatHeaderAssertion); diff --git a/apps/chat-e2e/src/testData/expectedConstants.ts b/apps/chat-e2e/src/testData/expectedConstants.ts index 1175d0036b..4242034180 100644 --- a/apps/chat-e2e/src/testData/expectedConstants.ts +++ b/apps/chat-e2e/src/testData/expectedConstants.ts @@ -76,7 +76,7 @@ export const ExpectedConstants = { backgroundAccentAttribute: 'bg-accent-primary-alpha', noResults: 'No results found', notAllowedModelError: - 'Not available model selected. Please, change the model to proceed', + 'Not available agent selected. Please, change the agent to proceed', replayAsIsDescr: 'This mode replicates user requests from the original conversation including settings set in each message.', replayOldVersionWarning: diff --git a/apps/chat-e2e/src/testData/expectedMessages.ts b/apps/chat-e2e/src/testData/expectedMessages.ts index c8e117a492..913574d3e0 100644 --- a/apps/chat-e2e/src/testData/expectedMessages.ts +++ b/apps/chat-e2e/src/testData/expectedMessages.ts @@ -77,7 +77,7 @@ export enum ExpectedMessages { infoAppIsValid = 'More info application is valid', infoAppDescriptionIsValid = 'More info application description is valid', entityHasDescription = 'Entity has description', - entityDescriptionIsValid = 'Entity description is valid', + agentDescriptionIsValid = 'Agent description is valid', entityDescriptionHasFullWidth = 'Entity description has full width', descriptionLinkIsBlue = 'Description link color is blue', descriptionLinkOpened = 'Description link is opened in a new window', diff --git a/apps/chat-e2e/src/tests/abortedReplay.test.ts b/apps/chat-e2e/src/tests/abortedReplay.test.ts index bddceaa076..08693cfcf6 100644 --- a/apps/chat-e2e/src/tests/abortedReplay.test.ts +++ b/apps/chat-e2e/src/tests/abortedReplay.test.ts @@ -162,7 +162,7 @@ dialTest( await dialTest.step( 'Apply model change and verify model icon is updated in the header, Replay icon stays on chat bar', async () => { - await chat.applyNewEntity(); + await chat.applyNewAgent(); await chatHeaderAssertion.assertHeaderIcon(expectedNewModelIcon); await conversationAssertion.assertReplayIconState( { @@ -362,7 +362,7 @@ dialTest( await dialTest.step( 'Continue generation with "Replay as is" option and verify model icons are updated on chat bar', async () => { - await chat.applyNewEntity(); + await chat.applyNewAgent(); await dialHomePage.mockChatTextResponse( MockedChatApiResponseBodies.simpleTextBody, ); diff --git a/apps/chat-e2e/src/tests/chatBarConversation.test.ts b/apps/chat-e2e/src/tests/chatBarConversation.test.ts index 81f8eac4c4..b1f6963ad3 100644 --- a/apps/chat-e2e/src/tests/chatBarConversation.test.ts +++ b/apps/chat-e2e/src/tests/chatBarConversation.test.ts @@ -860,9 +860,8 @@ dialTest( folderPrompts, prompts, promptBar, - talkToSelector, - entitySettings, - baseAssertion, + agentInfoAssertion, + agentInfo, setTestIds, }) => { setTestIds('EPMRTC-611'); @@ -968,8 +967,10 @@ dialTest( .isVisible(); if (!isOrganisationVisible && !isSharedWithMeVisible) { - await baseAssertion.assertElementState(talkToSelector, 'visible'); - await baseAssertion.assertElementState(entitySettings, 'visible'); + await agentInfoAssertion.assertElementState( + agentInfo.getElementLocator(), + 'visible', + ); } if (i === 1) { diff --git a/apps/chat-e2e/src/tests/chatExportImport.test.ts b/apps/chat-e2e/src/tests/chatExportImport.test.ts index b9d68cc0be..5446fe3116 100644 --- a/apps/chat-e2e/src/tests/chatExportImport.test.ts +++ b/apps/chat-e2e/src/tests/chatExportImport.test.ts @@ -498,7 +498,7 @@ dialTest( conversationAssertion, chat, iconApiHelper, - conversationSettings, + agentInfo, }) => { dialTest.skip( [ @@ -601,7 +601,7 @@ dialTest( await conversations.selectConversation( ExpectedConstants.newConversationTitle, ); - await conversationSettings.waitForState(); + await agentInfo.waitForState(); await chat.sendRequestWithButton('1+1=', false); const todayConversations = await conversations.getTodayConversations(); expect diff --git a/apps/chat-e2e/src/tests/chatExportImportWithAttachment.test.ts b/apps/chat-e2e/src/tests/chatExportImportWithAttachment.test.ts index b0eedf8a3d..7d3fc8cfdf 100644 --- a/apps/chat-e2e/src/tests/chatExportImportWithAttachment.test.ts +++ b/apps/chat-e2e/src/tests/chatExportImportWithAttachment.test.ts @@ -346,7 +346,7 @@ dialTest( simpleRequestModel, marketplacePage, ); - await chat.applyNewEntity(); + await chat.applyNewAgent(); await chat.sendRequestWithButton('1+2='); const messagesCount = await chatMessages.chatMessages.getElementsCount(); @@ -370,7 +370,8 @@ dialTest( conversationDropdownMenu, chatBar, confirmationDialog, - recentEntitiesAssertion, + agentInfo, + agentInfoAssertion, chatMessages, chat, playbackAssertion, @@ -455,7 +456,7 @@ dialTest( { name: playbackConversation.name }, 'visible', ); - await recentEntitiesAssertion.assertPlaybackIconState('visible'); + await agentInfoAssertion.assertElementState(agentInfo, 'visible'); }, ); diff --git a/apps/chat-e2e/src/tests/chatHeader.test.ts b/apps/chat-e2e/src/tests/chatHeader.test.ts index 154ac66111..e735fa2f8b 100644 --- a/apps/chat-e2e/src/tests/chatHeader.test.ts +++ b/apps/chat-e2e/src/tests/chatHeader.test.ts @@ -173,8 +173,9 @@ dialTest( conversationData, dataInjector, chatHeader, - conversationSettings, confirmationDialog, + agentInfoAssertion, + agentInfo, conversations, }) => { setTestIds('EPMRTC-490', 'EPMRTC-491'); @@ -209,13 +210,7 @@ dialTest( async () => { await chatHeader.clearConversation.click(); await confirmationDialog.confirm({ triggeredHttpMethod: 'PUT' }); - - await expect - .soft( - conversationSettings.getElementLocator(), - ExpectedMessages.conversationSettingsVisible, - ) - .toBeVisible(); + await agentInfoAssertion.assertElementState(agentInfo, 'visible'); }, ); }, diff --git a/apps/chat-e2e/src/tests/compareMode.test.ts b/apps/chat-e2e/src/tests/compareMode.test.ts index be8c122e48..41f03b0e44 100644 --- a/apps/chat-e2e/src/tests/compareMode.test.ts +++ b/apps/chat-e2e/src/tests/compareMode.test.ts @@ -837,7 +837,7 @@ dialTest( await rightEntitySettings .getTemperatureSlider() .setTemperature(secondUpdatedTemp); - await chat.applyNewEntity(); + await chat.applyNewAgent(); }, ); diff --git a/apps/chat-e2e/src/tests/conversationWithAttachment.test.ts b/apps/chat-e2e/src/tests/conversationWithAttachment.test.ts index b3305ccba3..c458b01825 100644 --- a/apps/chat-e2e/src/tests/conversationWithAttachment.test.ts +++ b/apps/chat-e2e/src/tests/conversationWithAttachment.test.ts @@ -27,8 +27,6 @@ dialTest( 'Send button is available if to send an attachment without a text', async ({ dialHomePage, - talkToSelector, - marketplacePage, setTestIds, attachFilesModal, sendMessage, @@ -69,10 +67,6 @@ dialTest( async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await talkToSelector.selectEntity( - randomModelWithAttachment, - marketplacePage, - ); await expect .soft( sendMessage.attachmentMenuTrigger.getElementLocator(), @@ -167,8 +161,6 @@ dialTest( 'Chat is named automatically to user text if to send it with attachment', async ({ dialHomePage, - talkToSelector, - marketplacePage, setTestIds, attachFilesModal, sendMessage, @@ -195,10 +187,6 @@ dialTest( async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await talkToSelector.selectEntity( - randomModelWithAttachment, - marketplacePage, - ); await sendMessage.attachmentMenuTrigger.click(); await attachmentDropdownMenu.selectMenuOption( UploadMenuOptions.attachUploadedFiles, @@ -237,8 +225,6 @@ dialTest( 'Blue loading bar is shown while the file is being uploaded to the message box', async ({ dialHomePage, - talkToSelector, - marketplacePage, setTestIds, sendMessage, tooltip, @@ -258,10 +244,6 @@ dialTest( await localStorageManager.setRecentModelsIds(randomModelWithAttachment); await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await talkToSelector.selectEntity( - randomModelWithAttachment, - marketplacePage, - ); await sendMessage.attachmentMenuTrigger.click(); await dialHomePage.uploadData( { path: Attachment.sunImageName, dataType: 'upload' }, @@ -314,8 +296,6 @@ dialTest( 'Download attached file from user message', async ({ dialHomePage, - talkToSelector, - marketplacePage, setTestIds, attachFilesModal, sendMessage, @@ -349,10 +329,6 @@ dialTest( async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await talkToSelector.selectEntity( - randomModelWithAttachment, - marketplacePage, - ); await sendMessage.attachmentMenuTrigger.click(); await attachmentDropdownMenu.selectMenuOption( UploadMenuOptions.attachUploadedFiles, @@ -488,8 +464,6 @@ dialTest( 'Error icon and red file name appear because of Network error while file is being uploaded', async ({ dialHomePage, - talkToSelector, - marketplacePage, setTestIds, sendMessage, uploadFromDeviceModal, @@ -509,10 +483,6 @@ dialTest( await localStorageManager.setRecentModelsIds(randomModelWithAttachment); await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await talkToSelector.selectEntity( - randomModelWithAttachment, - marketplacePage, - ); await sendMessage.attachmentMenuTrigger.click(); await dialHomePage.uploadData( { path: Attachment.sunImageName, dataType: 'upload' }, diff --git a/apps/chat-e2e/src/tests/conversationWithAttachmentInResponse.test.ts b/apps/chat-e2e/src/tests/conversationWithAttachmentInResponse.test.ts index 9765f43d5f..3577dbd17c 100644 --- a/apps/chat-e2e/src/tests/conversationWithAttachmentInResponse.test.ts +++ b/apps/chat-e2e/src/tests/conversationWithAttachmentInResponse.test.ts @@ -111,7 +111,7 @@ dialTest( async () => { await chatHeader.openConversationSettingsPopup(); await talkToSelector.selectEntity(updatedModel, marketplacePage); - await chat.applyNewEntity(); + await chat.applyNewAgent(); await dialHomePage.mockChatImageResponse( updatedModel.id, diff --git a/apps/chat-e2e/src/tests/defaultModelSettings.test.ts b/apps/chat-e2e/src/tests/defaultModelSettings.test.ts index 4a1be57762..799351bf1c 100644 --- a/apps/chat-e2e/src/tests/defaultModelSettings.test.ts +++ b/apps/chat-e2e/src/tests/defaultModelSettings.test.ts @@ -65,6 +65,7 @@ dialTest( async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); + await chat.configureSettingsButton.click(); await recentEntities.waitForState(); const modelBorderColors = await talkToEntities .getTalkToEntity(defaultModel) @@ -178,6 +179,7 @@ dialTest( await dialTest.step( 'Create new conversation and verify it is moved under Today section in chat bar, no clip icon is available in message textarea', async () => { + await chat.applyNewAgent(); const newConversationName = GeneratorUtil.randomString(7); await dialHomePage.mockChatTextResponse( MockedChatApiResponseBodies.simpleTextBody, @@ -213,7 +215,8 @@ dialTest( async ({ dialHomePage, header, - talkToSelector, + agentInfo, + agentInfoAssertion, chat, sendMessage, chatHeader, @@ -222,7 +225,6 @@ dialTest( page, talkToEntities, localStorageManager, - marketplacePage, setTestIds, }) => { setTestIds('EPMRTC-400', 'EPMRTC-474', 'EPMRTC-817', 'EPMRTC-1568'); @@ -233,8 +235,6 @@ dialTest( await localStorageManager.setRecentModelsIds(nonDefaultModel); await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await talkToSelector.selectEntity(nonDefaultModel, marketplacePage); - const isSendMessageBtnEnabled = await sendMessage.sendMessageButton.isElementEnabled(); expect @@ -317,6 +317,11 @@ dialTest( 'Create new conversation and verify previous model is preselected and highlighted', async () => { await header.createNewConversation(); + await agentInfoAssertion.assertElementText( + agentInfo.agentName, + nonDefaultModel.name, + ); + await chat.configureSettingsButton.click(); const modelBorderColors = await talkToEntities .getTalkToEntity(nonDefaultModel) .getAllBorderColors(); @@ -338,17 +343,16 @@ dialTest( ); dialTest( - 'Settings on default screen are saved in local storage when temperature = 0', + 'Settings on default screen are not saved in local storage when temperature = 0', async ({ dialHomePage, recentEntities, entitySettings, temperatureSlider, setTestIds, - talkToSelector, - marketplacePage, talkToEntities, addons, + chat, localStorageManager, }) => { setTestIds('EPMRTC-406'); @@ -358,7 +362,7 @@ dialTest( await localStorageManager.setRecentModelsIds(randomModel); await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await talkToSelector.selectEntity(randomModel, marketplacePage); + await chat.configureSettingsButton.click(); const sysPrompt = 'test prompt'; const temp = 0; const isSysPromptAllowed = !modelsWithoutSystemPrompt.includes( @@ -368,9 +372,11 @@ dialTest( await entitySettings.setSystemPrompt(sysPrompt); } await temperatureSlider.setTemperature(temp); + await chat.applyNewAgent(); + await dialHomePage.reloadPage(); await dialHomePage.waitForPageLoaded(); - + await chat.configureSettingsButton.click(); await recentEntities.waitForState(); const modelBorderColors = await talkToEntities .getTalkToEntity(defaultModel) @@ -408,6 +414,8 @@ dialTest( talkToSelector, marketplacePage, talkToEntities, + agentInfoAssertion, + agentInfo, setTestIds, }) => { setTestIds('EPMRTC-1044'); @@ -415,12 +423,19 @@ dialTest( iconsToBeLoaded: [defaultModel.iconUrl], }); await dialHomePage.waitForPageLoaded(); + await chat.configureSettingsButton.click(); await talkToSelector.selectEntity(nonDefaultModel, marketplacePage); + await chat.applyNewAgent(); await dialHomePage.mockChatTextResponse( MockedChatApiResponseBodies.simpleTextBody, ); await chat.sendRequestWithButton('test message'); await header.createNewConversation(); + await agentInfoAssertion.assertElementText( + agentInfo.agentName, + nonDefaultModel.name, + ); + await chat.configureSettingsButton.click(); const modelBorderColors = await talkToEntities .getTalkToEntity(nonDefaultModel) .getAllBorderColors(); @@ -448,6 +463,7 @@ dialTest( marketplaceFilter, marketplaceApplications, marketplaceHeader, + chat, setTestIds, }) => { setTestIds('EPMRTC-408'); @@ -482,6 +498,7 @@ dialTest( async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); + await chat.configureSettingsButton.click(); await talkToSelector.searchOnMyAppButton(); await marketplaceSidebar.homePageButton.click(); }, diff --git a/apps/chat-e2e/src/tests/editConversationWithAttachment.test.ts b/apps/chat-e2e/src/tests/editConversationWithAttachment.test.ts index 87a36af05e..2263f4a8df 100644 --- a/apps/chat-e2e/src/tests/editConversationWithAttachment.test.ts +++ b/apps/chat-e2e/src/tests/editConversationWithAttachment.test.ts @@ -66,7 +66,7 @@ dialTest( ModelsUtil.getDefaultModel()!, marketplacePage, ); - await chat.applyNewEntity(); + await chat.applyNewAgent(); }, ); @@ -92,8 +92,6 @@ dialTest( 'Delete attachment on x from message box', async ({ dialHomePage, - talkToSelector, - marketplacePage, setTestIds, attachFilesModal, sendMessage, @@ -132,10 +130,6 @@ dialTest( async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await talkToSelector.selectEntity( - randomModelWithAttachment, - marketplacePage, - ); await sendMessage.attachmentMenuTrigger.click(); await attachmentDropdownMenu.selectMenuOption( UploadMenuOptions.attachUploadedFiles, diff --git a/apps/chat-e2e/src/tests/entityIcon.test.ts b/apps/chat-e2e/src/tests/entityIcon.test.ts index 2d1bf76253..7483bbf198 100644 --- a/apps/chat-e2e/src/tests/entityIcon.test.ts +++ b/apps/chat-e2e/src/tests/entityIcon.test.ts @@ -26,6 +26,7 @@ dialTest( marketplaceApplications, addonsDialogAssertion, marketplaceApplicationsAssertion, + chat, setTestIds, }) => { dialTest.slow(); @@ -49,6 +50,7 @@ dialTest( iconsToBeLoaded: [defaultModel.iconUrl], }); await dialHomePage.waitForPageLoaded(); + await chat.configureSettingsButton.click(); await talkToSelector.searchOnMyAppButton(); await marketplaceSidebar.homePageButton.click(); }, @@ -74,6 +76,7 @@ dialTest( 'Click "See all addons" and verify all addons have valid icons', async () => { await header.backToChatButton.click(); + await chat.configureSettingsButton.click(); const expectedAddons = ModelsUtil.getAddons(); await addons.seeAllAddons(); const actualAddonsIcons = await addonsDialog.getAddonsIcons(); @@ -109,8 +112,6 @@ dialTest( conversationData, dataInjector, localStorageManager, - talkToSelector, - marketplacePage, conversations, }) => { dialTest.skip(simpleRequestModel === undefined, noSimpleModelSkipReason); @@ -127,7 +128,6 @@ dialTest( await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); await conversations.selectConversation(conversation.name); - await talkToSelector.selectEntity(simpleRequestModel!, marketplacePage); await dialHomePage.throttleAPIResponse(API.chatHost); await chat.sendRequestWithButton('write down 15 adjectives', false); }, diff --git a/apps/chat-e2e/src/tests/isolatedView.test.ts b/apps/chat-e2e/src/tests/isolatedView.test.ts index b13fc8d728..f4e8ccf62d 100644 --- a/apps/chat-e2e/src/tests/isolatedView.test.ts +++ b/apps/chat-e2e/src/tests/isolatedView.test.ts @@ -15,7 +15,7 @@ dialTest( 'Isolated view: available features in conversation', async ({ dialHomePage, - isolatedView, + agentInfo, iconApiHelper, chat, chatBar, @@ -24,7 +24,7 @@ dialTest( chatMessages, chatInfoTooltip, conversationInfoTooltipAssertion, - isolatedViewAssertion, + agentInfoAssertion, localStorageManager, setTestIds, }) => { @@ -43,21 +43,20 @@ dialTest( await dialHomePage.navigateToUrl( ExpectedConstants.isolatedUrl(expectedModel.id), ); - await isolatedView.waitForState(); - const modelName = await isolatedView.getEntityName(); - expect - .soft(modelName, ExpectedMessages.entityNameIsValid) - .toBe(expectedModelName); + await agentInfoAssertion.assertElementText( + agentInfo.agentName, + expectedModelName, + ); - const modelDescription = await isolatedView.getEntityDescription(); + const modelDescription = await agentInfo.getAgentDescription(); //only short description is displayed for isolated models const expectedShortDescription = expectedModel.description?.split(/\s*\n\s*\n\s*/g)[0]; expect - .soft(modelDescription, ExpectedMessages.entityDescriptionIsValid) + .soft(modelDescription, ExpectedMessages.agentDescriptionIsValid) .toBe(expectedShortDescription); - await isolatedViewAssertion.assertModelIcon(expectedModelIcon); + await agentInfoAssertion.assertAgentIcon(expectedModelIcon); }, ); diff --git a/apps/chat-e2e/src/tests/modelSettings.test.ts b/apps/chat-e2e/src/tests/modelSettings.test.ts index b2a9dd378a..fb4bf2874a 100644 --- a/apps/chat-e2e/src/tests/modelSettings.test.ts +++ b/apps/chat-e2e/src/tests/modelSettings.test.ts @@ -27,6 +27,7 @@ dialTest( talkToSelector, marketplacePage, talkToEntities, + chat, localStorageManager, }) => { setTestIds('EPMRTC-1046'); @@ -35,17 +36,19 @@ dialTest( (m) => m.id !== defaultModel.id && m.features?.systemPrompt === true, ), ); - await localStorageManager.setRecentModelsIds(randomModel); + await localStorageManager.setRecentModelsIds(defaultModel, randomModel); await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await talkToSelector.selectEntity(randomModel, marketplacePage); - await talkToEntities.waitForTalkToEntitySelected(randomModel); - await entitySettings.setSystemPrompt(sysPrompt); + await chat.configureSettingsButton.click(); + await talkToEntities.waitForTalkToEntitySelected(defaultModel); + if (defaultModel.features?.systemPrompt) { + await entitySettings.setSystemPrompt(sysPrompt); + } await temperatureSlider.setTemperature(temp); const modelBorderColors = await talkToEntities - .getTalkToEntity(randomModel) + .getTalkToEntity(defaultModel) .getAllBorderColors(); Object.values(modelBorderColors).forEach((borders) => { borders.forEach((borderColor) => { @@ -55,10 +58,14 @@ dialTest( }); }); - const systemPromptVisible = await entitySettings.getSystemPrompt(); - expect - .soft(systemPromptVisible, ExpectedMessages.systemPromptIsValid) - .toBe(sysPrompt); + await talkToSelector.selectEntity(randomModel, marketplacePage); + + if (defaultModel.features?.systemPrompt) { + const systemPromptVisible = await entitySettings.getSystemPrompt(); + expect + .soft(systemPromptVisible, ExpectedMessages.systemPromptIsValid) + .toBe(sysPrompt); + } const temperature = await temperatureSlider.getTemperature(); expect @@ -74,7 +81,7 @@ dialTest( dialTest( 'System prompt contains combinations with :', - async ({ dialHomePage, entitySettings, setTestIds }) => { + async ({ dialHomePage, entitySettings, chat, setTestIds }) => { setTestIds('EPMRTC-1084'); const prompts = [ 'test:', @@ -85,6 +92,7 @@ dialTest( ]; await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); + await chat.configureSettingsButton.click(); for (const prompt of prompts) { await entitySettings.setSystemPrompt(prompt); const systemPrompt = await entitySettings.getSystemPrompt(); diff --git a/apps/chat-e2e/src/tests/overlay/overlay.test.ts b/apps/chat-e2e/src/tests/overlay/overlay.test.ts index acb05742a9..cbe2c58700 100644 --- a/apps/chat-e2e/src/tests/overlay/overlay.test.ts +++ b/apps/chat-e2e/src/tests/overlay/overlay.test.ts @@ -10,31 +10,44 @@ for (const overlayUrl of ['/cases/overlay', '/cases/overlay-manager']) { `Overlay test for url: "${overlayUrl}"`, async ({ overlayHomePage, - overlayContainer, + overlayAgentInfo, overlayChat, overlayHeader, overlayChatHeader, + overlayConversationSettings, overlayEntitySettings, overlayIconApiHelper, + overlayBaseAssertion, overlayChatHeaderAssertion, overlayApiAssertion, overlayChatMessagesAssertion, overlayEntitySettingAssertion, + overlayAgentInfoAssertion, }) => { const expectedModel = ModelsUtil.getModel(expectedModelId)!; const expectedModelIcon = overlayIconApiHelper.getEntityIcon(expectedModel); + const expectedShortDescription = + expectedModel.description?.split(/\s*\n\s*\n\s*/g)[0]; await overlayHomePage.navigateToUrl(overlayUrl); if (overlayUrl.includes('overlay-manager')) { await overlayHomePage.overlayChatIcon.click(); } - await expect - .soft( - overlayContainer.getConversationSettings().getElementLocator(), - ExpectedMessages.conversationSettingsVisible, - ) - .toBeVisible(); + await overlayBaseAssertion.assertElementState( + overlayAgentInfo, + 'visible', + ); + await overlayBaseAssertion.assertElementText( + overlayAgentInfo.agentName, + expectedModel.name, + ); + await overlayAgentInfoAssertion.assertDescription( + expectedShortDescription, + ); + await overlayAgentInfoAssertion.assertAgentIcon(expectedModelIcon); + + await overlayChat.configureSettingsButton.click(); await overlayEntitySettingAssertion.assertSystemPromptValue(''); const temperature = await overlayEntitySettings .getTemperatureSlider() @@ -67,6 +80,7 @@ for (const overlayUrl of ['/cases/overlay', '/cases/overlay-manager']) { expect .soft(overlayTheme, ExpectedMessages.applicationThemeIsValid) .toContain('light'); + await overlayConversationSettings.cancelButton.click(); const userRequest = '1+2'; const request = await overlayChat.sendRequestWithButton(userRequest); diff --git a/apps/chat-e2e/src/tests/parametrizedReplay.test.ts b/apps/chat-e2e/src/tests/parametrizedReplay.test.ts index 0582deea7a..2a7ab887b4 100644 --- a/apps/chat-e2e/src/tests/parametrizedReplay.test.ts +++ b/apps/chat-e2e/src/tests/parametrizedReplay.test.ts @@ -255,7 +255,9 @@ dialTest( await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); await conversations.selectConversation(replayConversation.name); + await chat.configureSettingsButton.click(); await talkToSelector.selectEntity(randomModel, marketplacePage); + await chat.applyNewAgent(); await chat.replay.click(); await variableModalAssertion.assertVariableModalState('visible'); await variableModalDialog.closeButton.click(); diff --git a/apps/chat-e2e/src/tests/playBack.test.ts b/apps/chat-e2e/src/tests/playBack.test.ts index e8ed443ab9..470f68c5e6 100644 --- a/apps/chat-e2e/src/tests/playBack.test.ts +++ b/apps/chat-e2e/src/tests/playBack.test.ts @@ -44,6 +44,8 @@ dialTest( iconApiHelper, dataInjector, chatHeaderAssertion, + conversationSettings, + agentInfo, }) => { setTestIds('EPMRTC-1417', 'EPMRTC-1418', 'EPMRTC-1422'); let theme: string; @@ -79,8 +81,8 @@ dialTest( await conversations.selectConversation(conversation.name); await conversations.openEntityDropdownMenu(conversation.name); await conversationDropdownMenu.selectMenuOption(MenuOptions.playback); - - await conversations.getEntityByName(playbackConversationName).waitFor(); + await agentInfo.waitForState(); + await chat.configureSettingsButton.click(); const expectedButtonBorderColor = theme === Theme.light @@ -95,6 +97,7 @@ dialTest( .toBe(expectedButtonBorderColor); }); }); + await conversationSettings.cancelButton.click(); const isPlaybackNextBtnEnabled = await playbackControl.playbackNextButton.isElementEnabled(); @@ -346,7 +349,7 @@ dialTest( .toBe(ExpectedConstants.emptyPlaybackMessage); await chat.playPreviousChatMessage(); - await recentEntities.waitForState(); + await agentInfo.waitForState(); await chatHeader.waitForState({ state: 'hidden' }); playbackMessage = await playbackControl .getPlaybackMessage() @@ -356,7 +359,7 @@ dialTest( .toBe(conversation.messages[0].content); await chat.playPreviousChatMessage(); - await recentEntities.waitForState(); + await agentInfo.waitForState(); playbackMessage = await playbackControl .getPlaybackMessage() .getPlaybackMessageContent(); @@ -406,7 +409,7 @@ dialTest( chatMessages, page, chatHeader, - talkToSelector, + agentInfo, setTestIds, }) => { setTestIds('EPMRTC-1420', 'EPMRTC-1421'); @@ -596,7 +599,7 @@ dialTest( } } - await talkToSelector.waitForState(); + await agentInfo.waitForState(); const isPlaybackNextBtnEnabled = await playbackControl.playbackNextButton.isElementEnabled(); const isPlaybackPreviousBtnEnabled = diff --git a/apps/chat-e2e/src/tests/promptExportImport.test.ts b/apps/chat-e2e/src/tests/promptExportImport.test.ts index 5e0d300959..ef57bc5317 100644 --- a/apps/chat-e2e/src/tests/promptExportImport.test.ts +++ b/apps/chat-e2e/src/tests/promptExportImport.test.ts @@ -157,10 +157,12 @@ dialTest( async () => { const simpleRequestModel = ModelsUtil.getModelForSimpleRequest(); if (simpleRequestModel !== undefined) { + await chat.configureSettingsButton.click(); await talkToSelector.selectEntity( simpleRequestModel, marketplacePage, ); + await chat.applyNewAgent(); await chat.sendRequestWithPrompt(promptContent); await chat.sendRequestWithButton('white'); await chatMessagesAssertion.assertLastMessageContent('black'); diff --git a/apps/chat-e2e/src/tests/promptUsage.test.ts b/apps/chat-e2e/src/tests/promptUsage.test.ts index 4bb3611b39..24860a465b 100644 --- a/apps/chat-e2e/src/tests/promptUsage.test.ts +++ b/apps/chat-e2e/src/tests/promptUsage.test.ts @@ -491,6 +491,7 @@ dialTest( conversationData, dataInjector, entitySettings, + conversationSettings, variableModalAssertion, entitySettingAssertion, variableModalDialog, @@ -528,10 +529,11 @@ dialTest( await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); await conversations.selectConversation(conversation.name); + await chat.configureSettingsButton.click(); await entitySettings.setSystemPrompt('/'); const promptsList = entitySettings.getPromptList(); await promptsList.selectPromptWithKeyboard(prompt.name, { - triggeredHttpMethod: 'PUT', + triggeredHttpMethod: 'GET', }); await variableModalAssertion.assertVariableModalState('visible'); await variableModalAssertion.assertPromptVariableValue(aVar, ''); @@ -550,6 +552,7 @@ dialTest( await entitySettingAssertion.assertSystemPromptValue( promptTemplate(aVarValue, bVarDefaultValue), ); + await conversationSettings.cancelButton.click(); }, ); @@ -638,6 +641,7 @@ dialSharedWithMeTest( async () => { await additionalShareUserDialHomePage.openHomePage(); await additionalShareUserDialHomePage.waitForPageLoaded(); + await additionalShareUserChat.configureSettingsButton.click(); await additionalShareUserEntitySettings.setSystemPrompt('/'); await additionalShareUserSystemPromptListAssertion.assertPromptListOptions( [promptWithParams.name, promptInFolder.name], @@ -677,6 +681,7 @@ dialSharedWithMeTest( await additionalShareUserEntitySettingAssertion.assertSystemPromptValue( promptTemplate(promptParamValue) + promptInFolder.content, ); + await additionalShareUserChat.applyNewAgent(); }, ); diff --git a/apps/chat-e2e/src/tests/prompts.test.ts b/apps/chat-e2e/src/tests/prompts.test.ts index 43cf3256de..7835b9b0b6 100644 --- a/apps/chat-e2e/src/tests/prompts.test.ts +++ b/apps/chat-e2e/src/tests/prompts.test.ts @@ -19,7 +19,6 @@ dialTest( dialHomePage, promptBar, prompts, - conversationSettings, promptModalDialog, setTestIds, }) => { @@ -31,7 +30,6 @@ dialTest( async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); - await conversationSettings.waitForState(); await promptBar.hoverOverNewEntity(); const newPromptCursor = await promptBar.getNewEntityCursor(); expect diff --git a/apps/chat-e2e/src/tests/replay.test.ts b/apps/chat-e2e/src/tests/replay.test.ts index 36fb3b9ace..241f9de9fa 100644 --- a/apps/chat-e2e/src/tests/replay.test.ts +++ b/apps/chat-e2e/src/tests/replay.test.ts @@ -40,6 +40,7 @@ dialTest( dialHomePage, conversationData, chat, + agentInfo, dataInjector, conversations, setTestIds, @@ -107,7 +108,7 @@ dialTest( 'Verify new Replay conversation is created and Replay button appears', async () => { replayConversationName = `${ExpectedConstants.replayConversation}${replayConversation!.name}`; - await conversations.getEntityByName(replayConversationName).waitFor(); + await agentInfo.waitForState(); expect .soft( await chat.replay.getElementContent(), @@ -120,6 +121,7 @@ dialTest( await dialTest.step( 'Verify "Replay as is" option is selected', async () => { + await chat.configureSettingsButton.click(); const modelBorderColors = await recentEntities.replayAsIsButton.getAllBorderColors(); Object.values(modelBorderColors).forEach((borders) => { @@ -156,6 +158,7 @@ dialTest( expect .soft(newModelSelectedAddons, ExpectedMessages.selectedAddonsValid) .toEqual([]); + await chat.applyNewAgent(); }, ); @@ -290,9 +293,11 @@ dialTest( }); await dialHomePage.waitForPageLoaded(); await conversations.selectConversation(replayConversation.name); + await chat.configureSettingsButton.click(); await talkToSelector.selectEntity(replayModel, marketplacePage); await entitySettings.setSystemPrompt(replayPrompt); await temperatureSlider.setTemperature(replayTemp); + await chat.applyNewAgent(); await dialHomePage.throttleAPIResponse(API.chatHost); replayRequest = await chat.startReplay(); }, @@ -730,7 +735,8 @@ dialTest( await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); await conversations.selectConversation(replayConversation.name); - await talkToSelector.waitForState({ state: 'attached' }); + //TODO: add conversation screen verification when fixed https://github.com/epam/ai-dial-chat/issues/2697 + await chat.configureSettingsButton.click(); await chatAssertion.assertReplayButtonState('hidden'); await chatAssertion.assertNotAllowedModelLabelContent(); }, @@ -756,6 +762,7 @@ dialTest( 'Select any available model and start replaying', async () => { await talkToSelector.selectEntity(defaultModel, marketplacePage); + await chat.applyNewAgent(); const replayRequest = await chat.startReplay(); await apiAssertion.assertRequestModelId(replayRequest, defaultModel); }, @@ -772,6 +779,7 @@ dialTest( setTestIds, folderConversations, conversationDropdownMenu, + agentInfo, chat, chatHeader, talkToSelector, @@ -828,7 +836,7 @@ dialTest( const newModel = ModelsUtil.getModel(newModels[i - 1])!; await chatHeader.openConversationSettingsPopup(); await talkToSelector.selectEntity(newModel, marketplacePage); - await chat.applyNewEntity(); + await chat.applyNewAgent(); const newMessage = `${i}*2=`; await chat.sendRequestWithButton(newMessage); } @@ -843,6 +851,8 @@ dialTest( Import.oldVersionAppFolderChatName, ); await conversationDropdownMenu.selectMenuOption(MenuOptions.replay); + await agentInfo.waitForState(); + await chat.configureSettingsButton.click(); const replayAsIsDescr = await replayAsIs.replayAsIsDescr.getElementContent(); @@ -869,6 +879,7 @@ dialTest( expect .soft(warningColor[0], ExpectedMessages.warningLabelColorIsValid) .toBe(Colors.textError); + await chat.applyNewAgent(); }, ); diff --git a/apps/chat-e2e/src/tests/shareConversationWithContent.test.ts b/apps/chat-e2e/src/tests/shareConversationWithContent.test.ts index 086b1bd59f..efaf7906c9 100644 --- a/apps/chat-e2e/src/tests/shareConversationWithContent.test.ts +++ b/apps/chat-e2e/src/tests/shareConversationWithContent.test.ts @@ -644,6 +644,7 @@ dialSharedWithMeTest( additionalShareUserRecentEntities, additionalShareUserPlaybackControl, additionalShareUserSharedWithMeConversations, + additionalShareUserConversationSettings, additionalShareUserSharedWithMeConversationDropdownMenu, setTestIds, }) => { @@ -724,12 +725,14 @@ dialSharedWithMeTest( ExpectedMessages.chatBarConversationIconIsPlayback, ) .toBeVisible(); + await additionalShareUserChat.configureSettingsButton.click(); await expect .soft( additionalShareUserRecentEntities.playbackButton.getElementLocator(), ExpectedMessages.playbackIconIsSelected, ) .toBeVisible(); + await additionalShareUserConversationSettings.cancelButton.click(); await expect .soft( additionalShareUserPlaybackControl.playbackNextButton.getElementLocator(), diff --git a/apps/chat-e2e/src/tests/sharedChatIcons.test.ts b/apps/chat-e2e/src/tests/sharedChatIcons.test.ts index d3dadbb523..110423754a 100644 --- a/apps/chat-e2e/src/tests/sharedChatIcons.test.ts +++ b/apps/chat-e2e/src/tests/sharedChatIcons.test.ts @@ -380,7 +380,7 @@ dialTest( await entitySettings.setSystemPrompt(GeneratorUtil.randomString(5)); await temperatureSlider.setTemperature(0); await addons.selectAddon(randomAddon.name); - await chat.applyNewEntity(); + await chat.applyNewAgent(); await dialHomePage.mockChatTextResponse( MockedChatApiResponseBodies.simpleTextBody, ); @@ -429,7 +429,7 @@ dialTest( await conversations.selectConversation(thirdConversationToShare.name); await chatHeader.openConversationSettingsPopup(); await talkToSelector.selectEntity(randomModel, marketplacePage); - await chat.applyNewEntity(); + await chat.applyNewAgent(); await confirmationDialogAssertion.assertConfirmationDialogTitle( ExpectedConstants.sharedConversationModelChangeDialogTitle, ); diff --git a/apps/chat-e2e/src/tests/sharedFilesAttachments.test.ts b/apps/chat-e2e/src/tests/sharedFilesAttachments.test.ts index 6841c7a453..f344cb72ab 100644 --- a/apps/chat-e2e/src/tests/sharedFilesAttachments.test.ts +++ b/apps/chat-e2e/src/tests/sharedFilesAttachments.test.ts @@ -381,9 +381,7 @@ dialSharedWithMeTest( ), marketplacePage, ); - if (await talkToSelector.isVisible()) { - await chat.applyNewEntity(); - } + await chat.applyNewAgent(); break; case 'delete': await conversations.openEntityDropdownMenu( @@ -489,7 +487,6 @@ dialSharedWithMeTest( }, ); -//TODO: enable the test after implementing unique share users for each worker dialSharedWithMeTest( 'Shared with me: shared files located in "All folders" root appear in "Shared with me" root. The chat was shared.\n' + 'Shared with me: shared files located in folders appear in "Shared with me" root. The chat was shared.\n' + diff --git a/apps/chat-e2e/src/tests/workWithModels.test.ts b/apps/chat-e2e/src/tests/workWithModels.test.ts index 62366706d5..7a0c32f72a 100644 --- a/apps/chat-e2e/src/tests/workWithModels.test.ts +++ b/apps/chat-e2e/src/tests/workWithModels.test.ts @@ -350,8 +350,10 @@ dialTest( await localStorageManager.setRecentModelsIds(simpleRequestModel!); await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); + await chat.configureSettingsButton.click(); await talkToSelector.selectEntity(simpleRequestModel!, marketplacePage); await entitySettings.setSystemPrompt(promptContent); + await chat.applyNewAgent(); await chat.sendRequestWithButton(requestTerm); }, ); @@ -401,7 +403,9 @@ dialTest( async () => { await dialHomePage.openHomePage(); await dialHomePage.waitForPageLoaded(); + await chat.configureSettingsButton.click(); await talkToSelector.selectEntity(simpleRequestModel!, marketplacePage); + await chat.applyNewAgent(); await dialHomePage.throttleAPIResponse(API.chatHost); await chat.sendRequestWithButton(request, false); await sendMessage.stopGenerating.click(); @@ -614,6 +618,7 @@ dialTest( iconsToBeLoaded: [simpleRequestModel!.iconUrl], }); await dialHomePage.waitForPageLoaded(); + await chat.configureSettingsButton.click(); await entitySettings.setSystemPrompt('/'); const promptsList = entitySettings.getPromptList(); await systemPromptListAssertion.assertPromptOptionOverflow( @@ -628,6 +633,7 @@ dialTest( expect .soft(actualPrompt, ExpectedMessages.systemPromptValid) .toBe(prompt.content); + await chat.applyNewAgent(); }, ); diff --git a/apps/chat-e2e/src/ui/pages/dialHomePage.ts b/apps/chat-e2e/src/ui/pages/dialHomePage.ts index 1f8f99b9c7..cb1b02afbe 100644 --- a/apps/chat-e2e/src/ui/pages/dialHomePage.ts +++ b/apps/chat-e2e/src/ui/pages/dialHomePage.ts @@ -76,13 +76,10 @@ export class DialHomePage extends BasePage { await promptPreviewModal.waitForState(); await promptPreviewModal.promptName.waitForState(); } else { - const conversationSettings = appContainer.getConversationSettings(); - await conversationSettings - .getTalkToSelector() - .waitForState({ state: 'attached' }); - await conversationSettings - .getEntitySettings() - .waitForState({ state: 'attached' }); + await chat.getAgentInfo().waitForState({ state: 'attached' }); + await chat.configureSettingsButton.waitForState({ + state: 'attached', + }); } } diff --git a/apps/chat-e2e/src/ui/selectors/chatSelectors.ts b/apps/chat-e2e/src/ui/selectors/chatSelectors.ts index 749d06380b..9041020052 100644 --- a/apps/chat-e2e/src/ui/selectors/chatSelectors.ts +++ b/apps/chat-e2e/src/ui/selectors/chatSelectors.ts @@ -13,7 +13,7 @@ export const SendMessageSelectors = { }; export const ChatSettingsSelectors = { - conversationSettingsSelector: '[data-qa="conversation-settings"]', + conversationSettingsModal: '[data-qa="chat-settings-modal"]', entitySelector: '[data-qa="entity-selector"]', entitySettings: '[data-qa="entity-settings"]', searchOnMyApplications: '[data-qa="search-on-my-app"]', @@ -32,12 +32,14 @@ export const ChatSettingsSelectors = { selectedAddons: '[data-qa="selected-addons"]', recentAddons: '[data-qa="recent-addons"]', seeAllSelectors: '[data-qa="see-all-addons"]', - moreInfo: '[data-qa="more-info"]', - entityInfo: '[data-qa="entity-info"]', - entityDescription: '[data-qa="entity-descr"]', + agentInfoContainer: '[data-qa="agent-info-container"]', + agentInfo: '[data-qa="agent-info"]', + agentName: '[data-qa="agent-name"]', + agentDescription: '[data-qa="agent-descr"]', applyChanges: '[data-qa="apply-changes"]', playbackButton: '[data-qa="Playback"]', replayAsIsButton: '[data-qa="Replay as is"]', + configureSettingsButton: '[data-qa="configure-settings"]', }; export const MessageInputSelectors = { diff --git a/apps/chat-e2e/src/ui/webElements/agentInfo.ts b/apps/chat-e2e/src/ui/webElements/agentInfo.ts new file mode 100644 index 0000000000..7d1bfff7a8 --- /dev/null +++ b/apps/chat-e2e/src/ui/webElements/agentInfo.ts @@ -0,0 +1,38 @@ +import { ChatSettingsSelectors } from '../selectors'; +import { BaseElement } from './baseElement'; + +import { Tags } from '@/src/ui/domData'; +import { Locator, Page } from '@playwright/test'; + +export class AgentInfo extends BaseElement { + constructor(page: Page, parentLocator: Locator, index?: number) { + const elementLocator = new BaseElement( + page, + ChatSettingsSelectors.agentInfoContainer, + parentLocator, + ).getNthElement(index ?? 1); + super(page, '', elementLocator); + } + public agentInfo = this.getChildElementBySelector( + ChatSettingsSelectors.agentInfo, + ); + public agentName = this.getChildElementBySelector( + ChatSettingsSelectors.agentName, + ); + public agentDescription = this.getChildElementBySelector( + ChatSettingsSelectors.agentDescription, + ); + public agentIcon = this.getChildElementBySelector(Tags.img); + + async getAgentIcon() { + await this.agentIcon.waitForState(); + return this.getElementIcon(this.rootLocator); + } + + public async getAgentDescription() { + if (await this.agentDescription.isVisible()) { + return this.agentDescription.getElementInnerContent(); + } + return undefined; + } +} diff --git a/apps/chat-e2e/src/ui/webElements/chat.ts b/apps/chat-e2e/src/ui/webElements/chat.ts index 166878af24..b70c550d51 100644 --- a/apps/chat-e2e/src/ui/webElements/chat.ts +++ b/apps/chat-e2e/src/ui/webElements/chat.ts @@ -10,10 +10,10 @@ import { SendMessage } from './sendMessage'; import { API, ExpectedConstants, ScrollState, Side } from '@/src/testData'; import { keys } from '@/src/ui/keyboard'; +import { AgentInfo } from '@/src/ui/webElements/agentInfo'; import { ChatHeader } from '@/src/ui/webElements/chatHeader'; import { Compare } from '@/src/ui/webElements/compare'; import { Footer } from '@/src/ui/webElements/footer'; -import { MoreInfo } from '@/src/ui/webElements/moreInfo'; import { PlaybackControl } from '@/src/ui/webElements/playbackControl'; import { PublicationReviewControl } from '@/src/ui/webElements/publicationReviewControl'; import { Locator, Page } from '@playwright/test'; @@ -31,7 +31,7 @@ export class Chat extends BaseElement { private chatMessages!: ChatMessages; private compare!: Compare; private playbackControl!: PlaybackControl; - private isolatedView!: MoreInfo; + private agentInfo!: AgentInfo; private footer!: Footer; private publicationReviewControl!: PublicationReviewControl; public replay = this.getChildElementBySelector(ReplaySelectors.startReplay); @@ -51,6 +51,9 @@ export class Chat extends BaseElement { public addModelButton = this.getChildElementBySelector( ChatSelectors.addModelToWorkspace, ); + public configureSettingsButton = this.getChildElementBySelector( + ChatSettingsSelectors.configureSettingsButton, + ); getChatHeader(): ChatHeader { if (!this.chatHeader) { @@ -87,11 +90,11 @@ export class Chat extends BaseElement { return this.playbackControl; } - getIsolatedView(): MoreInfo { - if (!this.isolatedView) { - this.isolatedView = new MoreInfo(this.page, this.rootLocator); + getAgentInfo(): AgentInfo { + if (!this.agentInfo) { + this.agentInfo = new AgentInfo(this.page, this.rootLocator); } - return this.isolatedView; + return this.agentInfo; } getFooter(): Footer { @@ -290,8 +293,10 @@ export class Chat extends BaseElement { await this.getPlaybackControl().playbackPreviousButton.click(); } - public async applyNewEntity() { - await this.applyChanges().click(); + public async applyNewAgent() { + if (await this.applyChanges().isVisible()) { + await this.applyChanges().click(); + } } public async duplicateSharedConversation() { diff --git a/apps/chat-e2e/src/ui/webElements/compare.ts b/apps/chat-e2e/src/ui/webElements/compare.ts index 9d2cbd9e64..84f13db5b4 100644 --- a/apps/chat-e2e/src/ui/webElements/compare.ts +++ b/apps/chat-e2e/src/ui/webElements/compare.ts @@ -1,7 +1,8 @@ import { BaseElement } from './baseElement'; import { ConversationSettings } from './conversationSettings'; -import { CompareSelectors } from '@/src/ui/selectors'; +import { ChatSettingsSelectors, CompareSelectors } from '@/src/ui/selectors'; +import { AgentInfo } from '@/src/ui/webElements/agentInfo'; import { ChatHeader } from '@/src/ui/webElements/chatHeader'; import { ChatMessages } from '@/src/ui/webElements/chatMessages'; import { ConversationToCompare } from '@/src/ui/webElements/conversationToCompare'; @@ -11,6 +12,8 @@ export class Compare extends BaseElement { constructor(page: Page) { super(page, CompareSelectors.compareMode); } + private leftAgentInfo!: AgentInfo; + private rightAgentInfo!: AgentInfo; private leftConversationSettings!: ConversationSettings; private rightConversationSettings!: ConversationSettings; private chatMessages!: ChatMessages; @@ -18,6 +21,27 @@ export class Compare extends BaseElement { private rightChatHeader!: ChatHeader; private leftChatHeader!: ChatHeader; + public leftConfigureSettingsButton = this.getChildElementBySelector( + ChatSettingsSelectors.configureSettingsButton, + ).getNthElement(1); + public rightConfigureSettingsButton = this.getChildElementBySelector( + ChatSettingsSelectors.configureSettingsButton, + ).getNthElement(2); + + getLeftAgentInfo(): AgentInfo { + if (!this.leftAgentInfo) { + this.leftAgentInfo = new AgentInfo(this.page, this.rootLocator); + } + return this.leftAgentInfo; + } + + getRightAgentInfo(): AgentInfo { + if (!this.rightAgentInfo) { + this.rightAgentInfo = new AgentInfo(this.page, this.rootLocator, 2); + } + return this.rightAgentInfo; + } + getLeftConversationSettings(): ConversationSettings { if (!this.leftConversationSettings) { this.leftConversationSettings = new ConversationSettings(this.page); @@ -66,8 +90,8 @@ export class Compare extends BaseElement { public async getConversationsCount() { return ( - (await this.getLeftConversationSettings().getElementsCount()) + - (await this.getRightConversationSettings().getElementsCount()) + (await this.getLeftAgentInfo().getElementsCount()) + + (await this.getRightAgentInfo().getElementsCount()) ); } diff --git a/apps/chat-e2e/src/ui/webElements/conversationSettings.ts b/apps/chat-e2e/src/ui/webElements/conversationSettings.ts index 31e01c3c17..462f611902 100644 --- a/apps/chat-e2e/src/ui/webElements/conversationSettings.ts +++ b/apps/chat-e2e/src/ui/webElements/conversationSettings.ts @@ -1,4 +1,4 @@ -import { ChatSettingsSelectors } from '../selectors'; +import { ChatSettingsSelectors, IconSelectors } from '../selectors'; import { BaseElement } from './baseElement'; import { EntitySelector } from './entitySelector'; @@ -9,12 +9,15 @@ export class ConversationSettings extends BaseElement { constructor(page: Page, parentLocator?: Locator, index?: number) { const elementLocator = new BaseElement( page, - ChatSettingsSelectors.conversationSettingsSelector, + ChatSettingsSelectors.conversationSettingsModal, parentLocator, ).getNthElement(index ?? 1); super(page, '', elementLocator); } + public cancelButton = this.getChildElementBySelector( + IconSelectors.cancelIcon, + ); private talkToSelector!: EntitySelector; private entitySettings!: EntitySettings; diff --git a/apps/chat-e2e/src/ui/webElements/entitySelector.ts b/apps/chat-e2e/src/ui/webElements/entitySelector.ts index aa874d9cda..1c5c799e95 100644 --- a/apps/chat-e2e/src/ui/webElements/entitySelector.ts +++ b/apps/chat-e2e/src/ui/webElements/entitySelector.ts @@ -73,6 +73,7 @@ export class EntitySelector extends BaseElement { } } } + private async isEntitySelected( talkToEntities: TalkToEntities, entity: DialAIEntityModel, diff --git a/apps/chat-e2e/src/ui/webElements/entitySettings.ts b/apps/chat-e2e/src/ui/webElements/entitySettings.ts index 598657c360..e1787ee11b 100644 --- a/apps/chat-e2e/src/ui/webElements/entitySettings.ts +++ b/apps/chat-e2e/src/ui/webElements/entitySettings.ts @@ -4,7 +4,6 @@ import { BaseElement } from './baseElement'; import { Addons } from '@/src/ui/webElements/addons'; import { PROMPT_APPLY_DELAY } from '@/src/ui/webElements/chat'; import { ModelSelector } from '@/src/ui/webElements/modelSelector'; -import { MoreInfo } from '@/src/ui/webElements/moreInfo'; import { PromptList } from '@/src/ui/webElements/promptList'; import { TemperatureSlider } from '@/src/ui/webElements/temperatureSlider'; import { Locator, Page } from '@playwright/test'; @@ -20,7 +19,6 @@ export class EntitySettings extends BaseElement { private temperatureSlider!: TemperatureSlider; private addons!: Addons; private modelSelector!: ModelSelector; - private moreInfo!: MoreInfo; private promptList!: PromptList; getPromptList() { @@ -54,13 +52,6 @@ export class EntitySettings extends BaseElement { return this.modelSelector; } - getMoreInfo(): MoreInfo { - if (!this.moreInfo) { - this.moreInfo = new MoreInfo(this.page, this.rootLocator); - } - return this.moreInfo; - } - public async setSystemPrompt(prompt: string) { await this.systemPrompt.typeInInput(prompt); // eslint-disable-next-line playwright/no-wait-for-timeout diff --git a/apps/chat-e2e/src/ui/webElements/index.ts b/apps/chat-e2e/src/ui/webElements/index.ts index 177e5dfd56..b5319a87e7 100644 --- a/apps/chat-e2e/src/ui/webElements/index.ts +++ b/apps/chat-e2e/src/ui/webElements/index.ts @@ -17,7 +17,7 @@ export * from './promptModalDialog'; export * from './temperatureSlider'; export * from './promptList'; export * from './variableModalDialog'; -export * from './moreInfo'; +export * from './agentInfo'; export * from './chatHeader'; export * from './chatInfoTooltip'; export * from './compare'; diff --git a/apps/chat-e2e/src/ui/webElements/marketplace/applications.ts b/apps/chat-e2e/src/ui/webElements/marketplace/applications.ts index 43444e2672..809e2992b4 100644 --- a/apps/chat-e2e/src/ui/webElements/marketplace/applications.ts +++ b/apps/chat-e2e/src/ui/webElements/marketplace/applications.ts @@ -45,7 +45,7 @@ export class Applications extends BaseElement { //check if current version match expected const currentVersion = await appDetailsModal.applicationVersion .getElementInnerContent() - .then((value) => value.replace('version:\n', '').replace('v: ', '')); + .then((value) => value.replace('Version:\n', '').replace('v: ', '')); //select version from dropdown menu if it does not match the current one if (currentVersion !== entity.version) { const menuTrigger = appDetailsModal.versionMenuTrigger; diff --git a/apps/chat-e2e/src/ui/webElements/moreInfo.ts b/apps/chat-e2e/src/ui/webElements/moreInfo.ts deleted file mode 100644 index b28b1c72eb..0000000000 --- a/apps/chat-e2e/src/ui/webElements/moreInfo.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { ChatSettingsSelectors } from '../selectors'; -import { BaseElement } from './baseElement'; - -import { Tags } from '@/src/ui/domData'; -import { Locator, Page } from '@playwright/test'; - -export class MoreInfo extends BaseElement { - constructor(page: Page, parentLocator: Locator) { - super(page, ChatSettingsSelectors.moreInfo, parentLocator); - } - public entityInfo = this.getChildElementBySelector( - ChatSettingsSelectors.entityInfo, - ); - - public entityDescription = this.getChildElementBySelector( - ChatSettingsSelectors.entityDescription, - ); - public entityIcon = this.getChildElementBySelector(Tags.img); - - async getEntityIcon() { - await this.entityIcon.waitForState(); - return this.getElementIcon(this.rootLocator); - } - - public async getEntityDescription() { - if (await this.entityDescription.isVisible()) { - return this.entityDescription.getElementInnerContent(); - } - return undefined; - } - - public async getEntityName() { - return this.entityInfo - .getElementLocator() - .locator(Tags.span) - .last() - .textContent(); - } -} diff --git a/apps/chat/public/locales/en/chat.json b/apps/chat/public/locales/en/chat.json index 183a148151..c53ee06df9 100644 --- a/apps/chat/public/locales/en/chat.json +++ b/apps/chat/public/locales/en/chat.json @@ -1,4 +1,4 @@ { "chat.error.incorrect-selected_addon": "Not allowed addon selected. Please, change the addon to proceed", - "chat.error.incorrect-selected_model": "Not available model selected. Please, change the model to proceed" + "chat.error.incorrect-selected_model": "Not available agent selected. Please, change the agent to proceed" } diff --git a/apps/chat/src/components/Chat/Chat.tsx b/apps/chat/src/components/Chat/Chat.tsx index 6a488a1730..a91a25f5a7 100644 --- a/apps/chat/src/components/Chat/Chat.tsx +++ b/apps/chat/src/components/Chat/Chat.tsx @@ -46,8 +46,6 @@ import { PublicationSelectors } from '@/src/store/publication/publication.reduce import { SettingsSelectors } from '@/src/store/settings/settings.reducers'; import { UISelectors } from '@/src/store/ui/ui.reducers'; -import { REPLAY_AS_IS_MODEL } from '@/src/constants/chat'; - import Loader from '../Common/Loader'; import { NotFoundEntity } from '../Common/NotFoundEntity'; import { ChatCompareRotate } from './ChatCompareRotate'; @@ -57,7 +55,7 @@ import { ChatInput } from './ChatInput/ChatInput'; import { ChatInputControls } from './ChatInput/ChatInputControls'; import { ChatInputFooter } from './ChatInput/ChatInputFooter'; import { ChatSettings } from './ChatSettings'; -import { ChatSettingsEmpty } from './ChatSettingsEmpty'; +import { EmptyChatDescription } from './EmptyChatDescription'; import { ErrorMessageDiv } from './ErrorMessageDiv'; import { MemoizedChatMessage } from './MemoizedChatMessage'; import { NotAllowedModel } from './NotAllowedModel'; @@ -79,7 +77,6 @@ const scrollThrottlingTimeout = 250; export const ChatView = memo(() => { const dispatch = useAppDispatch(); - const appName = useAppSelector(SettingsSelectors.selectAppName); const models = useAppSelector(ModelsSelectors.selectModels); const modelsMap = useAppSelector(ModelsSelectors.selectModelsMap); const modelError = useAppSelector(ModelsSelectors.selectModelsError); @@ -350,42 +347,6 @@ export const ChatView = memo(() => { [dispatch], ); - const handleSelectModel = useCallback( - (conversation: Conversation, modelId: string) => { - const newAiEntity = modelsMap[modelId]; - if (!newAiEntity && modelId !== REPLAY_AS_IS_MODEL) { - return; - } - - dispatch( - ConversationsActions.updateConversation({ - id: conversation.id, - values: { - ...getConversationModelParams( - conversation, - modelId, - modelsMap, - addonsMap, - ), - }, - }), - ); - }, - [addonsMap, dispatch, modelsMap], - ); - - const handleSelectAssistantSubModel = useCallback( - (conversation: Conversation, modelId: string) => { - dispatch( - ConversationsActions.updateConversation({ - id: conversation.id, - values: { assistantModelId: modelId }, - }), - ); - }, - [dispatch], - ); - useEffect(() => { if (!selectedConversationsIds.some((id) => prevSelectedIds.includes(id))) { setAutoScroll(); @@ -397,73 +358,6 @@ export const ChatView = memo(() => { } }, [prevSelectedIds, selectedConversationsIds]); - const handleOnChangeAddon = useCallback( - (conversation: Conversation, addonId: string) => { - const isAddonInConversation = conversation.selectedAddons.some( - (id) => id === addonId, - ); - if (isAddonInConversation) { - const filteredAddons = conversation.selectedAddons.filter( - (id) => id !== addonId, - ); - dispatch( - ConversationsActions.updateConversation({ - id: conversation.id, - values: { selectedAddons: filteredAddons }, - }), - ); - } else { - dispatch( - ConversationsActions.updateConversation({ - id: conversation.id, - values: { - selectedAddons: conversation.selectedAddons.concat(addonId), - }, - }), - ); - } - }, - [dispatch], - ); - - const handleOnApplyAddons = useCallback( - (conversation: Conversation, addonIds: string[]) => { - dispatch( - ConversationsActions.updateConversation({ - id: conversation.id, - values: { - selectedAddons: addonIds.filter((addonId) => addonsMap[addonId]), - }, - }), - ); - }, - [addonsMap, dispatch], - ); - - const handleChangePrompt = useCallback( - (conversation: Conversation, prompt: string) => { - dispatch( - ConversationsActions.updateConversation({ - id: conversation.id, - values: { prompt }, - }), - ); - }, - [dispatch], - ); - - const handleChangeTemperature = useCallback( - (conversation: Conversation, temperature: number) => { - dispatch( - ConversationsActions.updateConversation({ - id: conversation.id, - values: { temperature }, - }), - ); - }, - [dispatch], - ); - const handleDeleteMessage = useCallback( (index: number, conv: Conversation) => { let finalIndex = index; @@ -589,6 +483,10 @@ export const ChatView = memo(() => { installedModelIds.has(conv.model.id), ); + const areSelectedConversationsEmpty = selectedConversations.every( + (conv) => !conv.messages.length, + ); + return (
{ )} data-qa={isCompareMode ? 'compare-mode' : 'chat-mode'} > -
+
{selectedConversations.map((conv) => (
{ } }} ref={setChatContainerRef} - className="h-full overflow-x-hidden" + className={classNames('h-full overflow-x-hidden', { + 'content-center': areSelectedConversationsEmpty, + })} data-qa="scrollable-area" >
@@ -723,32 +630,11 @@ export const ChatView = memo(() => { height: `calc(100% - ${inputHeight}px)`, }} > - - handleSelectModel(conv, modelId) - } - onSelectAssistantSubModel={( - modelId: string, - ) => - handleSelectAssistantSubModel(conv, modelId) - } - onChangeAddon={(addonId: string) => - handleOnChangeAddon(conv, addonId) - } - onChangePrompt={(prompt) => - handleChangePrompt(conv, prompt) - } - onChangeTemperature={(temperature) => - handleChangeTemperature(conv, temperature) - } - appName={appName} - onApplyAddons={handleOnApplyAddons} + modelsLoaded={models.length !== 0} + setShowChangeModel={setIsShowChatSettings} + setShowSettings={setIsShowChatSettings} />
diff --git a/apps/chat/src/components/Chat/ChatSettingsEmpty.tsx b/apps/chat/src/components/Chat/ChatSettingsEmpty.tsx deleted file mode 100644 index 516e52550f..0000000000 --- a/apps/chat/src/components/Chat/ChatSettingsEmpty.tsx +++ /dev/null @@ -1,116 +0,0 @@ -import { useCallback } from 'react'; - -import { Conversation } from '@/src/types/chat'; -import { DialAIEntityModel } from '@/src/types/models'; -import { Prompt } from '@/src/types/prompt'; - -import { useAppSelector } from '@/src/store/hooks'; -import { ModelsSelectors } from '@/src/store/models/models.reducers'; -import { SettingsSelectors } from '@/src/store/settings/settings.reducers'; - -import { REPLAY_AS_IS_MODEL } from '@/src/constants/chat'; - -import { Spinner } from '../Common/Spinner'; -import { ConversationSettings } from './ConversationSettings'; -import { ModelDescription } from './ModelDescription'; - -import { Inversify } from '@epam/ai-dial-modulify-ui'; - -interface Props { - isModels: boolean; - conversation: Conversation; - prompts: Prompt[]; - isShowSettings: boolean; - onChangePrompt: (prompt: string) => void; - onChangeTemperature: (temperature: number) => void; - onSelectModel: (modelId: string) => void; - onSelectAssistantSubModel: (modelId: string) => void; - onChangeAddon: (addonId: string) => void; - appName: string; - onApplyAddons: (conversation: Conversation, addonIds: string[]) => void; -} - -export const ChatSettingsEmpty = Inversify.register( - 'ChatSettingsEmpty', - ({ - isModels, - conversation, - prompts, - isShowSettings, - appName, - onChangePrompt, - onChangeTemperature, - onSelectModel, - onSelectAssistantSubModel, - onChangeAddon, - onApplyAddons, - }: Props) => { - const handleOnApplyAddons = useCallback( - (addons: string[]) => { - onApplyAddons(conversation, addons); - }, - [conversation, onApplyAddons], - ); - const isolatedModelId = useAppSelector( - SettingsSelectors.selectIsolatedModelId, - ); - const modelsMap = useAppSelector(ModelsSelectors.selectModelsMap); - - return ( -
-
- {!isModels ? ( -
- -
- ) : ( - <> - {appName && ( -
-

- {isolatedModelId && modelsMap[isolatedModelId] ? ( - - ) : ( - appName - )} -

-
- )} - - )} - - {isShowSettings && isModels && ( - - )} -
-
- ); - }, -); diff --git a/apps/chat/src/components/Chat/EmptyChatDescription.tsx b/apps/chat/src/components/Chat/EmptyChatDescription.tsx new file mode 100644 index 0000000000..4d5fc02150 --- /dev/null +++ b/apps/chat/src/components/Chat/EmptyChatDescription.tsx @@ -0,0 +1,176 @@ +import { useCallback, useMemo } from 'react'; + +import { useTranslation } from 'next-i18next'; + +import classNames from 'classnames'; + +import { getModelDescription } from '@/src/utils/app/application'; +import { getOpenAIEntityFullName } from '@/src/utils/app/conversation'; + +import { Conversation } from '@/src/types/chat'; +import { DialAIEntityModel } from '@/src/types/models'; +import { Translation } from '@/src/types/translation'; + +import { ConversationsActions } from '@/src/store/conversations/conversations.reducers'; +import { useAppDispatch, useAppSelector } from '@/src/store/hooks'; +import { ModelsSelectors } from '@/src/store/models/models.reducers'; + +import { ModelIcon } from '../Chatbar/ModelIcon'; +import { EntityMarkdownDescription } from '../Common/MarkdownDescription'; +import { Spinner } from '../Common/Spinner'; +import { FunctionStatusIndicator } from '../Marketplace/FunctionStatusIndicator'; +import { ModelVersionSelect } from './ModelVersionSelect'; + +interface Props { + conversation: Conversation; + modelsLoaded: boolean; + setShowChangeModel: (show: boolean) => void; + setShowSettings: (show: boolean) => void; +} + +export const EmptyChatDescription = ({ + conversation, + modelsLoaded, + // setShowChangeModel, + setShowSettings, +}: Props) => { + const dispatch = useAppDispatch(); + const { t } = useTranslation(Translation.Chat); + const model = useAppSelector((state) => + ModelsSelectors.selectModel(state, conversation.model.id), + ); + const installedModelIds = useAppSelector( + ModelsSelectors.selectInstalledModelIds, + ); + const models = useAppSelector(ModelsSelectors.selectModels); + const versions = useMemo( + () => + models.filter( + (m) => installedModelIds.has(m.reference) && m.name === model?.name, + ), + [installedModelIds, model?.name, models], + ); + const incorrectModel = !model; + // TODO: uncomment in https://github.com/epam/ai-dial-chat/issues/2047 + // const handleOpenChangeModel = useCallback( + // () => setShowChangeModel(true), + // [setShowChangeModel], + // ); + const handleOpenSettings = useCallback( + () => setShowSettings(true), + [setShowSettings], + ); + + const handleSelectVersion = useCallback( + (model: DialAIEntityModel) => { + dispatch( + ConversationsActions.updateConversation({ + id: conversation.id, + values: { model: { id: model.id } }, + }), + ); + }, + [conversation.id, dispatch], + ); + + return ( +
+
+ {!modelsLoaded ? ( +
+ +
+ ) : ( +
+
+ {/* {incorrectModel ? ( + +
{conversation.model.id}
+ ) : ( */} +
+
+ +
+ + {model + ? getOpenAIEntityFullName(model) + : conversation.model.id} + + {model && } +
+
+ {model && ( + <> + + {!!getModelDescription(model) && ( + + + {getModelDescription(model)} + + + )} + + )} +
+ {/* )} */} +
+
+ {/* */} + +
+
+ )} +
+
+ ); +}; diff --git a/apps/chat/src/components/Chat/ModelDescription.tsx b/apps/chat/src/components/Chat/ModelDescription.tsx index 6c3fc84d28..459ad04e5f 100644 --- a/apps/chat/src/components/Chat/ModelDescription.tsx +++ b/apps/chat/src/components/Chat/ModelDescription.tsx @@ -16,6 +16,8 @@ interface Props { hideMoreInfo?: boolean; className?: string; isShortDescription?: boolean; + iconSize?: number; + hideIconTooltip?: boolean; } export const ModelDescription = ({ @@ -23,23 +25,30 @@ export const ModelDescription = ({ hideMoreInfo, className, isShortDescription, + iconSize = 24, + hideIconTooltip, }: Props) => { const { t } = useTranslation(Translation.Chat); return ( -
+
{!hideMoreInfo && {t('More info')}}
- - {getOpenAIEntityFullName(model)} + + {getOpenAIEntityFullName(model)}
{!!getModelDescription(model) && ( {getModelDescription(model)} diff --git a/apps/chat/src/components/Chat/ModelVersionSelect.tsx b/apps/chat/src/components/Chat/ModelVersionSelect.tsx index e4ed2fcef4..0b4e43c906 100644 --- a/apps/chat/src/components/Chat/ModelVersionSelect.tsx +++ b/apps/chat/src/components/Chat/ModelVersionSelect.tsx @@ -19,7 +19,7 @@ const VersionPrefix = () => { return (
- {t('version: ')} + {t('Version: ')} {t('v: ')}
); @@ -55,7 +55,10 @@ export const ModelVersionSelect = ({ if (entities.length < 2) { if (entities.length && entities[0].version) { return ( -
+
{showVersionPrefix && } {entities[0].version}
@@ -75,7 +78,7 @@ export const ModelVersionSelect = ({ data-qa="model-version-select" trigger={
diff --git a/apps/chat/src/components/Chat/ReplayAsIsDescription.tsx b/apps/chat/src/components/Chat/ReplayAsIsDescription.tsx index 06b9c89ef7..952af6d2f2 100644 --- a/apps/chat/src/components/Chat/ReplayAsIsDescription.tsx +++ b/apps/chat/src/components/Chat/ReplayAsIsDescription.tsx @@ -13,7 +13,7 @@ export const ReplayAsIsDescription = ({ isModelInMessages }: Props) => { return (
-
+
{t('More info')}
diff --git a/apps/chat/src/components/Chat/SystemPrompt.tsx b/apps/chat/src/components/Chat/SystemPrompt.tsx index 29054e7ac3..d7ac44a920 100644 --- a/apps/chat/src/components/Chat/SystemPrompt.tsx +++ b/apps/chat/src/components/Chat/SystemPrompt.tsx @@ -162,11 +162,6 @@ export const SystemPrompt: FC = ({ }; }, [setShowPromptList]); - // TODO: remove this rerender useEffect in https://github.com/epam/ai-dial-chat/issues/2045 - useEffect(() => { - setContent(prompt ?? ''); - }, [prompt, setContent]); - return (
diff --git a/apps/chat/src/components/Chatbar/ChatbarSettings.tsx b/apps/chat/src/components/Chatbar/ChatbarSettings.tsx index cb1f618454..bd0f19039e 100644 --- a/apps/chat/src/components/Chatbar/ChatbarSettings.tsx +++ b/apps/chat/src/components/Chatbar/ChatbarSettings.tsx @@ -100,6 +100,7 @@ export const ChatbarSettings = () => { onClick: () => { dispatch(ConversationsActions.setAllChosenConversations()); }, + display: isMyItemsExist, disabled: isStreaming, }, { diff --git a/apps/chat/src/components/Promptbar/components/PromptbarSettings.tsx b/apps/chat/src/components/Promptbar/components/PromptbarSettings.tsx index e377afdfac..91595b59b1 100644 --- a/apps/chat/src/components/Promptbar/components/PromptbarSettings.tsx +++ b/apps/chat/src/components/Promptbar/components/PromptbarSettings.tsx @@ -51,6 +51,7 @@ export function PromptbarSettings() { onClick: () => { dispatch(PromptsActions.setAllChosenPrompts()); }, + display: isMyItemsExist, }, { name: t('Unselect all'),