39
39
from src .browser .custom_context import BrowserContextConfig , CustomBrowserContext
40
40
from src .controller .custom_controller import CustomController
41
41
from gradio .themes import Citrus , Default , Glass , Monochrome , Ocean , Origin , Soft , Base
42
- from src .utils .default_config_settings import default_config , load_config_from_file , save_config_to_file
42
+ from src .utils .default_config_settings import default_config , load_config_from_file , save_config_to_file , save_current_config , update_ui_from_config
43
43
from src .utils .utils import update_model_dropdown , get_latest_files , capture_screenshot
44
44
45
45
from dotenv import load_dotenv
@@ -809,50 +809,6 @@ def create_ui(config, theme_name="Ocean"):
809
809
interactive = False
810
810
)
811
811
812
- def update_ui_from_config (config_file ):
813
- if config_file is not None :
814
- loaded_config = load_config_from_file (config_file .name )
815
- if isinstance (loaded_config , dict ):
816
- return (
817
- gr .update (value = loaded_config .get ("agent_type" , "custom" )),
818
- gr .update (value = loaded_config .get ("max_steps" , 100 )),
819
- gr .update (value = loaded_config .get ("max_actions_per_step" , 10 )),
820
- gr .update (value = loaded_config .get ("use_vision" , True )),
821
- gr .update (value = loaded_config .get ("tool_call_in_content" , True )),
822
- gr .update (value = loaded_config .get ("llm_provider" , "openai" )),
823
- gr .update (value = loaded_config .get ("llm_model_name" , "gpt-4o" )),
824
- gr .update (value = loaded_config .get ("llm_temperature" , 1.0 )),
825
- gr .update (value = loaded_config .get ("llm_base_url" , "" )),
826
- gr .update (value = loaded_config .get ("llm_api_key" , "" )),
827
- gr .update (value = loaded_config .get ("use_own_browser" , False )),
828
- gr .update (value = loaded_config .get ("keep_browser_open" , False )),
829
- gr .update (value = loaded_config .get ("headless" , False )),
830
- gr .update (value = loaded_config .get ("disable_security" , True )),
831
- gr .update (value = loaded_config .get ("enable_recording" , True )),
832
- gr .update (value = loaded_config .get ("window_w" , 1280 )),
833
- gr .update (value = loaded_config .get ("window_h" , 1100 )),
834
- gr .update (value = loaded_config .get ("save_recording_path" , "./tmp/record_videos" )),
835
- gr .update (value = loaded_config .get ("save_trace_path" , "./tmp/traces" )),
836
- gr .update (value = loaded_config .get ("save_agent_history_path" , "./tmp/agent_history" )),
837
- gr .update (value = loaded_config .get ("task" , "" )),
838
- "Configuration loaded successfully."
839
- )
840
- else :
841
- return (
842
- gr .update (), gr .update (), gr .update (), gr .update (), gr .update (),
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 (), "Error: Invalid configuration file."
847
- )
848
- return (
849
- gr .update (), gr .update (), gr .update (), gr .update (), gr .update (),
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 (), "No file selected."
854
- )
855
-
856
812
load_config_button .click (
857
813
fn = update_ui_from_config ,
858
814
inputs = [config_file_input ],
@@ -865,32 +821,6 @@ def update_ui_from_config(config_file):
865
821
]
866
822
)
867
823
868
- def save_current_config (* args ):
869
- current_config = {
870
- "agent_type" : args [0 ],
871
- "max_steps" : args [1 ],
872
- "max_actions_per_step" : args [2 ],
873
- "use_vision" : args [3 ],
874
- "tool_call_in_content" : args [4 ],
875
- "llm_provider" : args [5 ],
876
- "llm_model_name" : args [6 ],
877
- "llm_temperature" : args [7 ],
878
- "llm_base_url" : args [8 ],
879
- "llm_api_key" : args [9 ],
880
- "use_own_browser" : args [10 ],
881
- "keep_browser_open" : args [11 ],
882
- "headless" : args [12 ],
883
- "disable_security" : args [13 ],
884
- "enable_recording" : args [14 ],
885
- "window_w" : args [15 ],
886
- "window_h" : args [16 ],
887
- "save_recording_path" : args [17 ],
888
- "save_trace_path" : args [18 ],
889
- "save_agent_history_path" : args [19 ],
890
- "task" : args [20 ],
891
- }
892
- return save_config_to_file (current_config )
893
-
894
824
save_config_button .click (
895
825
fn = save_current_config ,
896
826
inputs = [
0 commit comments