diff --git a/core/cli/explorer.go b/core/cli/explorer.go index 1997effae..e0ec8572e 100644 --- a/core/cli/explorer.go +++ b/core/cli/explorer.go @@ -12,7 +12,7 @@ import ( ) type ExplorerCMD struct { - P2PEnableLimits string `env:"LOCALAI_P2P_ENABLE_LIMITS" help:"Set to true to enable P2P resource limits" group:"p2p"` + P2PEnableLimits string `name:"p2p-enable-limits" env:"LOCALAI_P2P_ENABLE_LIMITS" help:"Set to true to enable P2P resource limits" group:"p2p"` Address string `env:"LOCALAI_ADDRESS,ADDRESS" default:":8080" help:"Bind address for the API server" group:"api"` PoolDatabase string `env:"LOCALAI_POOL_DATABASE,POOL_DATABASE" default:"explorer.json" help:"Path to the pool database" group:"api"` ConnectionTimeout string `env:"LOCALAI_CONNECTION_TIMEOUT,CONNECTION_TIMEOUT" default:"2m" help:"Connection timeout for the explorer" group:"api"` diff --git a/core/cli/p2p_worker_hint_test.go b/core/cli/p2p_worker_hint_test.go index f28194f2a..378920a15 100644 --- a/core/cli/p2p_worker_hint_test.go +++ b/core/cli/p2p_worker_hint_test.go @@ -56,4 +56,23 @@ var _ = Describe("P2P limits CLI boundary", func() { Expect(explorer.P2PEnableLimits == "true").To(Equal(value == "true")) } }) + + It("accepts the documented --p2p-enable-limits flag at every entry point", func() { + GinkgoT().Setenv("LOCALAI_P2P_ENABLE_LIMITS", "") + run := RunCMD{} + rpc := worker.P2P{} + mlx := worker.P2PMLX{} + explorer := ExplorerCMD{} + entries := map[string]*string{ + "run": &run.P2PEnableLimits, "rpc": &rpc.P2PEnableLimits, + "mlx": &mlx.P2PEnableLimits, "explorer": &explorer.P2PEnableLimits, + } + for name, entry := range map[string]any{"run": &run, "rpc": &rpc, "mlx": &mlx, "explorer": &explorer} { + parser, err := kong.New(entry, kong.Vars{"basepath": ".", "generatedcontentpath": ".", "uploadpath": ".", "galleries": config.DefaultGalleriesJSON, "backends": config.DefaultBackendGalleriesJSON, "version": "test"}) + Expect(err).NotTo(HaveOccurred()) + _, err = parser.Parse([]string{"--p2p-enable-limits=true"}) + Expect(err).NotTo(HaveOccurred(), name) + Expect(*entries[name]).To(Equal("true"), name) + } + }) }) diff --git a/core/cli/run.go b/core/cli/run.go index a3d692bc0..aa5bbc4b9 100644 --- a/core/cli/run.go +++ b/core/cli/run.go @@ -40,7 +40,7 @@ import ( const workerJoinCommand = "local-ai p2p-worker p2p-llama-cpp-rpc" type RunCMD struct { - P2PEnableLimits string `env:"LOCALAI_P2P_ENABLE_LIMITS" help:"Set to true to enable P2P resource limits" group:"p2p"` + P2PEnableLimits string `name:"p2p-enable-limits" env:"LOCALAI_P2P_ENABLE_LIMITS" help:"Set to true to enable P2P resource limits" group:"p2p"` AddonHostPolicy string `name:"addon-host-policy" env:"LOCALAI_ADDON_HOST_POLICY" help:"Absolute path to administrator host operation policy JSON, read once at startup. Empty disables environment policy" group:"addons"` AddonHostOps string `name:"addon-host-ops" env:"LOCALAI_ADDON_HOST_OPS" help:"Add-ons that may call host operations, as a comma list of addon-id=operation-prefix. An add-on that is not listed gets no host operation channel. Empty gives none" group:"addons"` AddonsEnabled bool `name:"addons-enabled" env:"LOCALAI_ADDONS_ENABLED" default:"true" help:"Run the add-on owner, which installs and supervises add-ons. Turn it off with --addons-enabled=false" group:"addons"` diff --git a/core/cli/worker/worker_p2p.go b/core/cli/worker/worker_p2p.go index 16493394d..b1bf616a7 100644 --- a/core/cli/worker/worker_p2p.go +++ b/core/cli/worker/worker_p2p.go @@ -17,7 +17,7 @@ import ( ) type P2P struct { - P2PEnableLimits string `env:"LOCALAI_P2P_ENABLE_LIMITS" help:"Set to true to enable P2P resource limits" group:"p2p"` + P2PEnableLimits string `name:"p2p-enable-limits" env:"LOCALAI_P2P_ENABLE_LIMITS" help:"Set to true to enable P2P resource limits" group:"p2p"` WorkerFlags `embed:""` Token string `env:"LOCALAI_TOKEN,LOCALAI_P2P_TOKEN,TOKEN" help:"P2P token to use"` NoRunner bool `env:"LOCALAI_NO_RUNNER,NO_RUNNER" help:"Do not start the llama-cpp-rpc-server"` diff --git a/core/cli/worker/worker_p2p_mlx.go b/core/cli/worker/worker_p2p_mlx.go index 0285e9cb8..3f905191a 100644 --- a/core/cli/worker/worker_p2p_mlx.go +++ b/core/cli/worker/worker_p2p_mlx.go @@ -15,7 +15,7 @@ import ( ) type P2PMLX struct { - P2PEnableLimits string `env:"LOCALAI_P2P_ENABLE_LIMITS" help:"Set to true to enable P2P resource limits" group:"p2p"` + P2PEnableLimits string `name:"p2p-enable-limits" env:"LOCALAI_P2P_ENABLE_LIMITS" help:"Set to true to enable P2P resource limits" group:"p2p"` WorkerFlags `embed:""` Token string `env:"LOCALAI_TOKEN,LOCALAI_P2P_TOKEN,TOKEN" help:"P2P token to use"` Peer2PeerNetworkID string `env:"LOCALAI_P2P_NETWORK_ID,P2P_NETWORK_ID" help:"Network ID for P2P mode" group:"p2p"`