From ed54b2846ae2bd35950aa7cff4840b53e41f97dd Mon Sep 17 00:00:00 2001 From: jeffser Date: Mon, 19 Aug 2024 23:06:58 -0600 Subject: [PATCH] Added exception catch to Ollama's output in case it can't decode message --- src/local_instance.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/local_instance.py b/src/local_instance.py index 90337bb..dbb03a6 100644 --- a/src/local_instance.py +++ b/src/local_instance.py @@ -19,10 +19,13 @@ overrides = {} def log_output(pipe): with open(os.path.join(data_dir, 'tmp.log'), 'a') as f: with pipe: - for line in iter(pipe.readline, ''): - print(line, end='') - f.write(line) - f.flush() + try: + for line in iter(pipe.readline, ''): + print(line, end='') + f.write(line) + f.flush() + except: + pass def start(): if not os.path.isdir(os.path.join(cache_dir, 'tmp/ollama')):