Browse Source

use Path / operator

Michael Yang 1 year ago
parent
commit
76fb9eea1e
2 changed files with 3 additions and 3 deletions
  1. 1 1
      ollama/engine.py
  2. 2 2
      ollama/model.py

+ 1 - 1
ollama/engine.py

@@ -30,7 +30,7 @@ def load(model_name, models={}):
     if not models.get(model_name, None):
         model_path = path.expanduser(model_name)
         if not path.exists(model_path):
-            model_path = path.join(MODELS_CACHE_PATH, model_name + ".bin")
+            model_path = MODELS_CACHE_PATH / model_name + ".bin"
 
         runners = {
             model_type: cls

+ 2 - 2
ollama/model.py

@@ -7,7 +7,7 @@ from tqdm import tqdm
 
 
 MODELS_MANIFEST = 'https://ollama.ai/api/models'
-MODELS_CACHE_PATH = path.join(Path.home(), '.ollama', 'models')
+MODELS_CACHE_PATH = Path.home() / '.ollama' / 'models'
 
 
 def models(*args, **kwargs):
@@ -78,7 +78,7 @@ def find_bin_file(json_response, location, branch):
 
 
 def download_file(download_url, file_name, file_size):
-    local_filename = path.join(MODELS_CACHE_PATH, file_name) + '.bin'
+    local_filename = MODELS_CACHE_PATH / file_name + '.bin'
 
     first_byte = path.getsize(local_filename) if path.exists(local_filename) else 0