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

Bedrock - Add way to identify which models an account currently has access to #4241

Closed
1 of 2 tasks
cohml opened this issue Aug 15, 2024 · 4 comments
Closed
1 of 2 tasks
Assignees
Labels
feature-request This issue requests a feature. p3 This is a minor priority issue

Comments

@cohml
Copy link

cohml commented Aug 15, 2024

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 boto3 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 boto3.client('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:

>>> import boto3, json
>>> bedrock = boto3.client('bedrock')
>>> model_summaries = bedrock.list_foundation_models()['modelSummaries']
>>> print(json.dumps(model_summaries[0], indent=4))
{
    "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.,

{
    "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, one could simply traverse the dictionary and filter where "accessGranted" is True. This would probably be much easier and more widely useful than introducing a dedicated method like boto3.client('bedrock').list_accessed_models().

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

SDK version used

1.34.159

Environment details (OS name and version, etc.)

MacOS Sonoma 14.5

@cohml cohml added feature-request This issue requests a feature. needs-triage This issue or PR still needs to be triaged. labels Aug 15, 2024
@cohml
Copy link
Author

cohml commented Aug 15, 2024

See sister issue for AWS CLI: aws/aws-sdk#810

@RyanFitzSimmonsAK RyanFitzSimmonsAK self-assigned this Aug 16, 2024
@RyanFitzSimmonsAK RyanFitzSimmonsAK added investigating This issue is being investigated and/or work is in progress to resolve the issue. p3 This is a minor priority issue and removed needs-triage This issue or PR still needs to be triaged. labels Aug 16, 2024
@RyanFitzSimmonsAK RyanFitzSimmonsAK removed the investigating This issue is being investigated and/or work is in progress to resolve the issue. label Aug 23, 2024
@RyanFitzSimmonsAK
Copy link
Contributor

Closing as per aws/aws-sdk#810 (comment)

Copy link

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

@HasseJohansen
Copy link

If you need it now. I think you can exploit that the console actually can show if access is granted. By calling the api the console uses like this:

https --auth-type aws4 GET https://bedrock.eu-central-1.amazonaws.com/foundation-model-availability/amazon.titan-embed-text-v2%3A0
HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 213
Content-Type: application/json
Date: Wed, 18 Dec 2024 09:44:04 GMT
x-amzn-RequestId: de8b100f-f97e-4080-a940-0d1a71ae669f

{
    "agreementAvailability": {
        "errorMessage": null,
        "status": "AVAILABLE"
    },
    "authorizationStatus": "AUTHORIZED",
    "entitlementAvailability": "AVAILABLE",
    "modelId": "amazon.titan-embed-text-v2",
    "regionAvailability": "AVAILABLE"
}

entitlementAvailability is what you are looking for the. The console list all the foundation models (like list-foundation-models available in boto3 and the aws-cli). Then it run each of them through https://bedrock.eu-central-1.amazonaws.com/foundation-model-availability/ to check entitlementStatus (This solution doesn't really seems effective at the scale like AWS where a filter on the list-foundation-models would be much more effective)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request This issue requests a feature. p3 This is a minor priority issue
Projects
None yet
Development

No branches or pull requests

3 participants