aws / aws-sdk

Landing page for the AWS SDKs on GitHub
https://aws.amazon.com/tools/
Other
71 stars 14 forks source link

aws bedrock - Add way to identify which models an account currently has access to #810

Open cohml opened 1 month ago

cohml commented 1 month ago

Describe the feature

Currently is no way to programmatically inspect which foundation models my account has been granted access to. Something should be added to the AWS CLI to allow this information to be retrieved by external APIs.

Use Case

Example of when this feature would be useful:

I have been granted access to a subset of models on Bedrock. I also have a front end application through which users can interact with these models. So that my users know which models they can use, the front end displays the list of models. But this list grows over time as I request access to more and more models.

Currently, because this list cannot be fetched programmatically, I am forced to hardcode it inside my application's source code. But this increases the amount of code I must manually maintain. Alternatively, I could iterative over the list of all available models (so not just the subset I have access to), submit a request to each, and infer that I have access iff the request returns successfully. But this means starting my application would actually cost me extra money.

So neither of those solutions is ideal. Much better would be a dedicated, purpose-built method for programmatically determining which models I have access to, then showing this list to users.

Proposed Solution

The closest existing tool seems to be aws bedrock list-foundation-models. But this returns everything available on Bedrock, not just the subset of things which currently have access to. The returned models are structured as follows:

{
    "modelSummaries": [
        {
            "modelArn": "arn:aws:bedrock:us-east-1::foundation-model/amazon.titan-tg1-large",
            "modelId": "amazon.titan-tg1-large",
            "modelName": "Titan Text Large",
            "providerName": "Amazon",
            "inputModalities": [
                "TEXT"
            ],
            "outputModalities": [
                "TEXT"
            ],
            "responseStreamingSupported": true,
            "customizationsSupported": [],
            "inferenceTypesSupported": [
                "ON_DEMAND"
            ],
            "modelLifecycle": {
                "status": "ACTIVE"
            }
        },
        ...
    ],
    ...
}

IMHO, the cheapest/most extensible solution would be to add a new field into each entry, e.g.,

{
    "modelSummaries": [
        {
            "modelArn": "arn:aws:bedrock:us-east-1::foundation-model/amazon.titan-tg1-large",
            "modelId": "amazon.titan-tg1-large",
            "modelName": "Titan Text Large",
            "providerName": "Amazon",
            "inputModalities": [
                "TEXT"
            ],
            "outputModalities": [
                "TEXT"
            ],
            "responseStreamingSupported": true,
            "customizationsSupported": [],
            "inferenceTypesSupported": [
                "ON_DEMAND"
            ],
            "modelLifecycle": {
                "status": "ACTIVE"
            }
            "accessGranted": true  # <---- I PROPOSE ADDING A FIELD LIKE THIS
        },
        ...
    ],
    ...
}

That way, a simple jq query would be enough to filter the output down to the desired subset. This would probably be much easier and more widely useful than a dedicated flag like aws bedrock list-foundation-models --accessed or subcommand like aws bedrock list-accessed-models.

Other Information

No response

Acknowledgements

CLI version used

aws-cli/2.17.13 Python/3.11.9 Darwin/23.5.0 exe/x86_64

Environment details (OS name and version, etc.)

MacOS Sonoma 14.5

jettro commented 3 weeks ago

Would be great to have this. Having a filter like: byAccessStatus would be very useful

RyanFitzSimmonsAK commented 3 weeks ago

Hi @cohml, thanks for reaching out. I can definitely see how this operation would be useful. I've forwarded this feature request to the Bedrock team, and I'll let you know when I hear back with any updates. In the meantime, since this is a service API issue, I'm going to move this to our cross-SDK repository for tracking purposes. I'm also going close the issue you made in the boto3 repository. Thanks!

Ticket # for internal use : P150245745

cohml commented 3 weeks ago

Thanks @RyanFitzSimmonsAK

I've forwarded this feature request to the Bedrock team, and I'll let you know when I hear back with any updates.

Does that imply that this feature is something that will have to be turned on from within the walled garden of AWS, not something a random contributor like myself could volunteer to implement?

I was possibly interested in doing it myself, but I'm not at AWS, so...