XanderJC commited on
Commit
c5cd535
·
1 Parent(s): 0eff0a1

save final screenshot

Browse files
.gitignore CHANGED
@@ -171,4 +171,5 @@ cython_debug/
171
  .pypirc
172
 
173
  logs/
174
- local_trajectories/
 
 
171
  .pypirc
172
 
173
  logs/
174
+ local_trajectories/
175
+ screenshots/
src/proxy_lite/cli.py CHANGED
@@ -1,5 +1,6 @@
1
  import argparse
2
  import asyncio
 
3
  import os
4
  from pathlib import Path
5
  from typing import Optional
@@ -35,7 +36,15 @@ def do_command(args):
35
  if args.viewport_height:
36
  config.viewport_height = args.viewport_height
37
  o = Runner(config=config)
38
- asyncio.run(o.run(do_text))
 
 
 
 
 
 
 
 
39
 
40
 
41
  def main():
 
1
  import argparse
2
  import asyncio
3
+ import base64
4
  import os
5
  from pathlib import Path
6
  from typing import Optional
 
36
  if args.viewport_height:
37
  config.viewport_height = args.viewport_height
38
  o = Runner(config=config)
39
+ result = asyncio.run(o.run(do_text))
40
+
41
+ final_screenshot = result.observations[-1].info["original_image"]
42
+ folder_path = Path(__file__).parent.parent.parent / "screenshots"
43
+ folder_path.mkdir(parents=True, exist_ok=True)
44
+ path = folder_path / f"{result.run_id}.png"
45
+ with open(path, "wb") as f:
46
+ f.write(base64.b64decode(final_screenshot))
47
+ logger.info(f"🤖 Screenshot saved to {path}")
48
 
49
 
50
  def main():
src/proxy_lite/configs/default.yaml CHANGED
@@ -7,6 +7,7 @@ environment:
7
  include_poi_text: true
8
  headless: false
9
  homepage: https://www.google.co.uk
 
10
  solver:
11
  name: simple
12
  agent:
 
7
  include_poi_text: true
8
  headless: false
9
  homepage: https://www.google.co.uk
10
+ keep_original_image: true
11
  solver:
12
  name: simple
13
  agent:
src/proxy_lite/recorder.py CHANGED
@@ -3,7 +3,6 @@ from __future__ import annotations
3
  import datetime
4
  import json
5
  import os
6
- import sys
7
  import uuid
8
  from pathlib import Path
9
  from typing import Any, Optional, Self
@@ -80,7 +79,7 @@ class DataRecorder:
80
  self.local_folder = local_folder
81
 
82
  def initialise_run(self, task: str) -> Run:
83
- self.local_folder = Path(os.path.abspath(".")) / "local_trajectories"
84
  os.makedirs(self.local_folder, exist_ok=True)
85
  return Run.initialise(task)
86
 
 
3
  import datetime
4
  import json
5
  import os
 
6
  import uuid
7
  from pathlib import Path
8
  from typing import Any, Optional, Self
 
79
  self.local_folder = local_folder
80
 
81
  def initialise_run(self, task: str) -> Run:
82
+ self.local_folder = Path(__file__).parent.parent.parent / "local_trajectories"
83
  os.makedirs(self.local_folder, exist_ok=True)
84
  return Run.initialise(task)
85