Skip to content

Commit 0e95f01

Browse files
authored
Merge pull request #1388 from CyanideByte/ollama-list-fix
Ollama model list fix and a typo
2 parents 3fe34e0 + 51a56df commit 0e95f01

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

interpreter/terminal_interface/local_setup.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def download_model(models_dir, models, interpreter):
7272
},
7373
{
7474
"name": "Mistral-7B-Instruct",
75-
"file_name": "Mistral-7B-Instruct-v0.3.Q5_K_M.llamafile",
75+
"file_name": "Mistral-7B-Instruct-v0.3.Q4_K_M.llamafile",
7676
"size": 4.40,
7777
"url": "https://huggingface.co/Mozilla/Mistral-7B-Instruct-v0.3-llamafile/resolve/main/Mistral-7B-Instruct-v0.3.Q4_K_M.llamafile?download=true",
7878
},
@@ -241,19 +241,21 @@ def download_model(models_dir, models, interpreter):
241241
["ollama", "list"], capture_output=True, text=True, check=True
242242
)
243243
lines = result.stdout.split("\n")
244+
244245
names = [
245246
line.split()[0].replace(":latest", "")
246-
for line in lines[1:]
247-
if line.strip()
247+
for line in lines
248+
if line.strip() and not line.startswith("failed") and not line.startswith("NAME")
248249
] # Extract names, trim out ":latest", skip header
249250

250-
if "llama3" in names:
251-
names.remove("llama3")
252-
names = ["llama3"] + names
253-
254-
if "codestral" in names:
255-
names.remove("codestral")
256-
names = ["codestral"] + names
251+
# Models whose name contain one of these keywords will be moved to the front of the list
252+
priority_models=["llama3","codestral"]
253+
priority_models_found=[]
254+
for word in priority_models:
255+
models_to_move=[name for name in names if word.lower() in name.lower()]
256+
priority_models_found.extend(models_to_move)
257+
names=[name for name in names if not any(word.lower() in name.lower() for word in priority_models)]
258+
names=priority_models_found+names
257259

258260
for model in ["llama3", "phi3", "wizardlm2", "codestral"]:
259261
if model not in names:

0 commit comments

Comments
 (0)