Skip to content

Commit

Permalink
Fix Ollama version
Browse files Browse the repository at this point in the history
  • Loading branch information
alisson-anjos committed Dec 3, 2024
1 parent 16a8d4a commit 8e652ef
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ class OllamaUtil:
def __init__(self):
pass

def __init__(self, client):
self.client = client

def tensor_to_image(self, tensor):
tensor = tensor.cpu()

Expand All @@ -41,6 +44,11 @@ def image_to_base64(self, image: Image.Image):
image_base64 = base64.b64encode(image_bytes)
return image_base64

def get_models(self):
try:
return [model_l['name'] for model_l in self.client.list()['models']]
except Exception as e:
return [model_l['model'] for model_l in self.client.list()['models']]

def pull_model(self, model, client):
current_digest, bars = '', {}
Expand Down Expand Up @@ -145,9 +153,9 @@ def run_captioner(self, model, custom_model, api_host, timeout, low_vram, keep_m

client = Client(api_host, timeout=timeout)

ollama_util = OllamaUtil()
ollama_util = OllamaUtil(client)

models = [model_l['name'] for model_l in client.list()['models']]
models = ollama_util.get_models()

model = model.split(' ')[0].strip()
custom_model = custom_model.strip()
Expand Down Expand Up @@ -359,9 +367,9 @@ def ollama_image_describe(self,

client = Client(api_host, timeout=timeout)

ollama_util = OllamaUtil()
ollama_util = OllamaUtil(client)

models = [model_l['name'] for model_l in client.list()['models']]
models = ollama_util.get_models()

model = model.split(' ')[0].strip()
custom_model = custom_model.strip()
Expand Down Expand Up @@ -524,9 +532,9 @@ def ollama_text_describe(self,
system_context):

client = Client(api_host, timeout=timeout)
ollama_util = OllamaUtil()
ollama_util = OllamaUtil(client)

models = [model_l['name'] for model_l in client.list()['models']]
models = ollama_util.get_models()

model = model.split(' ')[0].strip()
custom_model = custom_model.strip()
Expand Down

0 comments on commit 8e652ef

Please sign in to comment.