-
Notifications
You must be signed in to change notification settings - Fork 81
Open
Description
SDK Version (required): 5.20.2
1. Bug: BedrockClientV2 SigV4 Host Header Mismatch
The BedrockClientV2 (via AwsClientV2) is currently broken for all Bedrock calls due to an incorrect host being used during the SigV4 calculation.
- The Cause:
AwsClientV2initializes with a hardcodedbase_url="https://api.cohere.com". While themap_request_to_bedrockevent hook updates therequest.urlandrequest.headers["host"]to the AWS endpoint, the CanonicalRequest used for signing is generated using the originalapi.cohere.comhost. - The Result: AWS rejects the request with a
403 Forbiddenbecause the signature tied toapi.cohere.comdoes not match the actual transport host (bedrock-runtime.{region}.amazonaws.com). - Evidence: Debug logs show the
CanonicalRequesthost asapi.cohere.com, while the finalhttpxdispatch is to the AWS Bedrock URL.
2. Bug: cohere_aws.Client Forced SageMaker Dependency
The manually maintained cohere.manually_maintained.cohere_aws.Client is intended to support both SageMaker and Bedrock. However, it is currently unusable for Bedrock-only users who do not have the sagemaker library installed.
- The Cause: The
__init__method of the client forcibly callslazy_sagemaker().Session(). - The Result: This triggers an
ImportErroreven if the user explicitly setsco.mode = Mode.BEDROCK. - Fix Required: The SageMaker session should be initialized lazily only when
Mode.SAGEMAKERis actually used.
**3. Improvement: Support for Embed v4 in cohere_aws.Client**
While BedrockClientV2 is broken, the alternative cohere_aws.Client lacks support for the new parameters introduced in Embed v4.
- The Issue: The
embedmethod in the manually maintained client is statically defined and does not accept or pass theoutput_dimensionparameter. - The Result: Users cannot utilize the selectable dimensionality (256, 512, 1024) features of Embed v4 via the SDK on Bedrock.
Steps to Reproduce (BedrockClientV2)
import cohere
# This will fail with 403 Forbidden due to Host signing mismatch
co = cohere.BedrockClientV2(aws_region='us-east-1')
co.embed(texts=['test'], model='cohere.embed-v4-0', input_type='search_document')Suggested Fixes
- **For
AwsClientV2**: Ensure thehttpx.Requesthost and URL are fully updated prior to theSigV4Authsigner being invoked so theCanonicalRequestuses the AWS host. - **For
cohere_aws.Client**: Guard thesagemaker.Sessioncreation so it doesn't block users who only haveboto3andbotocoreinstalled for Bedrock use. - For Embed v4: Update the
embedsignature in the manually maintained client to supportoutput_dimensionandembedding_types.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels