Added ollama debbugging messages to about dialog
This commit is contained in:
parent
b8fe222052
commit
11dd13b430
@ -3,6 +3,7 @@
|
|||||||
Handles running, stopping and resetting the integrated Ollama instance
|
Handles running, stopping and resetting the integrated Ollama instance
|
||||||
"""
|
"""
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import threading
|
||||||
import os
|
import os
|
||||||
from time import sleep
|
from time import sleep
|
||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
@ -15,6 +16,14 @@ instance = None
|
|||||||
port = 11435
|
port = 11435
|
||||||
overrides = {}
|
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()
|
||||||
|
|
||||||
def start():
|
def start():
|
||||||
if not os.path.isdir(os.path.join(cache_dir, 'tmp/ollama')):
|
if not os.path.isdir(os.path.join(cache_dir, 'tmp/ollama')):
|
||||||
os.mkdir(os.path.join(cache_dir, 'tmp/ollama'))
|
os.mkdir(os.path.join(cache_dir, 'tmp/ollama'))
|
||||||
@ -23,7 +32,9 @@ def start():
|
|||||||
params["OLLAMA_HOST"] = f"127.0.0.1:{port}" # You can't change this directly sorry :3
|
params["OLLAMA_HOST"] = f"127.0.0.1:{port}" # You can't change this directly sorry :3
|
||||||
params["HOME"] = data_dir
|
params["HOME"] = data_dir
|
||||||
params["TMPDIR"] = os.path.join(cache_dir, 'tmp/ollama')
|
params["TMPDIR"] = os.path.join(cache_dir, 'tmp/ollama')
|
||||||
instance = subprocess.Popen(["ollama", "serve"], env={**os.environ, **params}, stderr=subprocess.PIPE, text=True)
|
instance = subprocess.Popen(["ollama", "serve"], env={**os.environ, **params}, stderr=subprocess.PIPE, stdout=subprocess.PIPE, text=True)
|
||||||
|
threading.Thread(target=log_output, args=(instance.stdout,)).start()
|
||||||
|
threading.Thread(target=log_output, args=(instance.stderr,)).start()
|
||||||
logger.info("Starting Alpaca's Ollama instance...")
|
logger.info("Starting Alpaca's Ollama instance...")
|
||||||
logger.debug(params)
|
logger.debug(params)
|
||||||
sleep(1)
|
sleep(1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user