Skip to content

Commit

Permalink
Improve model run error message clarity
Browse files Browse the repository at this point in the history
This applies both for when an empty string or an incorrect model name
is specified. The prior had an error message already, but it was fairly
vague. The latter was using the default error output from later in
execution. This commit makes them consistent and more detailed,
providing two suggestions.
  • Loading branch information
garman committed Oct 8, 2024
1 parent 818e4a9 commit 8162419
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions cmd/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,16 +226,18 @@ func NewRunCommand() *cobra.Command {
modelName = args[0]
}

foundMatch := false
for _, model := range models {
if strings.EqualFold(model.FriendlyName, modelName) || strings.EqualFold(model.Name, modelName) {
modelName = model.Name
foundMatch = true
break
}
}
}

if modelName == "" {
return errors.New("the specified model name is not supported")
}
if !foundMatch || modelName == "" {
return errors.New("The specified model name is not found. Run 'gh models list' to see available models or 'gh models run' to select interactively.")
}

initialPrompt := ""
singleShot := false
Expand Down

0 comments on commit 8162419

Please sign in to comment.