boto / boto3

AWS SDK for Python
https://aws.amazon.com/sdk-for-python/
Apache License 2.0
9.06k stars 1.87k forks source link

'Bedrock' object has no attribute 'invoke-model' #3881

Closed redsting closed 1 year ago

redsting commented 1 year ago

Describe the bug

boto3

boto3 version 1.28.57

Bedrock object returns attribute error for invoke_model AttributeError: 'Bedrock' object has no attribute 'invoke_model'

bedrock object instantiates fine bedrock = boto3.client('bedrock', endpoint_url='https://invoke-bedrock.us-east-1.amazonaws.com')

running the example code for an image generation causes the error image_data = bedrock.invoke_model(body = body, modelId = modelId, contentType = contentType, accept = accept)

Expected Behavior

boto3.client('bedrock') should have invoke_model.

Current Behavior

invoke_model and invoke_model_with_stream both return AttributeErrors

Reproduction Steps

import boto3 import json

bedrock = boto3.client('bedrock', endpoint_url='https://invoke-bedrock.us-east-1.amazonaws.com')

modelId = "stability.stable-diffusion-xl-v0" contentType = "application/json" accept = "/" body = json.dumps({"inputText": "A kitten on a rock playing with a ball of string"})

image_data = bedrock.invoke_model(body = body, modelId = modelId, contentType = contentType, accept = accept)

Possible Solution

No response

Additional Information/Context

No response

SDK version used

1.28.57

Environment details (OS name and version, etc.)

IntelliJ with jupyter notebook running under Windows 11.

tim-finnigan commented 1 year ago

Hi @redsting thanks for reaching out. It looks like you want to use bedrock-runtime for the invoke_model command. Here are the documentation pages for the bedrock and bedrock-runtime services:

redsting commented 1 year ago

Thanks. The link was somewhere on Amazon's site when it referenced, but this extra link fixes the runtime issue that was also referenced in the old documentation.

github-actions[bot] commented 1 year ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.

anniekmyatt commented 1 year ago

Is this issue fixed? I have

langchain==0.0.306
boto3==1.28.58
botocore==1.31.58

and the reproduction steps provided by @redsting redsting still give the same error: AttributeError: 'Bedrock' object has no attribute 'invoke_model'"?

Thank you!

redsting commented 1 year ago

Hi,       The documentation was older. The service name when you instantiate that boto3.client object needs to be updated to "bedrock-runtime" and that should fix it.

https://docs.aws.amazon.com/pdfs/bedrock/latest/userguide/bedrock-ug.pdf

Joe


From: anniekmyatt @.> Sent: Tuesday, October 3, 2023 6:33 AM To: boto/boto3 @.> Cc: Joe Webb @.>; Mention @.> Subject: Re: [boto/boto3] 'Bedrock' object has no attribute 'invoke-model' (Issue #3881)

Is this issue fixed? I have

langchain==0.0.306 boto3==1.28.58 botocore==1.31.58

and the reproduction steps provided by @redstinghttps://github.com/redsting redsting still give the same error: AttributeError: 'Bedrock' object has no attribute 'invoke_model'"?

Thank you!

— Reply to this email directly, view it on GitHubhttps://github.com/boto/boto3/issues/3881#issuecomment-1744874212, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ALJ4RKVNXL6TRLNGBETYQ6DX5QAZHAVCNFSM6AAAAAA5LUTS2WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONBUHA3TIMRRGI. You are receiving this because you were mentioned.Message ID: @.***>

anniekmyatt commented 1 year ago

Hello Joe,

Thank you for your quick reply! Yep, that works now. It helps to read the instructions 🤦‍♀️ .

Thanks again!

Best wishes, Anniek

redsting commented 1 year ago

No worries. The link on the boto3 versioning page was older docs that didn’t break out the models or give the right service names. Once the boto3 service team pointed to the right docs, everything worked as expected.

Thanks, Joe

On Oct 3, 2023, at 2:05 PM, anniekmyatt @.***> wrote:



Hello Joe,

Thank you for your quick reply! Yep, that works now. It helps to read the instructions 🤦‍♀️ .

Thanks again!

Best wishes, Anniek

— Reply to this email directly, view it on GitHubhttps://github.com/boto/boto3/issues/3881#issuecomment-1745644838, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ALJ4RKRQ2PCPDAFEVWASIADX5RVZLAVCNFSM6AAAAAA5LUTS2WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONBVGY2DIOBTHA. You are receiving this because you were mentioned.Message ID: @.***>