@@ -107,31 +107,32 @@ def list_bedrock_models() -> dict:
107107
108108 if ENABLE_CROSS_REGION_INFERENCE :
109109 # List system defined inference profile IDs
110- response = bedrock_client .list_inference_profiles (maxResults = 1000 , typeEquals = "SYSTEM_DEFINED" )
111- profile_list = [p ["inferenceProfileId" ] for p in response ["inferenceProfileSummaries" ]]
110+ paginator = bedrock_client .get_paginator ('list_inference_profiles' )
111+ for page in paginator .paginate (maxResults = 1000 , typeEquals = "SYSTEM_DEFINED" ):
112+ profile_list .extend ([p ["inferenceProfileId" ] for p in page ["inferenceProfileSummaries" ]])
112113
113114 if ENABLE_APPLICATION_INFERENCE_PROFILES :
114115 # List application defined inference profile IDs and create mapping
115- response = bedrock_client .list_inference_profiles (maxResults = 1000 , typeEquals = "APPLICATION" )
116-
117- for profile in response ["inferenceProfileSummaries" ]:
118- try :
119- profile_arn = profile .get ("inferenceProfileArn" )
120- if not profile_arn :
116+ paginator = bedrock_client .get_paginator ('list_inference_profiles' )
117+ for page in paginator .paginate (maxResults = 1000 , typeEquals = "APPLICATION" ):
118+ for profile in page ["inferenceProfileSummaries" ]:
119+ try :
120+ profile_arn = profile .get ("inferenceProfileArn" )
121+ if not profile_arn :
122+ continue
123+
124+ # Process all models in the profile
125+ models = profile .get ("models" , [])
126+ for model in models :
127+ model_arn = model .get ("modelArn" , "" )
128+ if model_arn :
129+ model_id = model_arn .split ('/' )[- 1 ] if '/' in model_arn else model_arn
130+ if model_id :
131+ app_profile_dict [model_id ] = profile_arn
132+ except Exception as e :
133+ logger .warning (f"Error processing application profile: { e } " )
121134 continue
122135
123- # Process all models in the profile
124- models = profile .get ("models" , [])
125- for model in models :
126- model_arn = model .get ("modelArn" , "" )
127- if model_arn :
128- model_id = model_arn .split ('/' )[- 1 ] if '/' in model_arn else model_arn
129- if model_id :
130- app_profile_dict [model_id ] = profile_arn
131- except Exception as e :
132- logger .warning (f"Error processing application profile: { e } " )
133- continue
134-
135136 # List foundation models, only cares about text outputs here.
136137 response = bedrock_client .list_foundation_models (byOutputModality = "TEXT" )
137138
0 commit comments