From 80d218debda0075e210ce32e704e0ff8d3685958 Mon Sep 17 00:00:00 2001 From: tygao Date: Fri, 1 Dec 2023 18:38:54 +0800 Subject: [PATCH] add constants for ml backend api Signed-off-by: tygao --- server/routes/chat_routes.ts | 9 ++++++--- server/services/constants.ts | 9 +++++++++ .../services/storage/agent_framework_storage_service.ts | 2 +- 3 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 server/services/constants.ts diff --git a/server/routes/chat_routes.ts b/server/routes/chat_routes.ts index 9e000f62..6cb72b5f 100644 --- a/server/routes/chat_routes.ts +++ b/server/routes/chat_routes.ts @@ -345,13 +345,16 @@ export function registerChatRoutes(router: IRouter, routeOptions: RoutesOptions) const { interactionId } = request.params; try { - const getResponse = await storageService.updateInteraction(interactionId, { + const updateResponse = await storageService.updateInteraction(interactionId, { feedback: request.body, }); - return response.ok({ body: getResponse }); + return response.ok({ body: { ...updateResponse, success: true } }); } catch (error) { context.assistant_plugin.logger.error(error); - return response.custom({ statusCode: error.statusCode || 500, body: error.message }); + return response.custom({ + statusCode: error.statusCode || 500, + body: error.message, + }); } } ); diff --git a/server/services/constants.ts b/server/services/constants.ts new file mode 100644 index 00000000..14335052 --- /dev/null +++ b/server/services/constants.ts @@ -0,0 +1,9 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +const ML_API_PREFIX = '/_plugins/_ml'; +const MEMORY_API_PREFIX = `${ML_API_PREFIX}/memory`; +export const CONVERSATION_API_PREFIX = `${MEMORY_API_PREFIX}/conversation`; +export const INTERACTION_API_PREFIX = `${MEMORY_API_PREFIX}/interaction`; diff --git a/server/services/storage/agent_framework_storage_service.ts b/server/services/storage/agent_framework_storage_service.ts index 52e2ceed..52a66528 100644 --- a/server/services/storage/agent_framework_storage_service.ts +++ b/server/services/storage/agent_framework_storage_service.ts @@ -224,7 +224,7 @@ export class AgentFrameworkStorageService implements StorageService { try { const response = await this.client.transport.request({ method: 'PUT', - path: `/_plugins/_ml/memory/interaction/${interactionId}/_update`, + path: `${ML_COMMONS_BASE_API}/memory/interaction/${interactionId}/_update`, body: { additional_info: additionalInfo, },