Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose a general function for agent execution #268

Conversation

ruanyl
Copy link
Member

@ruanyl ruanyl commented Sep 4, 2024

Description

This PR adds an assistant client to both public(UI) and server which currently exposes the agent execute API

Issues Resolved

[List any issues this PR will resolve]

Check List

  • New functionality includes testing.
    • All tests pass, including unit test, integration test.
  • New functionality has user manual doc added.
  • Commits are signed per the DCO using --signoff.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Yulong Ruan <ruanyl@amazon.com>
Signed-off-by: Yulong Ruan <ruanyl@amazon.com>
Signed-off-by: Yulong Ruan <ruanyl@amazon.com>
Comment on lines 43 to 45
agentName: string,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
parameters: Record<string, any>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to support executeAgent with agent id?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also considered this, but we don't have use case at the moment which requires to execute agent with id directly, so I decided to not add it for now, we can add it when it's needed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Knowledge base needs to execute by agent id directly

Copy link
Collaborator

@Hailong-am Hailong-am Sep 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@qianheng-aws may have a requirement to execute agent id directly

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, let me add that

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Hailong-am @qianheng-aws Updated, could you take another look?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Signed-off-by: Yulong Ruan <ruanyl@amazon.com>
Copy link
Contributor

@chishui chishui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we allow other plugins to overwrite assistantClient and provide their own customized functionalities?

Signed-off-by: Yulong Ruan <ruanyl@amazon.com>
Signed-off-by: Yulong Ruan <ruanyl@amazon.com>
@ruanyl
Copy link
Member Author

ruanyl commented Sep 4, 2024

How do we allow other plugins to overwrite assistantClient and provide their own customized functionalities?

Could you provide a use case or example?

@gaobinlong gaobinlong added backport 2.x Trigger the backport flow to 2.x v2.17.0 labels Sep 4, 2024
Signed-off-by: gaobinlong <gbinlong@amazon.com>
Copy link
Collaborator

@gaobinlong gaobinlong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

constructor(private http: HttpSetup) {}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
executeAgent = (agentId: string, parameters: Record<string, any>, options?: Options) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will there be chance that executeAgent and executeAgentByName combined to be one API? Seems the only difference is that they pass different parameters in the query field

Otherwise, we need to add active method in both these 2 functions.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the APIs of public(UI), they will call the corresponding server APIs, and in server side, they will end up with calling one single function.

@ruanyl ruanyl merged commit 88aa96b into opensearch-project:main Sep 5, 2024
8 of 9 checks passed
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 128

To backport manually, run these commands in your terminal:

# Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/dashboards-assistant/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/dashboards-assistant/backport-2.x
# Create a new branch
git switch --create backport/backport-268-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 88aa96b70df878dffccc689811c7ded29a7d490d
# Push it to GitHub
git push --set-upstream origin backport/backport-268-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/dashboards-assistant/backport-2.x

Then, create a pull request where the base branch is 2.x and the compare/head branch is backport/backport-268-to-2.x.

@ruanyl ruanyl added backport 2.x Trigger the backport flow to 2.x and removed backport 2.x Trigger the backport flow to 2.x labels Sep 6, 2024
opensearch-trigger-bot bot pushed a commit that referenced this pull request Sep 6, 2024
* feat: add assistant client to public and server

Signed-off-by: Yulong Ruan <ruanyl@amazon.com>

* tweaks

Signed-off-by: Yulong Ruan <ruanyl@amazon.com>

* fix path

Signed-off-by: Yulong Ruan <ruanyl@amazon.com>

* update changelog

Signed-off-by: Yulong Ruan <ruanyl@amazon.com>

* feat: support both execute agent by name and by id

Signed-off-by: Yulong Ruan <ruanyl@amazon.com>

* fix(public): support execute agent by name or id

Signed-off-by: Yulong Ruan <ruanyl@amazon.com>

---------

Signed-off-by: Yulong Ruan <ruanyl@amazon.com>
Signed-off-by: gaobinlong <gbinlong@amazon.com>
Co-authored-by: gaobinlong <gbinlong@amazon.com>
(cherry picked from commit 88aa96b)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.17 failed:

The process '/usr/bin/git' failed with exit code 128

To backport manually, run these commands in your terminal:

# Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/dashboards-assistant/backport-2.17 2.17
# Navigate to the new working tree
pushd ../.worktrees/dashboards-assistant/backport-2.17
# Create a new branch
git switch --create backport/backport-268-to-2.17
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 88aa96b70df878dffccc689811c7ded29a7d490d
# Push it to GitHub
git push --set-upstream origin backport/backport-268-to-2.17
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/dashboards-assistant/backport-2.17

Then, create a pull request where the base branch is 2.17 and the compare/head branch is backport/backport-268-to-2.17.

@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.17 failed:

The process '/usr/bin/git' failed with exit code 128

To backport manually, run these commands in your terminal:

# Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/dashboards-assistant/backport-2.17 2.17
# Navigate to the new working tree
pushd ../.worktrees/dashboards-assistant/backport-2.17
# Create a new branch
git switch --create backport/backport-268-to-2.17
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 88aa96b70df878dffccc689811c7ded29a7d490d
# Push it to GitHub
git push --set-upstream origin backport/backport-268-to-2.17
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/dashboards-assistant/backport-2.17

Then, create a pull request where the base branch is 2.17 and the compare/head branch is backport/backport-268-to-2.17.

ruanyl added a commit to ruanyl/dashboards-assistant that referenced this pull request Sep 6, 2024
* feat: add assistant client to public and server

Signed-off-by: Yulong Ruan <ruanyl@amazon.com>

* tweaks

Signed-off-by: Yulong Ruan <ruanyl@amazon.com>

* fix path

Signed-off-by: Yulong Ruan <ruanyl@amazon.com>

* update changelog

Signed-off-by: Yulong Ruan <ruanyl@amazon.com>

* feat: support both execute agent by name and by id

Signed-off-by: Yulong Ruan <ruanyl@amazon.com>

* fix(public): support execute agent by name or id

Signed-off-by: Yulong Ruan <ruanyl@amazon.com>

---------

Signed-off-by: Yulong Ruan <ruanyl@amazon.com>
Signed-off-by: gaobinlong <gbinlong@amazon.com>
Co-authored-by: gaobinlong <gbinlong@amazon.com>
ruanyl pushed a commit that referenced this pull request Sep 6, 2024
* feat: add assistant client to public and server

Signed-off-by: Yulong Ruan <ruanyl@amazon.com>

* tweaks

Signed-off-by: Yulong Ruan <ruanyl@amazon.com>

* fix path

Signed-off-by: Yulong Ruan <ruanyl@amazon.com>

* update changelog

Signed-off-by: Yulong Ruan <ruanyl@amazon.com>

* feat: support both execute agent by name and by id

Signed-off-by: Yulong Ruan <ruanyl@amazon.com>

* fix(public): support execute agent by name or id

Signed-off-by: Yulong Ruan <ruanyl@amazon.com>

---------

Signed-off-by: Yulong Ruan <ruanyl@amazon.com>
Signed-off-by: gaobinlong <gbinlong@amazon.com>
Co-authored-by: gaobinlong <gbinlong@amazon.com>
(cherry picked from commit 88aa96b)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
ruanyl added a commit that referenced this pull request Sep 6, 2024
* feat: add assistant client to public and server



* tweaks



* fix path



* update changelog



* feat: support both execute agent by name and by id



* fix(public): support execute agent by name or id



---------

Signed-off-by: Yulong Ruan <ruanyl@amazon.com>
Signed-off-by: gaobinlong <gbinlong@amazon.com>
Co-authored-by: gaobinlong <gbinlong@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants