Skip to content

Commit 2b2edc3

Browse files
committed
feat: load and save functions to follow uuid format
1 parent b540b35 commit 2b2edc3

File tree

1 file changed

+15
-33
lines changed

1 file changed

+15
-33
lines changed
Lines changed: 15 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,22 @@
11
import os
22
import pickle
3+
import uuid
34

45

5-
def load_config_from_file(file_path: str='./.config.pkl',) -> dict:
6+
def load_config_from_file(config_file):
7+
"""Load settings from a UUID.pkl file."""
68
try:
7-
with open(file_path, 'rb') as file:
8-
loaded_config = pickle.load(file)
9-
except FileNotFoundError as FNFE:
10-
from dotenv import load_dotenv
11-
load_dotenv()
12-
return {
13-
"agent_type": "custom",
14-
"max_steps": 100,
15-
"max_actions_per_step": 10,
16-
"use_vision": True,
17-
"tool_call_in_content": True,
18-
"llm_provider": "openai",
19-
"llm_model_name": "gpt-4o",
20-
"llm_temperature": 1.0,
21-
"llm_base_url": '',
22-
"llm_api_key": '',
23-
"use_own_browser": False,
24-
"keep_browser_open": os.getenv("CHROME_PERSISTENT_SESSION", "False").lower() == "true",
25-
"headless": False,
26-
"disable_security": True,
27-
"enable_recording": True,
28-
"window_w": 1280,
29-
"window_h": 1100,
30-
"save_recording_path": "./tmp/record_videos",
31-
"save_trace_path": "./tmp/traces",
32-
"save_agent_history_path": "./tmp/agent_history",
33-
"task": "go to google.com and type 'OpenAI' click search and give me the first url",
34-
}
35-
return loaded_config
9+
with open(config_file, 'rb') as f:
10+
settings = pickle.load(f)
11+
return settings
12+
except Exception as e:
13+
return f"Error loading configuration: {str(e)}"
3614

3715

38-
def save_config_to_file(config, file_path: str='./.config.pkl',) -> None:
39-
with open(file_path, 'wb') as file:
40-
pickle.dump(config, file)
16+
def save_config_to_file(settings, save_dir="./tmp/webui_settings"):
17+
"""Save the current settings to a UUID.pkl file with a UUID name."""
18+
os.makedirs(save_dir, exist_ok=True)
19+
config_file = os.path.join(save_dir, f"{uuid.uuid4()}.pkl")
20+
with open(config_file, 'wb') as f:
21+
pickle.dump(settings, f)
22+
return f"Configuration saved to {config_file}"

0 commit comments

Comments
 (0)