From fa846d3ab90057f1445c89822e7e2b2f293fd963 Mon Sep 17 00:00:00 2001 From: Daniel Garman Date: Tue, 8 Oct 2024 10:27:31 -0400 Subject: [PATCH 1/3] Improve model run error message clarity 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. --- cmd/run/run.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd/run/run.go b/cmd/run/run.go index 6992888..dec8785 100644 --- a/cmd/run/run.go +++ b/cmd/run/run.go @@ -226,15 +226,17 @@ 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 := "" From 981a7b1cb77682587600c8c8dbf4abc70812a4fe Mon Sep 17 00:00:00 2001 From: Daniel Garman Date: Tue, 8 Oct 2024 12:02:10 -0400 Subject: [PATCH 2/3] Move empty model name to above iteration --- cmd/run/run.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cmd/run/run.go b/cmd/run/run.go index dec8785..b29970d 100644 --- a/cmd/run/run.go +++ b/cmd/run/run.go @@ -226,6 +226,11 @@ func NewRunCommand() *cobra.Command { modelName = args[0] } + noMatchErrorMessage := "The specified model name is not found. Run 'gh models list' to see available models or 'gh models run' to select interactively." + if modelName == "" { + return errors.New(noMatchErrorMessage) + } + foundMatch := false for _, model := range models { if strings.EqualFold(model.FriendlyName, modelName) || strings.EqualFold(model.Name, modelName) { @@ -235,8 +240,8 @@ func NewRunCommand() *cobra.Command { } } - 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.") + if !foundMatch { + return errors.New(noMatchErrorMessage) } initialPrompt := "" From 1b69d4a02b7b313b590878663f3b550eb482bd83 Mon Sep 17 00:00:00 2001 From: Daniel Garman Date: Tue, 8 Oct 2024 12:18:00 -0400 Subject: [PATCH 3/3] Update cmd/run/run.go --- cmd/run/run.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/run/run.go b/cmd/run/run.go index b29970d..54dd471 100644 --- a/cmd/run/run.go +++ b/cmd/run/run.go @@ -227,6 +227,7 @@ func NewRunCommand() *cobra.Command { } noMatchErrorMessage := "The specified model name is not found. Run 'gh models list' to see available models or 'gh models run' to select interactively." + if modelName == "" { return errors.New(noMatchErrorMessage) }