@@ -58,6 +58,7 @@ var BEDROCKER_SUPPORTED_REGION = []string{
5858}
5959
6060var defaultModels = []bedrock_support.BedrockModel {
61+
6162 {
6263 Name : "us.anthropic.claude-3-7-sonnet-20250219-v1:0" ,
6364 Completion : & bedrock_support.CohereMessagesCompletion {},
@@ -311,7 +312,6 @@ func (a *AmazonBedRockClient) getModelFromString(model string) (*bedrock_support
311312
312313 // Trim spaces from the model name
313314 model = strings .TrimSpace (model )
314- modelLower := strings .ToLower (model )
315315
316316 // Try to find an exact match first
317317 for i := range a .models {
@@ -322,26 +322,27 @@ func (a *AmazonBedRockClient) getModelFromString(model string) (*bedrock_support
322322 }
323323 }
324324
325- // If no exact match, try partial match
326- for i := range a .models {
327- modelNameLower := strings . ToLower ( a . models [ i ]. Name )
328- modelConfigNameLower := strings . ToLower ( a . models [ i ]. Config . ModelName )
325+ supportedModels := make ([] string , len ( a . models ))
326+ for i , m := range a .models {
327+ supportedModels [ i ] = m . Name
328+ }
329329
330- // Check if the input string contains the model name or vice versa
331- if strings .Contains (modelNameLower , modelLower ) || strings .Contains (modelLower , modelNameLower ) ||
332- strings .Contains (modelConfigNameLower , modelLower ) || strings .Contains (modelLower , modelConfigNameLower ) {
333- // Create a copy to avoid returning a pointer to a loop variable
334- modelCopy := a .models [i ]
335- // for partial match, set the model name to the input string if it is a valid ARN
336- if validateModelArn (modelLower ) {
337- modelCopy .Config .ModelName = modelLower
338- }
330+ supportedRegions := BEDROCKER_SUPPORTED_REGION
339331
340- return & modelCopy , nil
341- }
332+ // Pretty-print supported models and regions
333+ modelList := ""
334+ for _ , m := range supportedModels {
335+ modelList += " - " + m + "\n "
336+ }
337+ regionList := ""
338+ for _ , r := range supportedRegions {
339+ regionList += " - " + r + "\n "
342340 }
343341
344- return nil , fmt .Errorf ("model '%s' not found in supported models" , model )
342+ return nil , fmt .Errorf (
343+ "model '%s' not found in supported models.\n \n Supported models:\n %sSupported regions:\n %s" ,
344+ model , modelList , regionList ,
345+ )
345346}
346347
347348// Configure configures the AmazonBedRockClient with the provided configuration.
@@ -415,7 +416,7 @@ func (a *AmazonBedRockClient) Configure(config IAIConfig) error {
415416 // Regular model ID provided
416417 foundModel , err := a .getModelFromString (modelInput )
417418 if err != nil {
418- return err
419+ return fmt . Errorf ( "model '%s' is not supported: %v" , modelInput , err )
419420 }
420421 a .model = foundModel
421422 a .model .Config .ModelName = foundModel .Config .ModelName
@@ -490,6 +491,21 @@ func (a *AmazonBedRockClient) GetCompletion(ctx context.Context, prompt string)
490491 a .model .Config .Temperature = a .temperature
491492 a .model .Config .TopP = a .topP
492493
494+ supportedModels := make ([]string , len (a .models ))
495+ for i , m := range a .models {
496+ supportedModels [i ] = m .Name
497+ }
498+
499+ if ! bedrock_support .IsModelSupported (a .model .Config .ModelName , supportedModels ) {
500+ return "" , fmt .Errorf ("model '%s' is not supported.\n Supported models:\n %s" , a .model .Config .ModelName , func () string {
501+ s := ""
502+ for _ , m := range supportedModels {
503+ s += " - " + m + "\n "
504+ }
505+ return s
506+ }())
507+ }
508+
493509 body , err := a .model .Completion .GetCompletion (ctx , prompt , a .model .Config )
494510 if err != nil {
495511 return "" , err
0 commit comments