diff --git a/cmd/list/list.go b/cmd/list/list.go index 1db503f5..d82f74b2 100644 --- a/cmd/list/list.go +++ b/cmd/list/list.go @@ -7,6 +7,7 @@ import ( "github.com/cli/go-gh/v2/pkg/tableprinter" "github.com/github/gh-models/internal/azuremodels" "github.com/github/gh-models/pkg/command" + "github.com/MakeNowJust/heredoc" "github.com/mgutz/ansi" "github.com/spf13/cobra" ) @@ -20,6 +21,12 @@ func NewListCommand(cfg *command.Config) *cobra.Command { cmd := &cobra.Command{ Use: "list", Short: "List available models", + Long: heredoc.Docf(` + Returns a list of models that are available to use via the CLI. + + Values from the "MODEL NAME" column can be used as the %[1]s[model]%[1]s + argument in other commands. + `, "`"), Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { ctx := cmd.Context() diff --git a/cmd/list/list_test.go b/cmd/list/list_test.go index a0c462ad..0b564e74 100644 --- a/cmd/list/list_test.go +++ b/cmd/list/list_test.go @@ -55,7 +55,7 @@ func TestList(t *testing.T) { err := listCmd.Help() require.NoError(t, err) - require.Contains(t, outBuf.String(), "List available models") + require.Contains(t, outBuf.String(), "Returns a list of models that are available to use via the CLI.\n\nValues from the \"MODEL NAME\" column can be used as the `[model]`\nargument in other commands.") require.Empty(t, errBuf.String()) }) } diff --git a/cmd/root.go b/cmd/root.go index 24f958f4..4b1775f1 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -13,6 +13,7 @@ import ( "github.com/github/gh-models/internal/azuremodels" "github.com/github/gh-models/pkg/command" "github.com/github/gh-models/pkg/util" + "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" ) @@ -21,6 +22,16 @@ func NewRootCommand() *cobra.Command { cmd := &cobra.Command{ Use: "models", Short: "GitHub Models extension", + Long: heredoc.Docf(` + GitHub Models CLI extension allows you to experiment with AI models from the command line. + + To see a list of all available commands, run %[1]sgh models help%[1]s. To run the extension in + interactive mode, run %[1]sgh models run%[1]s. This will prompt you to select a model and then + enter a prompt. The extension will then return a response from the model. + + For more information about what you can do with GitHub Models extension, see the manual + at https://github.com/github/gh-models/blob/main/README.md. + `, "`"), } terminal := term.FromEnv() diff --git a/cmd/run/run.go b/cmd/run/run.go index ad966263..fab9eee1 100644 --- a/cmd/run/run.go +++ b/cmd/run/run.go @@ -18,6 +18,7 @@ import ( "github.com/github/gh-models/internal/sse" "github.com/github/gh-models/pkg/command" "github.com/github/gh-models/pkg/util" + "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" "github.com/spf13/pflag" ) @@ -192,6 +193,19 @@ func NewRunCommand(cfg *command.Config) *cobra.Command { cmd := &cobra.Command{ Use: "run [model] [prompt]", Short: "Run inference with the specified model", + Long: heredoc.Docf(` + Prompts the specified model with the given prompt. + + Use %[1]sgh models run%[1]s to run in interactive mode. It will provide a list of the current + models and allow you to select the one you want to run an inference with. After you select the model + you will be able to enter the prompt you want to run via the selected model. + + If you know which model you want to run inference with, you can run the request in a single command + as %[1]sgh models run [model] [prompt]%[1]s + + The return value will be the response to your prompt from the selected model. + `, "`"), + Example: "gh models run gpt-4o-mini \"how many types of hyena are there?\"", Args: cobra.ArbitraryArgs, RunE: func(cmd *cobra.Command, args []string) error { cmdHandler := newRunCommandHandler(cmd, cfg, args) diff --git a/cmd/run/run_test.go b/cmd/run/run_test.go index a9f8da17..b9ae85d0 100644 --- a/cmd/run/run_test.go +++ b/cmd/run/run_test.go @@ -73,7 +73,7 @@ func TestRun(t *testing.T) { require.NoError(t, err) output := outBuf.String() - require.Contains(t, output, "Run inference with the specified model") + require.Contains(t, output, "Use `gh models run` to run in interactive mode. It will provide a list of the current\nmodels and allow you to select the one you want to run an inference with.") require.Regexp(t, regexp.MustCompile(`--max-tokens string\s+Limit the maximum tokens for the model response\.`), output) require.Regexp(t, regexp.MustCompile(`--system-prompt string\s+Prompt the system\.`), output) require.Regexp(t, regexp.MustCompile(`--temperature string\s+Controls randomness in the response, use lower to be more deterministic\.`), output) diff --git a/cmd/view/view.go b/cmd/view/view.go index 1a547d62..89b24ab5 100644 --- a/cmd/view/view.go +++ b/cmd/view/view.go @@ -7,6 +7,7 @@ import ( "github.com/AlecAivazis/survey/v2" "github.com/github/gh-models/internal/azuremodels" "github.com/github/gh-models/pkg/command" + "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" ) @@ -15,6 +16,16 @@ func NewViewCommand(cfg *command.Config) *cobra.Command { cmd := &cobra.Command{ Use: "view [model]", Short: "View details about a model", + Long: heredoc.Docf(` + Returns details about the specified model. + + Use %[1]sgh models view%[1]s to run in interactive mode. It will provide a list of the current + models and allow you to select the one you want information about. + + If you know which model you want information for, you can run the request in a single command + as %[1]sgh models view [model]%[1]s + `, "`"), + Example: "gh models view gpt-4o", Args: cobra.ArbitraryArgs, RunE: func(cmd *cobra.Command, args []string) error { ctx := cmd.Context() diff --git a/cmd/view/view_test.go b/cmd/view/view_test.go index 537c968b..3cf252b3 100644 --- a/cmd/view/view_test.go +++ b/cmd/view/view_test.go @@ -98,7 +98,7 @@ func TestView(t *testing.T) { err := viewCmd.Help() require.NoError(t, err) - require.Contains(t, outBuf.String(), "View details about a model") + require.Contains(t, outBuf.String(), "Use `gh models view` to run in interactive mode. It will provide a list of the current\nmodels and allow you to select the one you want information about.") require.Empty(t, errBuf.String()) }) } diff --git a/go.mod b/go.mod index 9b73ace2..27c75700 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,7 @@ toolchain go1.22.8 require ( github.com/AlecAivazis/survey/v2 v2.3.7 + github.com/MakeNowJust/heredoc v1.0.0 github.com/briandowns/spinner v1.23.1 github.com/cli/cli/v2 v2.58.0 github.com/cli/go-gh/v2 v2.10.0