|
| 1 | +package cmd |
| 2 | + |
| 3 | +import ( |
| 4 | + "github.com/julien040/anyquery/controller" |
| 5 | + "github.com/spf13/cobra" |
| 6 | +) |
| 7 | + |
| 8 | +var gptCmd = &cobra.Command{ |
| 9 | + Use: "gpt", |
| 10 | + Aliases: []string{"chat", "chatgpt"}, |
| 11 | + Short: "Open an HTTP server so that ChatGPT can do function calls", |
| 12 | + Long: `Open an HTTP server so that ChatGPT can do function calls. By default, it will expose a tunnel to the internet. |
| 13 | +By setting the --host or --port flags, you can disable the tunnel and bind to a specific host and port. In this case, you will need to configure your LLM to connect to this host and port.`, |
| 14 | + |
| 15 | + RunE: controller.Gpt, |
| 16 | +} |
| 17 | + |
| 18 | +var mcpCmd = &cobra.Command{ |
| 19 | + Use: "mcp", |
| 20 | + Short: "Start the Model Context Protocol (MCP) server", |
| 21 | + Long: `Start the Model Context Protocol (MCP) server. It is used to provide context for LLM that supports it. |
| 22 | +Pass the --stdio flag to use standard input/output for communication. By default, it will bind locally to localhost:8070 (modify it with the --host, --port and --domain flags). |
| 23 | +You can also expose the tunnel to the internet by using the --tunnel flag (useful when the LLM is on a remote server). |
| 24 | +`, |
| 25 | + RunE: controller.Mcp, |
| 26 | +} |
| 27 | + |
| 28 | +func init() { |
| 29 | + // GPT command |
| 30 | + rootCmd.AddCommand(gptCmd) |
| 31 | + addFlag_commandModifiesConfiguration(gptCmd) |
| 32 | + gptCmd.Flags().StringP("database", "d", "", "Database to connect to (a path or :memory:)") |
| 33 | + gptCmd.Flags().Bool("in-memory", false, "Use an in-memory database") |
| 34 | + gptCmd.Flags().Bool("readonly", false, "Open the SQLite database in read-only mode") |
| 35 | + gptCmd.Flags().Bool("read-only", false, "Open the SQLite database in read-only mode") |
| 36 | + gptCmd.Flags().StringSlice("extension", []string{}, "Load one or more extensions by specifying their path. Separate multiple extensions with a comma.") |
| 37 | + gptCmd.Flags().String("log-file", "", "Log file") |
| 38 | + gptCmd.Flags().String("log-level", "info", "Log level (trace, debug, info, warn, error, off)") |
| 39 | + gptCmd.Flags().String("log-format", "text", "Log format (text, json)") |
| 40 | + gptCmd.Flags().String("host", "", "Host to bind to. If not empty, the tunnel will be disabled") |
| 41 | + gptCmd.Flags().Int("port", 0, "Port to bind to. If not empty, the tunnel will be disabled") |
| 42 | + |
| 43 | + // MCP command |
| 44 | + rootCmd.AddCommand(mcpCmd) |
| 45 | + addFlag_commandModifiesConfiguration(mcpCmd) |
| 46 | + mcpCmd.Flags().String("host", "127.0.0.1", "Host to bind to") |
| 47 | + mcpCmd.Flags().String("domain", "", "Domain to use for the HTTP tunnel (empty to use the host)") |
| 48 | + mcpCmd.Flags().Int("port", 8070, "Port to bind to") |
| 49 | + mcpCmd.Flags().Bool("stdio", false, "Use standard input/output for communication") |
| 50 | + mcpCmd.Flags().Bool("tunnel", false, "Use an HTTP tunnel, and expose the server to the internet (when used, --host, --domain and --port are ignored)") |
| 51 | + mcpCmd.Flags().StringP("database", "d", "", "Database to connect to (a path or :memory:)") |
| 52 | + mcpCmd.Flags().Bool("in-memory", false, "Use an in-memory database") |
| 53 | + mcpCmd.Flags().Bool("readonly", false, "Open the SQLite database in read-only mode") |
| 54 | + mcpCmd.Flags().Bool("read-only", false, "Open the SQLite database in read-only mode") |
| 55 | + mcpCmd.Flags().StringSlice("extension", []string{}, "Load one or more extensions by specifying their path. Separate multiple extensions with a comma.") |
| 56 | + mcpCmd.Flags().String("log-file", "", "Log file") |
| 57 | + mcpCmd.Flags().String("log-level", "info", "Log level (trace, debug, info, warn, error, off)") |
| 58 | + mcpCmd.Flags().String("log-format", "text", "Log format (text, json)") |
| 59 | + |
| 60 | +} |
0 commit comments