From 29c0fec6cbd56cb3f9b17212ca76a1a0940cb3c6 Mon Sep 17 00:00:00 2001 From: Eric Curtin Date: Wed, 25 Sep 2024 11:36:06 +0100 Subject: [PATCH] llama-cli made a change Now instead of --log-disable we need to redirect stderr to /dev/null: https://github.com/ggerganov/llama.cpp/pull/9418 Signed-off-by: Eric Curtin --- ramalama/common.py | 8 +++++++- ramalama/model.py | 3 +-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ramalama/common.py b/ramalama/common.py index 2a1985eb..579ec1b5 100644 --- a/ramalama/common.py +++ b/ramalama/common.py @@ -34,10 +34,16 @@ def available(cmd): return shutil.which(cmd) is not None -def exec_cmd(args): +def exec_cmd(args, stderr=True): if x: print(*args) + if not stderr: + # Replace the current process with a new one + # Redirecting stderr to /dev/null + with open(os.devnull, 'w') as devnull: + os.dup2(devnull.fileno(), sys.stderr.fileno()) + try: return os.execvp(args[0], args) except Exception: diff --git a/ramalama/model.py b/ramalama/model.py index 5e888051..97a62790 100644 --- a/ramalama/model.py +++ b/ramalama/model.py @@ -86,7 +86,6 @@ def run(self, args): "llama-cli", "-m", symlink_path, - "--log-disable", "--in-prefix", "", "--in-suffix", @@ -98,7 +97,7 @@ def run(self, args): if not args.ARGS: exec_args.append("-cnv") - exec_cmd(exec_args) + exec_cmd(exec_args, False) def serve(self, args): symlink_path = self.pull(args)