AWS bedrock documentation change
Summary
Replaced deprecated Invoke API example with Rerank API implementation using bedrock-agent-runtime client
Security assessment
Change updates API usage patterns but doesn't address security vulnerabilities or introduce security documentation. No evidence of security fixes.
Diff
diff --git a/bedrock/latest/userguide/model-card-cohere-rerank-3-5.md b/bedrock/latest/userguide/model-card-cohere-rerank-3-5.md index 03fb0853e..c73a2d524 100644 --- a//bedrock/latest/userguide/model-card-cohere-rerank-3-5.md +++ b//bedrock/latest/userguide/model-card-cohere-rerank-3-5.md @@ -98 +98 @@ Your AWS account has default quotas to maintain the performance of the service a -Invoke API +Rerank API @@ -102 +101,0 @@ Invoke API - import json @@ -105,7 +104,31 @@ Invoke API - client = boto3.client('bedrock-runtime', region_name='us-east-1') - response = client.invoke_model( - modelId='cohere.rerank-v3-5:0', - body=json.dumps({ - 'messages': [{ 'role': 'user', 'content': 'Can you explain the features of Amazon Bedrock?'}], - 'max_tokens': 1024 - }) + client = boto3.client('bedrock-agent-runtime', region_name='us-east-1') + response = client.rerank( + queries=[{ + 'type': 'TEXT', + 'textQuery': {'text': 'What is Amazon Bedrock?'} + }], + sources=[ + { + 'type': 'INLINE', + 'inlineDocumentSource': { + 'type': 'TEXT', + 'textDocument': {'text': 'Amazon Bedrock is a fully managed service for foundation models.'} + } + }, + { + 'type': 'INLINE', + 'inlineDocumentSource': { + 'type': 'TEXT', + 'textDocument': {'text': 'Amazon S3 is an object storage service.'} + } + } + ], + rerankingConfiguration={ + 'type': 'BEDROCK_RERANKING_MODEL', + 'bedrockRerankingConfiguration': { + 'modelConfiguration': { + 'modelArn': 'arn:aws:bedrock:us-east-1::foundation-model/cohere.rerank-v3-5:0' + }, + 'numberOfResults': 2 + } + } @@ -113 +136,2 @@ Invoke API - print(json.loads(response['body'].read())) + for result in response['results']: + print(f'Index: {result["index"]}, Score: {result["relevanceScore"]}')