From 9201c7681684bd53f21fe6527d2773cf307f048d Mon Sep 17 00:00:00 2001 From: Lyubov Voloshko Date: Wed, 3 Sep 2025 15:41:33 +0300 Subject: [PATCH] ai panel: update server requests --- .../db-table-ai-panel/db-table-ai-panel.component.ts | 10 +++++++--- frontend/src/app/services/connections.service.ts | 2 -- frontend/src/app/services/tables.service.ts | 12 ++++++++---- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/frontend/src/app/components/dashboard/db-table-view/db-table-ai-panel/db-table-ai-panel.component.ts b/frontend/src/app/components/dashboard/db-table-view/db-table-ai-panel/db-table-ai-panel.component.ts index b3f89312e..2c1c1e039 100644 --- a/frontend/src/app/components/dashboard/db-table-view/db-table-ai-panel/db-table-ai-panel.component.ts +++ b/frontend/src/app/components/dashboard/db-table-view/db-table-ai-panel/db-table-ai-panel.component.ts @@ -95,7 +95,11 @@ export class DbTableAiPanelComponent implements OnInit, OnDestroy { }); } else { event.preventDefault(); - this.createThread(); + if (this.threadID) { + this.sendMessage(); + } else { + this.createThread(); + } } } } @@ -152,10 +156,10 @@ export class DbTableAiPanelComponent implements OnInit, OnDestroy { const messageCopy = this.message; this.message = ''; this.charactrsNumber = 0; - this._tables.requestAImessage(this.connectionID, this.tableName, this.threadID, messageCopy).subscribe((response) => { + this._tables.requestAImessage(this.connectionID, this.tableName, this.threadID, messageCopy).subscribe((response_message) => { this.messagesChain.push({ type: 'ai', - text: this.markdownService.parse(response.response_message) as string + text: this.markdownService.parse(response_message) as string }); this.submitting = false; diff --git a/frontend/src/app/services/connections.service.ts b/frontend/src/app/services/connections.service.ts index d585fabfd..394bc0b87 100644 --- a/frontend/src/app/services/connections.service.ts +++ b/frontend/src/app/services/connections.service.ts @@ -218,7 +218,6 @@ export class ConnectionsService { const connections = res.connections.map(connectionItem => { const connection = this.defineConnectionType(connectionItem.connection); const displayTitle = this.defineConnectionTitle(connectionItem.connection); - console.log('displayTitle', displayTitle); return {...connectionItem, connection, displayTitle}; }); this.ownConnections = connections.filter(connectionItem => !connectionItem.connection.isTestConnection); @@ -330,7 +329,6 @@ export class ConnectionsService { } updateConnection(connection: Connection, masterKey: string) { - console.log('updateConnection'); let dbCredentials; dbCredentials = { ...connection, diff --git a/frontend/src/app/services/tables.service.ts b/frontend/src/app/services/tables.service.ts index 049c9dc40..98e96b564 100644 --- a/frontend/src/app/services/tables.service.ts +++ b/frontend/src/app/services/tables.service.ts @@ -480,7 +480,7 @@ export class TablesService { }) .pipe( map((res) => { - const threadId = res.headers.get('x-openai-thread-id'); + const threadId = res.headers.get('X-OpenAI-Thread-ID'); this.angulartics2.eventTrack.next({ action: 'AI: thread created' }); @@ -495,14 +495,18 @@ export class TablesService { } requestAImessage(connectionID: string, tableName: string, threadId: string, message: string) { - return this._http.post(`/ai/thread/message/${connectionID}/${threadId}`, {user_message: message}, { + console.log('threadId', threadId); + return this._http.post(`/ai/v2/request/${connectionID}`, {user_message: message}, { + responseType: 'text' as 'json', + observe: 'response', params: { - tableName + tableName, + threadId } }) .pipe( map((res) => { - return res + return res.body as string; }), catchError((err) => { console.log(err);