@@ -96,9 +96,11 @@ def generate_model_rows(rawData: dict):
9696ollama_spacer_text = ft .Text ('' )
9797ollama_download_textField = ft .TextField (width = 500 , height = 50 , label = 'Enter model name eg mistral:7b' , expand = True )
9898ollama_download_pbar = ft .ProgressBar (bar_height = 20 , color = "green" )
99- ollama_download_pbar_text = ft .Text ()
99+ ollama_download_pbar_text = ft .Text (max_lines = 2 )
100100ollama_download_pbar .visible = False
101101ollama_download_pbar_text .visible = False
102+ restart_required_container = ft .Text ('Restart PyOllaMx to reload new models' , size = 15 , bgcolor = ft .colors .RED_400 , color = ft .colors .YELLOW_ACCENT )
103+ restart_required_container .visible = False
102104
103105def return_pb_value (total , current ):
104106 if total == 0 or current == 0 :
@@ -113,21 +115,27 @@ def download_from_ollama(e: ft.ControlEvent):
113115 model_name = ollama_download_textField .value
114116 ollama_download_pbar_text .value = f'Contacting Ollama Library to pull { model_name } ⏳ .....'
115117 e .page .update ()
116- status = pull (model = model_name ,stream = True )
117- for s in status :
118- #print(f"S is {s}")
119- if 'total' in s and 'completed' in s :
120- #print("### Inside If")
121- ollama_download_pbar_text .value = s ['status' ]
122- ollama_download_pbar .value = return_pb_value (float (s ['total' ]), float (s ['completed' ]))
123- e .page .update ()
124- #print(f"ollama_download_pbar_text {ollama_download_pbar_text.value}")
125- #print(f"ollama_download_pbar {ollama_download_pbar.value}")
126- if s ['status' ] == 'success' :
127- ollama_download_pbar_text .value = f'Pulled { model_name } ✅ . Model list Refreshed ✅'
128- ollama_download_pbar .value = 1.0
129- ollama_models_table .rows = generate_model_rows (list ())
130- e .page .update ()
118+ try :
119+ status = pull (model = model_name ,stream = True )
120+ for s in status :
121+ #print(f"S is {s}")
122+ if 'total' in s and 'completed' in s :
123+ #print("### Inside If")
124+ ollama_download_pbar_text .value = s ['status' ]
125+ ollama_download_pbar .value = return_pb_value (float (s ['total' ]), float (s ['completed' ]))
126+ e .page .update ()
127+ #print(f"ollama_download_pbar_text {ollama_download_pbar_text.value}")
128+ #print(f"ollama_download_pbar {ollama_download_pbar.value}")
129+ if s ['status' ] == 'success' :
130+ ollama_download_pbar_text .value = f'Pulled { model_name } ✅ . Model list Refreshed ✅'
131+ ollama_download_pbar .value = 1.0
132+ ollama_models_table .rows = generate_model_rows (list ())
133+ restart_required_container .visible = True
134+ e .page .update ()
135+ except :
136+ ollama_download_pbar .value = 1.0
137+ ollama_download_pbar_text .value = f'🚨 Error occured while pulling { model_name } . Double check model name or whether Ollama 🦙 is running 💡'
138+ e .page .update ()
131139
132140
133141
@@ -155,11 +163,16 @@ def download_from_ollama(e: ft.ControlEvent):
155163 ], alignment = ft .MainAxisAlignment .SPACE_BETWEEN ),
156164 ollama_download_pbar_text ,
157165 ollama_download_pbar ,
166+ restart_required_container ,
158167 ft .Column ([
159168 ollama_models_table
160169 ], scroll = ft .ScrollMode .ADAPTIVE , height = 350 ),
161170],alignment = ft .MainAxisAlignment .START , horizontal_alignment = ft .CrossAxisAlignment .STRETCH , spacing = 10 )
162171
172+ coming_soon_view = ft .Column ([
173+ ft .Text (value = 'Coming Soon!' , style = ft .TextStyle (font_family = 'CabinSketch-Bold' ), size = 50 )
174+ ], alignment = ft .MainAxisAlignment .CENTER , horizontal_alignment = ft .CrossAxisAlignment .CENTER )
175+
163176mlx_control = ft .Column ([
164177 mlx_download_text ,
165178 ft .Row ([
@@ -179,7 +192,7 @@ def download_from_ollama(e: ft.ControlEvent):
179192 ),
180193 ft .Tab (
181194 text = "Mlx Models 🤗" ,
182- content = mlx_control
195+ content = coming_soon_view
183196 ),
184197 ],
185198 height = 490 ,
0 commit comments