Skip to content

Added KB examples and tests and updated metadata file #7451

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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

gausekha
Copy link

This pull request adds code examples for the APIs CreateKnowledgeBase, GetKnowledgeBase, UpdateKnowledgeBase, DeleteKnowledgeBase, and ListKnowledgeBases APIs. The same submission was made earlier but running the writeme created a large number of file diffs. This submission hopes to avoid such a large commit.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@github-actions github-actions bot added the Python This issue relates to the AWS SDK for Python (boto3) label May 16, 2025
DavidSouther and others added 3 commits May 19, 2025 14:23
…agraphs in incorrect segments to correct custom blocks. Some information was lost, for list flows, which does not have a current scenario in metadata.
parser = argparse.ArgumentParser(
description="Work with knowledge bases in your AWS account."
)
parser.add_argument(
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to run these steps together as a set? For example: Create a KnowledgeBase, List, Get, Update, then Delete? With the role created as part of the process? Otherwise the user has to know what the required Role will look like, and provide the arn. We try to have scenarios be self-contained. For more information, see the example standards. If this is not possible for some reason and an exception needs to be made, let us know.

Copy link
Member

Choose a reason for hiding this comment

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

Hey @gausekha, did you have a chance to review Rachel's note here?

Copy link
Author

Choose a reason for hiding this comment

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

Hey @rlhagerm and @beqqrry-aws my apologies got caught up with a few things and didn't get a chance! Shall check and get back on this. It should be possible to run the examples in a set using the created role shall confirm and get back on it.

Copy link
Author

Choose a reason for hiding this comment

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

@rlhagerm and @beqqrry-aws I just added the IAM role and a scenario: gausekha@0dec32e. I am trying to run this locally but keep running into an error about specifying the region. Could you please take a look?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @gausekha , I'm not getting any error about the region. Maybe you need to specify it in your profile? What I am getting is this, which seems to be a problem with the specified CollectionArn. I don't think it's supposed to be the same as the embeddingModelArn.

botocore.errorfactory.ValidationException: An error occurred (ValidationException) when calling the CreateKnowledgeBase operation: 1 validation error detected: Value 'arn:aws:bedrock:us-east-1::foundati on-model/amazon.titan-embed-text-v1' at 'storageConfiguration.opensearchServerlessConfiguration.collectionArn' failed to satisfy constraint: Member must satisfy regular expression pattern: arn:aws(-cn|- us-gov|-eusc|-iso(-[b-f])?)?:aoss:([a-z]{2,}-){2,}\d:\d{12}:collection/[a-z0-9-]{3,32}

Copy link
Author

Choose a reason for hiding this comment

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

Ah, I see - got it that makes sense. Shall update it, thanks for catching it! And yes, shall try to update my profile as well and get a clean build before pushing the next commit.

Copy link
Author

Choose a reason for hiding this comment

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

@rlhagerm Apologies for the back and forth! I tried updating the ARNs. Here's the commit: 9356a35. Please LMK if any additional updates are needed. Thanks!

Copy link
Author

Choose a reason for hiding this comment

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

@rlhagerm Please LMK once you have a chance to look at this. Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

Is the CollectionArn something the user is supposed to provide? It looks like what is in there now is a placeholder, which may be fine, but we should include some information on how to provide the correct value and/or replace it in the code.

"storageConfiguration": {
"type": "OPENSEARCH_SERVERLESS",
"opensearchServerlessConfiguration": {
"collectionArn": "arn:aws:aoss:us-east-1::123456789012:collection/abcdefgh12345678defgh",
Copy link
Contributor

Choose a reason for hiding this comment

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

So, does the collection arn come from a pre-existing collection? Does the user need to configure it somewhere first and provide it as an input? It seems unclear how the arn is set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Python This issue relates to the AWS SDK for Python (boto3)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants