Skip to content

Commit

Permalink
switch to ml_configuration in agent response as backend changed (#239)
Browse files Browse the repository at this point in the history
* switch to ml_configuration in agent response as backend changed

Signed-off-by: Heng Qian <[email protected]>

* Address comments and add changelog

Signed-off-by: Heng Qian <[email protected]>

* Address comments

Signed-off-by: Heng Qian <[email protected]>

* Add change in release notes

Signed-off-by: Heng Qian <[email protected]>

---------

Signed-off-by: Heng Qian <[email protected]>
(cherry picked from commit 913c47b)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md
  • Loading branch information
github-actions[bot] committed Jul 26, 2024
1 parent 80f64eb commit f399efa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 5 additions & 1 deletion release-notes/dashboards-assistant.release-notes-2.16.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
- 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))
7 changes: 5 additions & 2 deletions server/routes/get_agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
Expand Down

0 comments on commit f399efa

Please sign in to comment.