Skip to content

Commit

Permalink
add constants for ml backend api
Browse files Browse the repository at this point in the history
Signed-off-by: tygao <[email protected]>
  • Loading branch information
raintygao committed Dec 1, 2023
1 parent c42f65c commit 80d218d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
9 changes: 6 additions & 3 deletions server/routes/chat_routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
}
}
);
Expand Down
9 changes: 9 additions & 0 deletions server/services/constants.ts
Original file line number Diff line number Diff line change
@@ -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`;
2 changes: 1 addition & 1 deletion server/services/storage/agent_framework_storage_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down

0 comments on commit 80d218d

Please sign in to comment.