@@ -793,7 +793,118 @@ def create_ui(config, theme_name="Ocean"):
793
793
label = "Live Browser View" ,
794
794
)
795
795
796
- with gr .TabItem ("📊 Results" , id = 5 ):
796
+ with gr .TabItem ("📁 Configuration" , id = 5 ):
797
+ with gr .Group ():
798
+ config_file_input = gr .File (
799
+ label = "Load Config File" ,
800
+ file_types = [".pkl" ],
801
+ interactive = True
802
+ )
803
+
804
+ load_config_button = gr .Button ("Load Existing Config From File" , variant = "primary" )
805
+ save_config_button = gr .Button ("Save Current Config" , variant = "primary" )
806
+
807
+ config_status = gr .Textbox (
808
+ label = "Status" ,
809
+ lines = 2 ,
810
+ interactive = False
811
+ )
812
+
813
+ def update_ui_from_config (config_file ):
814
+ if config_file is not None :
815
+ loaded_config = load_config_from_file (config_file .name )
816
+ if isinstance (loaded_config , dict ):
817
+ return (
818
+ gr .update (value = loaded_config .get ("agent_type" , "custom" )),
819
+ gr .update (value = loaded_config .get ("max_steps" , 100 )),
820
+ gr .update (value = loaded_config .get ("max_actions_per_step" , 10 )),
821
+ gr .update (value = loaded_config .get ("use_vision" , True )),
822
+ gr .update (value = loaded_config .get ("tool_call_in_content" , True )),
823
+ gr .update (value = loaded_config .get ("llm_provider" , "openai" )),
824
+ gr .update (value = loaded_config .get ("llm_model_name" , "gpt-4o" )),
825
+ gr .update (value = loaded_config .get ("llm_temperature" , 1.0 )),
826
+ gr .update (value = loaded_config .get ("llm_base_url" , "" )),
827
+ gr .update (value = loaded_config .get ("llm_api_key" , "" )),
828
+ gr .update (value = loaded_config .get ("use_own_browser" , False )),
829
+ gr .update (value = loaded_config .get ("keep_browser_open" , False )),
830
+ gr .update (value = loaded_config .get ("headless" , False )),
831
+ gr .update (value = loaded_config .get ("disable_security" , True )),
832
+ gr .update (value = loaded_config .get ("enable_recording" , True )),
833
+ gr .update (value = loaded_config .get ("window_w" , 1280 )),
834
+ gr .update (value = loaded_config .get ("window_h" , 1100 )),
835
+ gr .update (value = loaded_config .get ("save_recording_path" , "./tmp/record_videos" )),
836
+ gr .update (value = loaded_config .get ("save_trace_path" , "./tmp/traces" )),
837
+ gr .update (value = loaded_config .get ("save_agent_history_path" , "./tmp/agent_history" )),
838
+ gr .update (value = loaded_config .get ("task" , "" )),
839
+ "Configuration loaded successfully."
840
+ )
841
+ else :
842
+ return (
843
+ gr .update (), gr .update (), gr .update (), gr .update (), gr .update (),
844
+ gr .update (), gr .update (), gr .update (), gr .update (), gr .update (),
845
+ gr .update (), gr .update (), gr .update (), gr .update (), gr .update (),
846
+ gr .update (), gr .update (), gr .update (), gr .update (), gr .update (),
847
+ gr .update (), "Error: Invalid configuration file."
848
+ )
849
+ return (
850
+ gr .update (), gr .update (), gr .update (), gr .update (), gr .update (),
851
+ gr .update (), gr .update (), gr .update (), gr .update (), gr .update (),
852
+ gr .update (), gr .update (), gr .update (), gr .update (), gr .update (),
853
+ gr .update (), gr .update (), gr .update (), gr .update (), gr .update (),
854
+ gr .update (), "No file selected."
855
+ )
856
+
857
+ load_config_button .click (
858
+ fn = update_ui_from_config ,
859
+ inputs = [config_file_input ],
860
+ outputs = [
861
+ agent_type , max_steps , max_actions_per_step , use_vision , tool_call_in_content ,
862
+ llm_provider , llm_model_name , llm_temperature , llm_base_url , llm_api_key ,
863
+ use_own_browser , keep_browser_open , headless , disable_security , enable_recording ,
864
+ window_w , window_h , save_recording_path , save_trace_path , save_agent_history_path ,
865
+ task , config_status
866
+ ]
867
+ )
868
+
869
+ def save_current_config (* args ):
870
+ current_config = {
871
+ "agent_type" : args [0 ],
872
+ "max_steps" : args [1 ],
873
+ "max_actions_per_step" : args [2 ],
874
+ "use_vision" : args [3 ],
875
+ "tool_call_in_content" : args [4 ],
876
+ "llm_provider" : args [5 ],
877
+ "llm_model_name" : args [6 ],
878
+ "llm_temperature" : args [7 ],
879
+ "llm_base_url" : args [8 ],
880
+ "llm_api_key" : args [9 ],
881
+ "use_own_browser" : args [10 ],
882
+ "keep_browser_open" : args [11 ],
883
+ "headless" : args [12 ],
884
+ "disable_security" : args [13 ],
885
+ "enable_recording" : args [14 ],
886
+ "window_w" : args [15 ],
887
+ "window_h" : args [16 ],
888
+ "save_recording_path" : args [17 ],
889
+ "save_trace_path" : args [18 ],
890
+ "save_agent_history_path" : args [19 ],
891
+ "task" : args [20 ],
892
+ }
893
+ return save_config_to_file (current_config )
894
+
895
+ save_config_button .click (
896
+ fn = save_current_config ,
897
+ inputs = [
898
+ agent_type , max_steps , max_actions_per_step , use_vision , tool_call_in_content ,
899
+ llm_provider , llm_model_name , llm_temperature , llm_base_url , llm_api_key ,
900
+ use_own_browser , keep_browser_open , headless , disable_security ,
901
+ enable_recording , window_w , window_h , save_recording_path , save_trace_path ,
902
+ save_agent_history_path , task ,
903
+ ],
904
+ outputs = [config_status ]
905
+ )
906
+
907
+ with gr .TabItem ("📊 Results" , id = 6 ):
797
908
with gr .Group ():
798
909
799
910
recording_display = gr .Video (label = "Latest Recording" )
@@ -852,7 +963,7 @@ def create_ui(config, theme_name="Ocean"):
852
963
],
853
964
)
854
965
855
- with gr .TabItem ("🎥 Recordings" , id = 6 ):
966
+ with gr .TabItem ("🎥 Recordings" , id = 7 ):
856
967
def list_recordings (save_recording_path ):
857
968
if not os .path .exists (save_recording_path ):
858
969
return []
@@ -913,7 +1024,7 @@ def main():
913
1024
parser .add_argument ("--dark-mode" , action = "store_true" , help = "Enable dark mode" )
914
1025
args = parser .parse_args ()
915
1026
916
- config_dict = load_config_from_file ()
1027
+ config_dict = load_config_from_file ("./default_config.pkl" ) or {}
917
1028
918
1029
demo = create_ui (config_dict , theme_name = args .theme )
919
1030
demo .launch (server_name = args .ip , server_port = args .port )
0 commit comments