From aefc7928db06fd50fcd37861f2912c2f66a40119 Mon Sep 17 00:00:00 2001 From: ai-jeannie Date: Thu, 24 Apr 2025 23:40:37 +1000 Subject: [PATCH 1/2] Add Bedrock functions for Anthropic model token limits MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added new bedrock-functions file with two commands: - bedrock-model-token-limits: Shows token rate limits for Anthropic models - bedrock-models: Lists all available foundation models in Bedrock 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- lib/bedrock-functions | 70 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 lib/bedrock-functions diff --git a/lib/bedrock-functions b/lib/bedrock-functions new file mode 100644 index 0000000..d06e23c --- /dev/null +++ b/lib/bedrock-functions @@ -0,0 +1,70 @@ +#!/bin/bash +# +# bedrock-functions + +bedrock-model-token-limits() { + # List token rate limits for Anthropic models + # + # $ bedrock-model-token-limits + # anthropic.claude-v2 100000 500000 10000000 + # anthropic.claude-v2:1 100000 500000 10000000 + # anthropic.claude-instant-v1 100000 500000 10000000 + # anthropic.claude-3-sonnet-20240229-v1:0 200000 1000000 20000000 + # anthropic.claude-3-haiku-20240307-v1:0 200000 1000000 20000000 + # anthropic.claude-3-opus-20240229-v1:0 200000 1000000 20000000 + + local model_ids=$(skim-stdin "$@") + local filters=$(__bma_read_filters $@) + + local column_command + if column --help 2>/dev/null | grep -- --table-right > /dev/null; then + column_command='column --table --table-right 2,3,4' + else + column_command='column -t' + fi + + # First list available models + aws bedrock list-foundation-models \ + --output text \ + --query "modelSummaries[?contains(modelId, 'anthropic')].[modelId]" | + sort | + while read -r model_id; do + # Only process models specified in arguments, or all if no arguments + if [[ -z "$model_ids" ]] || [[ "$model_ids" == *"$model_id"* ]]; then + # Get model details + aws bedrock get-foundation-model \ + --model-id "$model_id" \ + --output text \ + --query "[ + modelId, + inferenceTypesSupported[?inferenceType=='ON_DEMAND'].inferenceSpecificThrottling[0].throttlingValues[0].[rateLimit.requestsPerSecond, rateLimit.tokensPerMinute, rateLimit.tokenBucketCapacity] | [0][0][0], + inferenceTypesSupported[?inferenceType=='ON_DEMAND'].inferenceSpecificThrottling[0].throttlingValues[0].[rateLimit.requestsPerSecond, rateLimit.tokensPerMinute, rateLimit.tokenBucketCapacity] | [0][0][1], + inferenceTypesSupported[?inferenceType=='ON_DEMAND'].inferenceSpecificThrottling[0].throttlingValues[0].[rateLimit.requestsPerSecond, rateLimit.tokensPerMinute, rateLimit.tokenBucketCapacity] | [0][0][2] + ]" + fi + done | + grep -E -- "$filters" | + $column_command +} + +bedrock-models() { + # List available foundation models in AWS Bedrock + # + # $ bedrock-models + # amazon.titan-text-lite-v1 ACTIVE + # anthropic.claude-instant-v1 ACTIVE + # anthropic.claude-v2 ACTIVE + + local model_ids=$(skim-stdin "$@") + local filters=$(__bma_read_filters $@) + + aws bedrock list-foundation-models \ + --output text \ + --query "modelSummaries[].[ + modelId, + modelLifecycle.status + ]" | + grep -E -- "$filters" | + sort | + columnise +} \ No newline at end of file From ec6aa0b6744102c8eac510eb1b370721bd6ed0e5 Mon Sep 17 00:00:00 2001 From: ai-jeannie Date: Fri, 2 May 2025 17:33:44 +1000 Subject: [PATCH 2/2] Refactor bedrock-model-token-limits to use columnise function consistently MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove custom column formatting in bedrock-model-token-limits - Use columnise function to maintain consistency with project conventions - This change ensures the function works correctly without relying on custom column handling 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- lib/bedrock-functions | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/lib/bedrock-functions b/lib/bedrock-functions index d06e23c..a6682db 100644 --- a/lib/bedrock-functions +++ b/lib/bedrock-functions @@ -16,18 +16,11 @@ bedrock-model-token-limits() { local model_ids=$(skim-stdin "$@") local filters=$(__bma_read_filters $@) - local column_command - if column --help 2>/dev/null | grep -- --table-right > /dev/null; then - column_command='column --table --table-right 2,3,4' - else - column_command='column -t' - fi - # First list available models aws bedrock list-foundation-models \ --output text \ - --query "modelSummaries[?contains(modelId, 'anthropic')].[modelId]" | - sort | + --query "modelSummaries[?contains(modelId, 'anthropic')].[modelId]" |\ + sort |\ while read -r model_id; do # Only process models specified in arguments, or all if no arguments if [[ -z "$model_ids" ]] || [[ "$model_ids" == *"$model_id"* ]]; then @@ -42,9 +35,10 @@ bedrock-model-token-limits() { inferenceTypesSupported[?inferenceType=='ON_DEMAND'].inferenceSpecificThrottling[0].throttlingValues[0].[rateLimit.requestsPerSecond, rateLimit.tokensPerMinute, rateLimit.tokenBucketCapacity] | [0][0][2] ]" fi - done | - grep -E -- "$filters" | - $column_command + done |\ + grep -E -- "$filters" |\ + columnise + } bedrock-models() { @@ -63,8 +57,8 @@ bedrock-models() { --query "modelSummaries[].[ modelId, modelLifecycle.status - ]" | - grep -E -- "$filters" | - sort | + ]" |\ + grep -E -- "$filters" |\ + sort |\ columnise } \ No newline at end of file