From 5483d7bf97095f3d8d5f83b600d8d920f420225b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 26 Jul 2024 01:29:03 +0000 Subject: [PATCH] switch to ml_configuration in agent response as backend changed (#239) * switch to ml_configuration in agent response as backend changed Signed-off-by: Heng Qian * Address comments and add changelog Signed-off-by: Heng Qian * Address comments Signed-off-by: Heng Qian * Add change in release notes Signed-off-by: Heng Qian --------- Signed-off-by: Heng Qian (cherry picked from commit 913c47b46b321410bd9baa972f225d8c197d92d8) Signed-off-by: github-actions[bot] # Conflicts: # CHANGELOG.md --- .../dashboards-assistant.release-notes-2.16.0.0.md | 6 +++++- server/routes/get_agent.ts | 7 +++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/release-notes/dashboards-assistant.release-notes-2.16.0.0.md b/release-notes/dashboards-assistant.release-notes-2.16.0.0.md index c9804b9f..4c7315db 100644 --- a/release-notes/dashboards-assistant.release-notes-2.16.0.0.md +++ b/release-notes/dashboards-assistant.release-notes-2.16.0.0.md @@ -4,4 +4,8 @@ Compatible with OpenSearch and OpenSearch Dashboards Version 2.16.0 ### Features -- Add feature to support text to visualization. ([#218](https://github.com/opensearch-project/dashboards-assistant/pull/218)) \ No newline at end of file +- Add feature to support text to visualization. ([#218](https://github.com/opensearch-project/dashboards-assistant/pull/218)) + +### Maintenance + +- Make ML Configuration Index Mapping be compatible with ml-commons plugin. ([#239](https://github.com/opensearch-project/dashboards-assistant/pull/239)) diff --git a/server/routes/get_agent.ts b/server/routes/get_agent.ts index a8d285a6..76cdd467 100644 --- a/server/routes/get_agent.ts +++ b/server/routes/get_agent.ts @@ -14,10 +14,13 @@ export const getAgent = async (id: string, client: OpenSearchClient['transport'] path, }); - if (!response || !response.body.configuration?.agent_id) { + if ( + !response || + !(response.body.ml_configuration?.agent_id || response.body.configuration?.agent_id) + ) { throw new Error(`cannot get agent ${id} by calling the api: ${path}`); } - return response.body.configuration.agent_id; + return response.body.ml_configuration?.agent_id || response.body.configuration.agent_id; } catch (error) { const errorMessage = JSON.stringify(error.meta?.body) || error; throw new Error(`get agent ${id} failed, reason: ${errorMessage}`);