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

feat: add bedrock runtime agent for knowledge base #2651

Merged

Conversation

yuye-aws
Copy link
Member

@yuye-aws yuye-aws commented Jul 16, 2024

Description

Enable users to register bedrock runtime agent for calling bedrock knowledge base.

Issues Resolved

POST /_plugins/_ml/connectors/_create
{
  "name": "Amazon Bedrock Connector: knowledge",
  "description": "The connector to the Bedrock knowledge base",
  "version": 1,
  "protocol": "aws_sigv4",
  "parameters": {
    "region": "...",
    "service_name": "bedrock"
  },
  "credential": {
    "access_key": "...",
    "secret_key": "..."
  },
  "actions": [
    {
      "action_type": "predict",
      "method": "POST",
      "url": "...",
      "headers": {
        "content-type": "application/json",
        "x-amz-content-sha256": "required"
      },
      "request_body": "{\"retrievalQuery\": {\"text\": \"${parameters.text}\"}}"
    }
  ]
}

POST /_plugins/_ml/models/_register?deploy=true
{
  "name": "bedrock: knowledge base",
  "function_name": "remote",
  "description": "Test connector for bedrock knowledge base",
  "connector_id": <connector_id>
}

POST /_plugins/_ml/models/<model_id>/_predict/
{
  "parameters": {
    "text": "aws 2021"
  }
}

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc 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.

xinyual
xinyual previously approved these changes Jul 16, 2024
Signed-off-by: yuye-aws <[email protected]>
@yuye-aws yuye-aws temporarily deployed to ml-commons-cicd-env July 16, 2024 08:48 — with GitHub Actions Inactive
@yuye-aws yuye-aws temporarily deployed to ml-commons-cicd-env July 16, 2024 08:48 — with GitHub Actions Inactive
@yuye-aws yuye-aws requested a review from xinyual July 16, 2024 08:51
@yuye-aws yuye-aws temporarily deployed to ml-commons-cicd-env July 16, 2024 09:46 — with GitHub Actions Inactive
@@ -144,7 +144,8 @@ private MLCommonsSettings() {}
"^https://runtime\\.sagemaker\\..*[a-z0-9-]\\.amazonaws\\.com/.*$",
"^https://api\\.openai\\.com/.*$",
"^https://api\\.cohere\\.ai/.*$",
"^https://bedrock-runtime\\..*[a-z0-9-]\\.amazonaws\\.com/.*$"
"^https://bedrock-runtime\\..*[a-z0-9-]\\.amazonaws\\.com/.*$",
"^https://bedrock-agent-runtime\\..*[a-z0-9-]\\.amazonaws\\.com/.*$"
Copy link
Contributor

Choose a reason for hiding this comment

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

should we combine these two bedrock endpoint into one?

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you mean regex like the following?
^https://(?:bedrock-runtime|bedrock-agent-runtime)\\..*[a-z0-9-]\\.amazonaws\\.com/.*$

But I think the current code is more readable, so I prefer remain unchanged.

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean bedrock.* to include all bedrock related, so we don't need to add more if there has another bedrock-xyz. I think it's ok to keep as two for now and merge into one if we have more bedrock endpoints comes after.

@ylwu-amzn ylwu-amzn merged commit 226e53f into opensearch-project:main Jul 18, 2024
7 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Jul 18, 2024
* add bedrock runtime agent for knowledge base

Signed-off-by: yuye-aws <[email protected]>

* update unit test

Signed-off-by: yuye-aws <[email protected]>

---------

Signed-off-by: yuye-aws <[email protected]>
(cherry picked from commit 226e53f)
b4sjoo pushed a commit that referenced this pull request Jul 18, 2024
* add bedrock runtime agent for knowledge base

Signed-off-by: yuye-aws <[email protected]>

* update unit test

Signed-off-by: yuye-aws <[email protected]>

---------

Signed-off-by: yuye-aws <[email protected]>
(cherry picked from commit 226e53f)

Co-authored-by: yuye-aws <[email protected]>
@yuye-aws yuye-aws deleted the feat/KnowledgeBaseConnector branch July 24, 2024 06:32
@b4sjoo b4sjoo added the v2.16.0 Issues targeting release v2.16.0 label Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x v2.16.0 Issues targeting release v2.16.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants