From 92595bfd4375089e0711070baafbe693af325345 Mon Sep 17 00:00:00 2001 From: Aliullov Vlad Date: Thu, 12 Dec 2024 17:55:57 +0400 Subject: [PATCH] fix named OpenAI import problem, and use import path to DataSource and CustomStore in previous way --- .../Angular/app/app.component.ts | 2 +- .../Angular/app/app.service.ts | 19 ++++++++++--------- .../Chat/AIAndChatbotIntegration/Vue/App.vue | 8 ++++---- apps/demos/configs/Angular/config.js | 3 +++ apps/demos/configs/React/config.js | 3 +++ apps/demos/configs/ReactJs/config.js | 3 +++ apps/demos/configs/Vue/config.js | 3 +++ 7 files changed, 27 insertions(+), 14 deletions(-) diff --git a/apps/demos/Demos/Chat/AIAndChatbotIntegration/Angular/app/app.component.ts b/apps/demos/Demos/Chat/AIAndChatbotIntegration/Angular/app/app.component.ts index dcb678531d0..0431879f254 100644 --- a/apps/demos/Demos/Chat/AIAndChatbotIntegration/Angular/app/app.component.ts +++ b/apps/demos/Demos/Chat/AIAndChatbotIntegration/Angular/app/app.component.ts @@ -13,7 +13,7 @@ import { import { Observable } from 'rxjs'; import { AppService } from './app.service'; import { loadMessages } from 'devextreme/localization'; -import { DataSource } from 'devextreme/common/data'; +import DataSource from 'devextreme/data/data_source'; if (!/localhost/.test(document.location.host)) { enableProdMode(); diff --git a/apps/demos/Demos/Chat/AIAndChatbotIntegration/Angular/app/app.service.ts b/apps/demos/Demos/Chat/AIAndChatbotIntegration/Angular/app/app.service.ts index da9d735f27d..fe4ece54ec6 100644 --- a/apps/demos/Demos/Chat/AIAndChatbotIntegration/Angular/app/app.service.ts +++ b/apps/demos/Demos/Chat/AIAndChatbotIntegration/Angular/app/app.service.ts @@ -10,7 +10,8 @@ import { Alert, MessageEnteredEvent } from 'devextreme/ui/chat'; -import { DataSource, CustomStore } from 'devextreme/common/data'; +import DataSource from 'devextreme/data/data_source'; +import CustomStore from 'devextreme/data/custom_store'; @Injectable({ providedIn: 'root', @@ -26,7 +27,7 @@ export class AppService { endpoint: 'https://public-api.devexpress.com/demo-openai', apiKey: 'DEMO', } - + REGENERATION_TEXT = 'Regeneration...'; ALERT_TIMEOUT = 1000 * 60; @@ -95,7 +96,7 @@ export class AppService { }); }, }); - + this.dataSource = new DataSource({ store: this.customStore, paginate: false, @@ -109,17 +110,17 @@ export class AppService { max_tokens: 1000, temperature: 0.7, }; - + const response = await this.chatService.chat.completions.create(params); const data = { choices: response.choices }; - + return data.choices[0].message?.content; } async processMessageSending(message, event) { this.messages.push({ role: 'user', content: message.text }); this.typingUsersSubject.next([this.assistant]); - + try { const aiResponse = await this.getAIResponse(this.messages); @@ -138,7 +139,7 @@ export class AppService { updateLastMessage(text = this.REGENERATION_TEXT) { const items = this.dataSource.items(); const lastMessage = items.at(-1); - + this.dataSource.store().push([{ type: 'update', key: lastMessage.id, @@ -161,7 +162,7 @@ export class AppService { this.setAlerts([{ message: 'Request limit reached, try again in a minute.' }]); - + setTimeout(() => { this.setAlerts([]); }, this.ALERT_TIMEOUT); @@ -194,7 +195,7 @@ export class AppService { return result; } - + async onMessageEntered({ message, event }: MessageEnteredEvent) { this.dataSource.store().push([{ type: 'insert', data: { id: Date.now(), ...message } }]); diff --git a/apps/demos/Demos/Chat/AIAndChatbotIntegration/Vue/App.vue b/apps/demos/Demos/Chat/AIAndChatbotIntegration/Vue/App.vue index 46bc2fb98fc..420dc2ac68e 100644 --- a/apps/demos/Demos/Chat/AIAndChatbotIntegration/Vue/App.vue +++ b/apps/demos/Demos/Chat/AIAndChatbotIntegration/Vue/App.vue @@ -17,7 +17,7 @@ @message-entered="onMessageEntered($event)" >