@@ -30,7 +30,7 @@ def flush(self):
3030class InstallerApp :
3131 def __init__ (self , root ):
3232 self .root = root
33- self .root .title ("Open WebUI Conda Installer (Beta v0.1.1 )" )
33+ self .root .title ("Open WebUI Conda Installer (Beta v0.1.3 )" )
3434 self .root .geometry ("800x600" )
3535 self .root .resizable (True , True )
3636
@@ -47,7 +47,7 @@ def __init__(self, root):
4747 self .progress_text .set ("Installation Progress" )
4848
4949 # Instructions Section
50- Label (frame , text = "Instructions" , font = ("Arial" , 14 , "bold" )).pack (anchor = "w" , pady = (20 , 10 ))
50+ Label (frame , text = "Instructions" , font = ("Arial" , 14 , "bold" )).pack (anchor = "w" , pady = (10 , 10 ))
5151 Label (
5252 frame ,
5353 text = "This installer will set up Miniconda and Open WebUI.Click 'Install' to begin." ,
@@ -89,10 +89,33 @@ def __init__(self, root):
8989 self .update_button .pack (side = "left" , padx = 5 )
9090 self .update_button .config (state = "disabled" )
9191
92- # Add Icon Button
93- # self.add_icon_button = Button(button_frame, text="Add Icon", command=self.add_icon)
94- # self.add_icon_button.pack(side="left", padx=5)
95- # self.add_icon_button.config(state="normal") # Enable the button
92+ # Adding Ollama Section
93+ ollama_frame = Frame (frame )
94+ ollama_frame .pack (fill = "x" , pady = 20 )
95+
96+ # Ollama Heading
97+ Label (ollama_frame , text = "Ollama" , font = ("Arial" , 14 , "bold" )).grid (row = 0 , column = 0 , sticky = "w" , padx = 10 , pady = 5 )
98+
99+ # Ollama Description on the Left
100+ ollama_description = Label (
101+ ollama_frame ,
102+ text = "Open WebUI uses Ollama to handle serving local models to the interface. "
103+ "If you need it, feel free to install it now." ,
104+ font = ("Arial" , 12 ),
105+ wraplength = 550 ,
106+ anchor = "w" ,
107+ justify = "left" ,
108+ )
109+ ollama_description .grid (row = 1 , column = 0 , sticky = "w" , padx = 10 , pady = 5 )
110+
111+ # Install Ollama Button on the Right
112+ self .install_ollama_button = Button (
113+ ollama_frame ,
114+ text = "Install Ollama" ,
115+ command = self .install_ollama ,
116+ )
117+ self .install_ollama_button .grid (row = 1 , column = 1 , sticky = "e" , padx = 10 , pady = 5 )
118+ self .install_ollama_button .config (state = "disabled" ) # Initially disabled
96119
97120 # Perform initial checks
98121 self .perform_initial_checks ()
@@ -104,6 +127,49 @@ def update_progress(self, step, total_steps):
104127 else :
105128 self .progress_text .set (f"Installation Progress [{ step } /{ total_steps } ]" )
106129
130+
131+
132+ def install_ollama (self ):
133+ """Handle the installation of Ollama."""
134+ def ollama_install_task ():
135+ try :
136+ self .install_ollama_button .config (state = "disabled" )
137+ # Define the URL and target path for the installer
138+ ollama_url = "https://ollama.com/download/OllamaSetup.exe"
139+ installer_name = "OllamaSetup.exe"
140+ installer_path = os .path .join (os .getcwd (), installer_name ) # Save in current directory
141+
142+ Logger .log ("Downloading Ollama installer..." )
143+
144+ # Download the installer
145+ import urllib .request
146+ with urllib .request .urlopen (ollama_url ) as response , open (installer_path , 'wb' ) as out_file :
147+ data = response .read ()
148+ out_file .write (data )
149+
150+ Logger .log ("Ollama installer downloaded successfully." )
151+
152+
153+ # Run the installer
154+ Logger .log ("Running Ollama installer..." )
155+ subprocess .Popen (installer_path , shell = True )
156+
157+ Logger .log ("Ollama installation initiated. Follow the on-screen instructions to complete the installation." )
158+
159+ except Exception as e :
160+ Logger .log (f"Failed to install Ollama: { e } " )
161+ messagebox .showerror ("Error" , f"Failed to install Ollama: { e } " )
162+
163+ # Run the installation task in a separate thread
164+ threading .Thread (target = ollama_install_task , daemon = True ).start ()
165+
166+ def update_ollama_button_state (self ):
167+ """Enable the Ollama button if the Start Open WebUI button is enabled."""
168+ if self .start_button ["state" ] == "normal" :
169+ self .install_ollama_button .config (state = "normal" )
170+ else :
171+ self .install_ollama_button .config (state = "disabled" )
172+
107173 def add_icon (self ):
108174 """Create a desktop shortcut for the application."""
109175 def icon_task ():
@@ -230,7 +296,7 @@ def checks_task():
230296 print ("Error: Could not find conda executable or the environment is not properly set up." )
231297 open_webui_installed = False
232298 else :
233- print ("Since the environment is not set up, open-webui is not installed ." )
299+ print ("Please Click 'Install' to set up Open WebUI ." )
234300 open_webui_installed = False
235301 update_available = False
236302
@@ -263,32 +329,37 @@ def checks_task():
263329 self .root .after (0 , self .start_button .config , {'state' : 'normal' , 'text' : 'Start Open WebUI' , 'command' : self .start_open_webui })
264330 else :
265331 self .root .after (0 , self .start_button .config , {'state' : 'disabled' })
332+
333+ self .root .after (0 , self .update_ollama_button_state )
266334 except Exception as e :
267335 print (f"Error during initial checks: { e } " )
268336 # If there's an error, assume not all checks passed
269337 self .root .after (0 , self .update_install_button_state , False , False , False , False )
270338
339+
271340 # Run the checks in a separate thread
272341 threading .Thread (target = checks_task , daemon = True ).start ()
273342
274343
275344 def update_install_button_state (self , conda_installed , env_exists , open_webui_installed , update_available ):
276345 """Enable or disable the Install, Start, and Update buttons based on initial checks."""
277346 if conda_installed and env_exists and open_webui_installed :
278- # All checks passed
279347 self .install_button .config (state = "disabled" )
280- print ("All components are already installed." )
348+ print ("All components are installed." )
349+ print ("Click 'Start Open WebUI' to Launch." )
281350 else :
282- # Some checks failed
283351 self .install_button .config (state = "normal" )
284352 self .start_button .config (state = "disabled" )
285353
286- # Enable or disable the Update Open WebUI button
354+ # Update the Update button
287355 if open_webui_installed and update_available :
288356 self .update_button .config (state = "normal" )
289357 else :
290358 self .update_button .config (state = "disabled" )
291359
360+ # Update Ollama button state
361+ self .update_ollama_button_state ()
362+
292363
293364 def check_process_running (self , pid ):
294365 """Check if a process with the given PID is running (Windows compatible)."""
@@ -306,7 +377,7 @@ def start_task():
306377 try :
307378 self .start_button .config (state = "disabled" )
308379 Logger .log (f"Starting Open WebUI Server..." )
309- Logger .log (f"Especially the first time, this may take a moment ." )
380+ Logger .log (f"This may take a few minutes depending on your computer. Your browser will open automatically when the server is ready ." )
310381 installer = MinicondaInstaller ()
311382 env_setup = EnvironmentSetup (installer .base_path , installer .miniconda_path )
312383 conda_exe = env_setup .conda_exe
@@ -350,8 +421,6 @@ def start_task():
350421
351422 if open_webui_pid is not None :
352423 break # Found the process, exit the outer loop
353- else :
354- Logger .log (f"Attempt { attempt + 1 } /10: Open WebUI process not found yet." )
355424
356425 if open_webui_pid is None :
357426 Logger .log ("Failed to find open-webui process after multiple attempts.\n " )
@@ -366,15 +435,15 @@ def start_task():
366435
367436
368437 # Check if the server is accessible on http://localhost:8080
369- Logger .log ("Checking for server availability..." )
438+ # Logger.log("Checking for server availability...")
439+ # Logger.log("Your browser will open automatically when the server is ready.")
370440 server_ready = False
371441 for attempt in range (120 ): # Retry up to 20 times with a delay
372442 try :
373443 with socket .create_connection (("localhost" , 8080 ), timeout = 2 ):
374444 server_ready = True
375445 break
376446 except (socket .timeout , ConnectionRefusedError ):
377- Logger .log (f"Attempt { attempt + 1 } /20: Server not ready yet. Retrying in 2 seconds..." )
378447 time .sleep (2 )
379448
380449 if server_ready :
0 commit comments