@@ -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