|
11 | 11 | from ramalama.transports.base import Transport |
12 | 12 |
|
13 | 13 |
|
14 | | -def in_existing_cache(model_name, model_tag): |
| 14 | +def in_existing_cache(organization, model_name, model_tag): |
15 | 15 | if not available("ollama"): |
16 | 16 | return None |
17 | 17 | default_ollama_caches = [ |
18 | 18 | os.path.expanduser('~/.ollama/models'), |
19 | 19 | '/usr/share/ollama/.ollama/models', |
20 | 20 | ] |
| 21 | + if ollama_models_env := os.environ.get("OLLAMA_MODELS"): |
| 22 | + default_ollama_caches.insert(0, ollama_models_env) |
21 | 23 |
|
22 | 24 | for cache_dir in default_ollama_caches: |
23 | | - manifest_path = os.path.join(cache_dir, 'manifests', 'registry.ollama.ai', model_name, model_tag) |
| 25 | + manifest_path = os.path.join(cache_dir, 'manifests', 'registry.ollama.ai', organization, model_name, model_tag) |
24 | 26 | if os.access(manifest_path, os.R_OK): |
25 | 27 | with open(manifest_path, 'r') as file: |
26 | 28 | manifest_data = json.load(file) |
@@ -180,7 +182,7 @@ def pull(self, args) -> None: |
180 | 182 |
|
181 | 183 | ollama_repo = OllamaRepository(name, organization) |
182 | 184 | manifest = ollama_repo.fetch_manifest(tag) |
183 | | - ollama_cache_path = in_existing_cache(self.model_name, tag) |
| 185 | + ollama_cache_path = in_existing_cache(organization, self.model_name, tag) |
184 | 186 | is_model_in_ollama_cache = ollama_cache_path is not None |
185 | 187 | files: list[SnapshotFile] = ollama_repo.get_file_list(tag, cached_files, is_model_in_ollama_cache) |
186 | 188 |
|
|
0 commit comments