@@ -225,7 +225,7 @@ async def run_custom_agent(
225
225
import argparse
226
226
import gradio as gr
227
227
from gradio .themes import Base , Default , Soft , Monochrome , Glass , Origin , Citrus , Ocean
228
- import os
228
+ import os , glob
229
229
230
230
# Define the theme map globally
231
231
theme_map = {
@@ -238,7 +238,7 @@ async def run_custom_agent(
238
238
"Ocean" : Ocean ()
239
239
}
240
240
241
- def create_ui (theme_name = "Citrus" ):
241
+ def create_ui ():
242
242
"""Create the UI with the specified theme"""
243
243
# Enhanced styling for better visual appeal
244
244
css = """
@@ -258,7 +258,7 @@ def create_ui(theme_name="Citrus"):
258
258
}
259
259
"""
260
260
261
- with gr .Blocks (title = "Browser Use WebUI" , theme = theme_map [theme_name ], css = css ) as demo :
261
+ with gr .Blocks (title = "Browser Use WebUI" , theme = theme_map ["Ocean" ], css = css ) as demo :
262
262
with gr .Row ():
263
263
gr .Markdown (
264
264
"""
@@ -268,15 +268,6 @@ def create_ui(theme_name="Citrus"):
268
268
elem_classes = ["header-text" ]
269
269
)
270
270
271
- # Quick access theme switcher at the top
272
- with gr .Row (elem_classes = ["theme-section" ]):
273
- theme_dropdown = gr .Dropdown (
274
- choices = list (theme_map .keys ()),
275
- value = theme_name ,
276
- label = "🎨 Quick Theme Switch" ,
277
- container = False
278
- )
279
-
280
271
with gr .Tabs () as tabs :
281
272
with gr .TabItem ("🤖 Agent Settings" , id = 1 ):
282
273
with gr .Group ():
@@ -303,7 +294,7 @@ def create_ui(theme_name="Citrus"):
303
294
with gr .TabItem ("🔧 LLM Configuration" , id = 2 ):
304
295
with gr .Group ():
305
296
llm_provider = gr .Dropdown (
306
- ["anthropic" , "openai" , "gemini" , "azure_openai" , "deepseek" ],
297
+ ["anthropic" , "openai" , "gemini" , "azure_openai" , "deepseek" , "" ],
307
298
label = "LLM Provider" ,
308
299
value = "gemini" ,
309
300
info = "Select your preferred language model provider"
@@ -391,15 +382,27 @@ def create_ui(theme_name="Citrus"):
391
382
392
383
with gr .TabItem ("🎬 Recordings" , id = 5 ):
393
384
def list_videos (path ):
385
+ """Return the latest video file from the specified path."""
394
386
if not os .path .exists (path ):
395
387
return ["Recording path not found" ]
396
- video_files = [f for f in os .listdir (path ) if f .endswith (('.mp4' , '.webm' ))]
397
- return [os .path .join (path , vf ) for vf in video_files ]
388
+
389
+ # Get all video files in the directory
390
+ video_files = glob .glob (os .path .join (path , '*.[mM][pP]4' )) + glob .glob (os .path .join (path , '*.[wW][eE][bB][mM]' ))
391
+
392
+ if not video_files :
393
+ return ["No recordings found" ]
394
+
395
+ # Sort files by modification time (latest first)
396
+ video_files .sort (key = os .path .getmtime , reverse = True )
397
+
398
+ # Return only the latest video
399
+ return [video_files [0 ]]
398
400
399
401
def display_videos (recording_path ):
402
+ """Display the latest video in the gallery."""
400
403
return list_videos (recording_path )
401
404
402
- recording_display = gr .Gallery (label = "Recorded Videos " , type = "video" )
405
+ recording_display = gr .Gallery (label = "Latest Recording " , type = "video" )
403
406
404
407
demo .load (
405
408
display_videos ,
@@ -436,17 +439,6 @@ def display_videos(recording_path):
436
439
show_label = True
437
440
)
438
441
439
- # Handle theme changes
440
- def reload_ui (new_theme ):
441
- """Reload the UI with the new theme"""
442
- return create_ui (new_theme )
443
-
444
- theme_dropdown .change (
445
- fn = reload_ui ,
446
- inputs = [theme_dropdown ],
447
- outputs = [demo ]
448
- )
449
-
450
442
# Run button click handler
451
443
run_button .click (
452
444
fn = run_browser_agent ,
0 commit comments