From ce827139bb35bad5bbbd8d3cd1104fd6aac96c5d Mon Sep 17 00:00:00 2001 From: Ettore Di Giacinto Date: Sat, 24 Aug 2024 10:30:24 +0200 Subject: [PATCH] fix(p2p): correctly allow to pass extra args to llama.cpp (#3368) Signed-off-by: Ettore Di Giacinto --- core/cli/worker/worker_p2p.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/core/cli/worker/worker_p2p.go b/core/cli/worker/worker_p2p.go index a65d338175b0..adfd28190db9 100644 --- a/core/cli/worker/worker_p2p.go +++ b/core/cli/worker/worker_p2p.go @@ -8,6 +8,7 @@ import ( "fmt" "os" "os/exec" + "strings" "time" cliContext "github.com/mudler/LocalAI/core/cli/context" @@ -20,12 +21,12 @@ import ( type P2P struct { 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"` - RunnerAddress string `env:"LOCALAI_RUNNER_ADDRESS,RUNNER_ADDRESS" help:"Address of the llama-cpp-rpc-server"` - RunnerPort string `env:"LOCALAI_RUNNER_PORT,RUNNER_PORT" help:"Port of the llama-cpp-rpc-server"` - ExtraLLamaCPPArgs []string `env:"LOCALAI_EXTRA_LLAMA_CPP_ARGS,EXTRA_LLAMA_CPP_ARGS" help:"Extra arguments to pass to llama-cpp-rpc-server"` - Peer2PeerNetworkID string `env:"LOCALAI_P2P_NETWORK_ID,P2P_NETWORK_ID" help:"Network ID for P2P mode, can be set arbitrarly by the user for grouping a set of instances" group:"p2p"` + 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"` + RunnerAddress string `env:"LOCALAI_RUNNER_ADDRESS,RUNNER_ADDRESS" help:"Address of the llama-cpp-rpc-server"` + RunnerPort string `env:"LOCALAI_RUNNER_PORT,RUNNER_PORT" help:"Port of the llama-cpp-rpc-server"` + ExtraLLamaCPPArgs string `name:"llama-cpp-args" env:"LOCALAI_EXTRA_LLAMA_CPP_ARGS,EXTRA_LLAMA_CPP_ARGS" help:"Extra arguments to pass to llama-cpp-rpc-server"` + Peer2PeerNetworkID string `env:"LOCALAI_P2P_NETWORK_ID,P2P_NETWORK_ID" help:"Network ID for P2P mode, can be set arbitrarly by the user for grouping a set of instances" group:"p2p"` } func (r *P2P) Run(ctx *cliContext.Context) error { @@ -76,8 +77,8 @@ func (r *P2P) Run(ctx *cliContext.Context) error { "util", "llama-cpp-rpc-server", ) - - args := append([]string{"--host", address, "--port", fmt.Sprint(port)}, r.ExtraLLamaCPPArgs...) + extraArgs := strings.Split(r.ExtraLLamaCPPArgs, " ") + args := append([]string{"--host", address, "--port", fmt.Sprint(port)}, extraArgs...) args, grpcProcess = library.LoadLDSO(r.BackendAssetsPath, args, grpcProcess) cmd := exec.Command(