Better checker for Ollama instance missing

This commit is contained in:
jeffser 2024-09-03 21:56:37 -06:00
parent 19a8aade60
commit 79a7840f24
2 changed files with 26 additions and 26 deletions

View File

@ -2,7 +2,7 @@
""" """
Handles requests to remote and integrated instances of Ollama Handles requests to remote and integrated instances of Ollama
""" """
import json, os, requests, subprocess, threading import json, os, requests, subprocess, threading, shutil
from .internal import data_dir, cache_dir from .internal import data_dir, cache_dir
from logging import getLogger from logging import getLogger
from time import sleep from time import sleep
@ -92,6 +92,7 @@ class instance():
self.idle_timer.start() self.idle_timer.start()
def start(self): def start(self):
if shutil.which('ollama'):
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'))
self.instance = None self.instance = None
@ -111,6 +112,11 @@ class instance():
self.instance = instance self.instance = instance
if not self.idle_timer: if not self.idle_timer:
self.start_timer() self.start_timer()
else:
self.remote = True
if not self.remote_url:
self.remote_url = 'http://0.0.0.0:11434'
window.connection_error()
def stop(self): def stop(self):
if self.idle_timer: if self.idle_timer:

View File

@ -777,12 +777,6 @@ Generate a title following these rules:
if show_launch_dialog: if show_launch_dialog:
GLib.idle_add(self.launch_dialog.present, self) GLib.idle_add(self.launch_dialog.present, self)
#Check if Ollama instance doesn't exists
if not shutil.which('ollama'):
remote = True
if not remote_url:
remote_url = 'http://0.0.0.0:11434'
#Instance #Instance
self.launch_level_bar.set_value(0) self.launch_level_bar.set_value(0)
self.launch_status.set_description(_('Loading instance')) self.launch_status.set_description(_('Loading instance'))